Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="rawPacket"></param>
        /// <param name="hostId"></param>
        /// <param name="connectionId"></param>
        private void OnPlayerAttackPacket(IPacket rawPacket, int hostId, int connectionId)
        {
            var packet = rawPacket as Client.Packet.PlayerAttackPacket;

            if (packet == null)
            {
                return;
            }

            Debug.Log("Server: Player Attack Packet Received - 1");

            var mob = m_mobs.FirstOrDefault(x => x.ID == packet.MobID);

            if (mob == null)
            {
                return;
            }

            mob.Health -= packet.Damage;

            if (mob.Health > 0)
            {
                var mobDamagePacket = new Server.Packet.MobDamagedPacket(mob.ID, mob.Health);
                QueuePacketAll(mobDamagePacket);
            }
            else
            {
                // It's dead mate
                var mobDeathPacket = new Server.Packet.MobDeathPacket(mob.ID);
                QueuePacketAll(mobDeathPacket);

                m_mobs.Remove(mob);
                var spawner = mob.SpawnArea.GetComponent <Server.SpawnArea>();
                spawner.RequestSpawn();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="rawPacket"></param>
        /// <param name="hostId"></param>
        /// <param name="connectionId"></param>
        private void OnPlayerAttackPacket(IPacket rawPacket, int hostId, int connectionId)
        {
            var packet = rawPacket as Client.Packet.PlayerAttackPacket;
            if (packet == null)
            {
                return;
            }

            Debug.Log("Server: Player Attack Packet Received - 1");

            var mob = m_mobs.FirstOrDefault(x => x.ID == packet.MobID);
            if (mob == null)
            {
                return;
            }

            mob.Health -= packet.Damage;

            if (mob.Health > 0)
            {
                var mobDamagePacket = new Server.Packet.MobDamagedPacket(mob.ID, mob.Health);
                QueuePacketAll(mobDamagePacket);
            }
            else
            {
                // It's dead mate
                var mobDeathPacket = new Server.Packet.MobDeathPacket(mob.ID);
                QueuePacketAll(mobDeathPacket);

                m_mobs.Remove(mob);
                var spawner = mob.SpawnArea.GetComponent<Server.SpawnArea>();
                spawner.RequestSpawn();
            }
        }