Ejemplo n.º 1
0
        // 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);
        }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
        public void UninitObject()
        {
            if (_isInit)
            {
                _selectable.Unselect();
            }

            _monoBehaviour      = null;
            _damageable         = null;
            _moveable           = null;
            _attackable         = null;
            _behaviorSwitchable = null;
            _carriable          = null;
            _isInit             = false;
        }
Ejemplo n.º 4
0
        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();
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
 public void Launch(ICarriable parentCarrier)
 {
     _parentCarrier = parentCarrier;
     StartCoroutine(LaunchSequence());
 }
Ejemplo n.º 7
0
 public virtual void PickItem(ICarriable item)
 {
 }
Ejemplo n.º 8
0
 /// <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);
 }
Ejemplo n.º 9
0
 private void IsCarriable()
 {
     ic = new Marker();
     Assert.AreEqual(ic.Carriable, true);
 }
Ejemplo n.º 10
0
 /// <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);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// removes item from list
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public override Boolean RemoveItem(ICarriable item)
 {
     return Items.Remove(item);
 }
Ejemplo n.º 12
0
 /// <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);
 }
Ejemplo n.º 13
0
 /// <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);
 }
Ejemplo n.º 14
0
 /// <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);
 }
Ejemplo n.º 15
0
 /// <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);
 }