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); } } }
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()); }