sing UnityEngine;
using System.Collections;
using System.Collections.Generic;
using ORKFramework;
using ORKFramework.Behaviours;
public class EquipWeapon : MonoBehaviour
{
#region fields
Combatant combatant;
#endregion
#region init
// Use this for initialization
void Start ()
{
combatant = ComponentHelper.GetCombatant(gameObject);
if(combatant != null)
{
if (combatant.Inventory.HasWeapons())
{
List<IShortcut> wpns = combatant.Inventory.GetContent(combatant,false,false,true,false);
if(wpns.Count > 0)
{
IShortcut wpn = null;
//now choose a random weapon from the list to equip
int roll = DiceBag.Custom(0,wpns.Count-1);
if (wpns.Count == 1)
{
wpn = wpns[0]; //wpns.RandomObject();
}
else
{
wpn = wpns[roll]; //wpns.RandomObject();
}
if(wpn != null)
{
//create the shortcut and equip the item
EquipShortcut es = new EquipShortcut(EquipSet.Weapon,wpn.ID,1,1);
combatant.Equipment.Equip (2,es,null,false); //2 is my primary weapon slot which has an equipmentviewer attached. This is where the weapon will be displayed.
combatant.MarkResetStatus();
}
}
}
//we could add shields and helms here
}
}
#endregion
}
It looks like you're new here. If you want to get involved, click one of these buttons!