Ejemplo n.º 1
0
        private void OnRecvEquipWeapon(IChannel channel, Message message)
        {
            SEquipWeapon     msg        = message as SEquipWeapon;
            NetworkEntity    player     = networkEntities[msg.playerID];
            PlayerController controller = player.gameObject.GetComponent <PlayerController>();

            if (controller == null)
            {
                return;
            }

            NetworkEntity weapon;

            if (networkEntities.ContainsKey(msg.itemID))
            {
                weapon = networkEntities[msg.itemID];
            }
            else
            {
                GameObject go = CloneGameObject(msg.itemName, msg.itemID);
                weapon = go.GetComponent <NetworkEntity>();
                if (weapon == null)
                {
                    return;
                }
                go.SetActive(false);
                controller.TakeItem(weapon);
            }
            weapon.gameObject.SetActive(false);
            if (!controller.CanAttack)
            {
                weapon.gameObject.SetActive(true);
                controller.EquipWeapon(weapon);
            }
        }
Ejemplo n.º 2
0
        public void SendEquipWeapon(Player player)
        {
            SEquipWeapon msgEquip = new SEquipWeapon();

            msgEquip.playerID = player.entityId;
            msgEquip.itemName = player.m_weapon.name;
            msgEquip.itemID   = player.m_weapon.entityId;
            connection.Send(msgEquip);
        }
Ejemplo n.º 3
0
        public void EquipWeapon(Weapon weapon)
        {
            if (m_weapon != null)
            {
                return;
            }

            m_weapon = weapon;
            SEquipWeapon msgEquip = new SEquipWeapon();

            msgEquip.playerID = this.entityId;
            msgEquip.itemName = this.m_weapon.name;
            msgEquip.itemID   = this.m_weapon.entityId;

            Broadcast(msgEquip);
        }