// Inventory public bool Carry(Entity that) { // Must be `close` to pickup if (!InRange(that, 1)) { return(false); } // Can only carry 'items' ICarriable item = that as ICarriable; if (that == null) { return(false); } // Must have space in inventory // Item must be 'pickable" if (CanCarry() && item.Pickup()) { _inventory.Add(that); return(true); } return(false); }
public void InitObject(MonoBehaviour monoBehaviourObj) { UninitObject(); _monoBehaviour = monoBehaviourObj; _selectable = _monoBehaviour.GetComponent <ISelectable>(); if (_selectable == null || !_selectable.CanSelect()) { UninitObject(); return; } _damageable = _monoBehaviour.GetComponent <IDamageable>(); _targetable = _monoBehaviour.GetComponent <ITargetable>(); _moveable = _monoBehaviour.GetComponent <IMoveable>(); _attackable = _monoBehaviour.GetComponent <IAttackable>(); _behaviorSwitchable = _monoBehaviour.GetComponent <IBehaviorSwitchable>(); _carriable = _monoBehaviour.GetComponent <ICarriable>(); if (_damageable != null) { // If enemy, don't select. if (_targetable.IsEnemy(_targetable.TeamId)) { UninitObject(); return; } } _selectable.Select(); _isInit = true; }
public void UninitObject() { if (_isInit) { _selectable.Unselect(); } _monoBehaviour = null; _damageable = null; _moveable = null; _attackable = null; _behaviorSwitchable = null; _carriable = null; _isInit = false; }
static void Start(string path) { char[,] map = LoadMap(path); Player player = new Player(1, 1, 100, 25); Enemy[] enemies = new Enemy[2]; ICarriable[] items = new ICarriable[2]; items[0] = new LightSword('S', "Sword"); items[1] = new LightSword('S', "Sword"); enemies[0] = new Enemy(4, 1, 100, 15, null); enemies[1] = new Enemy(8, 8, 100, 15, null); Map level = null; player.Set(map, player, enemies, ref level, items); level.Move(); }
public bool Drop(int index = 0) { if (_inventory.Count >= index) { return(false); } ICarriable item = _inventory[index] as ICarriable; if (item == null) { Debug.Log("ENTITY: ERROR, NON-ITEM IN INVENTORY"); return(false); } if (item.Place(CurrentPosition)) { _inventory.RemoveAt(index); return(true); } return(false); }
public void Launch(ICarriable parentCarrier) { _parentCarrier = parentCarrier; StartCoroutine(LaunchSequence()); }
public virtual void PickItem(ICarriable item) { }
/// <summary> /// the player can pick item .It will be added to the list of his items /// </summary> /// <param name="item"></param> public override void PickItem(ICarriable item) { if(Items.Count < MaxItemsToCarry) Items.Add(item); else Console.WriteLine("You reached the max for items you can hold. Drop an item to pick item - {0}.", item.Name); }
private void IsCarriable() { ic = new Marker(); Assert.AreEqual(ic.Carriable, true); }
/// <summary> /// player leaves the item.It will be added to list of items /// </summary> /// <param name="item"></param> public override void DropItem(ICarriable item) { Items.Add(item); }
/// <summary> /// removes item from list /// </summary> /// <param name="item"></param> /// <returns></returns> public override Boolean RemoveItem(ICarriable item) { return Items.Remove(item); }
/// <summary> /// The drop item method drops the item from location and the player picks it /// </summary> /// <param name="item"></param> public virtual void DropItem(ICarriable item) { Location.DropItem(item); }
/// <summary> /// this removes the items from the location when a player picks it up /// </summary> /// <param name="item"></param> /// <returns></returns> public virtual bool RemoveItem(ICarriable item) { return Location.RemoveItem(item); }
/// <summary> /// player leaves the item.It will be added to list of items /// </summary> /// <param name="item"></param> public void DropItem(ICarriable item) { Items.Add(item); }
/// <summary> /// the player can pick item .It will be added to the items of player /// </summary> /// <param name="item"></param> public void PickItem(ICarriable item) { Items.Add(item); }