예제 #1
0
    public void OnMove(IntVector2 to)
    {
        List <GameObject> collectables = intTransform.GetLevel().GetCollectablesAt(to);

        foreach (GameObject collectable in collectables.ToArray())
        {
            ItemCollectable itemCollectable = collectable.GetComponent <ItemCollectable>();
            if (itemCollectable && itemCollectable.item.GetType() == typeof(Weapon))
            {
                // Drop our item
                if (weapon)
                {
                    weapon.OnUnequip(this.gameObject);
                    intTransform.GetLevel().SpawnItem(weapon, to);
                }

                // Grab the item
                weapon = (Weapon)itemCollectable.item;
                weapon.OnEquip(this.gameObject);
                Destroy(collectable);
                intTransform.GetLevel().RemoveCollectableAt(collectable, to);

                SoundManager.S.Play(SoundManager.S.pickup);
            }
        }
    }
예제 #2
0
파일: Action.cs 프로젝트: TBartl/NecroClone
 public void RpcExecute(IntVector2 direction)
 {
     Action[] actions = this.GetComponents <Action>();
     for (int i = 0; i < actions.Length; i++)
     {
         Action action = actions[i];
         if (action == this)
         {
             NetManager.S.SendServerMessageToGroup(new NetMessage_ActionOccupant(intTransform.GetPos(), intTransform.GetLevel(), i, direction), ConnectionGroup.game);
             return;
         }
     }
     Debug.LogError("Tried to do an action that didn't exist " + this.GetType().ToString());
 }