Exemple #1
0
        public void SpawnHeroes(ServerRoom room)
        {
            if (!room.SpawnTeam)
            {
                Dictionary <uint, GameObject> gameObjectTable = room.GetGameObjectTable();

                foreach (GameObject obj in gameObjectTable.Values)
                {
                    if (obj is RPGHero)
                    {
                        RPGHero hero        = (RPGHero)obj;
                        Packet  spawnPacket = new Packet(2, hero.ClassID, hero.ID, hero.GetOwner().ClientID, hero.X, hero.Y, hero.Z);
                        spawnPacket.NeedAck = true;

                        Send(spawnPacket, room.Player1.GetEndPoint());
                        Send(spawnPacket, room.Player2.GetEndPoint());
                    }
                    else
                    {
                        continue;
                    }
                }
                room.TeamSpawned();
            }
        }
Exemple #2
0
        private void TurnCreation(byte[] data, EndPoint sender)
        {
            uint       clientId = BitConverter.ToUInt32(data, 1);
            GameClient client   = GetClientFromID(clientId);

            uint       roomId = BitConverter.ToUInt32(data, 5);
            ServerRoom room   = GetRoomFromID(roomId);

            if (!room.GetClientTable().Contains(client))
            {
                client.UpdateMalus();
                return;
            }

            uint heroId = BitConverter.ToUInt32(data, 9);

            if (!room.GetGameObjectTable().ContainsKey(heroId))
            {
                client.UpdateMalus();
                return;
            }

            RPGHero hero = (RPGHero)room.GetGameObjectFromId(heroId);

            room.AddNewTurn(hero);
        }
Exemple #3
0
 public Turn(RPGHero turnOwner)
 {
     attacker  = turnOwner;
     skillID   = -1;
     target    = null;
     turnReady = false;
 }
Exemple #4
0
        private RPGHero SpawnHero(uint roomID)
        {
            RPGHero newHero = new RPGHero(2, this);

            RegisterGameObject(roomID, newHero);
            return(newHero);
        }
Exemple #5
0
        public void TurnSettings(RPGHero attacker, int skillID = -1, RPGHero target = null)
        {
            if (HeroIsRegisted(attacker))
            {
                Turn selectedTurn = GetTurnFromAttacker(attacker);
                selectedTurn.SetTurnParamaters(skillID, target);

                if (target != null)
                {
                    Console.WriteLine("Turn Info: " + attacker.ID, skillID, target.ID);
                }
                else
                {
                    Console.WriteLine("Turn Info: " + attacker.ID, skillID);
                }

                uint targetId = 142;
                if (target != null)
                {
                    targetId = target.ID;
                }

                StartProcessing();
                selectedTurn.Print();
                Room.ProcessingTurn(attacker.ID, skillID, targetId);
            }
        }
Exemple #6
0
 public void AddTurn(RPGHero newAttacker)
 {
     if (!HeroIsRegisted(newAttacker))
     {
         Turn newTurn = new Turn(newAttacker);
         TurnOrder.Add(newTurn);
         PrintTurnOrder();
         Room.CreateTurn(newAttacker.ID);
     }
 }
Exemple #7
0
 public Turn GetTurnFromAttacker(RPGHero attacker)
 {
     foreach (Turn turn in TurnOrder)
     {
         if (turn.Attacker == attacker)
         {
             return(turn);
         }
     }
     return(new Turn(null));
 }
Exemple #8
0
 public bool HeroIsRegisted(RPGHero hero)
 {
     foreach (Turn turn in TurnOrder)
     {
         if (turn.Attacker.ID == hero.ID)
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #9
0
        private void Spawn(byte[] data, EndPoint sender)
        {
            //2[0], myIdOnServer[1], serverRoomId[5], classIndex[9], x[13], y[17], z[21]
            uint       clientId = BitConverter.ToUInt32(data, 1);
            GameClient client   = GetClientFromID(clientId);

            uint       roomId = BitConverter.ToUInt32(data, 5);
            ServerRoom room   = GetRoomFromID(roomId);

            if (!room.GetClientTable().Contains(client))
            {
                client.UpdateMalus();
                return;
            }

            RPGHero newHero = SpawnHero(roomId);

            newHero.SetOwner(client);

            uint classId = BitConverter.ToUInt32(data, 9);

            newHero.SetInGameValues(classId, "");
            float x = BitConverter.ToSingle(data, 13);
            float y = BitConverter.ToSingle(data, 17);
            float z = BitConverter.ToSingle(data, 21);

            newHero.SetPosition(x, y, z);

            //byte[] name = new byte[12];
            //for (int i = 0; i < name.Length; i++)
            //{
            //    name[i] = data[25 + i];
            //}
            //string heroName = System.Text.Encoding.UTF8.GetString(name);
            //Console.WriteLine(heroName);

            Console.WriteLine("Spaned Object {0}", room.GetGameObjectTable().Count);
        }
Exemple #10
0
        private void SetTurnParameter(byte[] data, EndPoint sender)
        {
            uint       clientId = BitConverter.ToUInt32(data, 1);
            GameClient client   = GetClientFromID(clientId);

            uint       roomId = BitConverter.ToUInt32(data, 5);
            ServerRoom room   = GetRoomFromID(roomId);

            if (!room.GetClientTable().Contains(client))
            {
                client.UpdateMalus();
                return;
            }

            uint heroId = BitConverter.ToUInt32(data, 9);

            if (!room.GetGameObjectTable().ContainsKey(heroId))
            {
                client.UpdateMalus();
                return;
            }

            RPGHero hero = (RPGHero)room.GetGameObjectFromId(heroId);

            int     skillId  = BitConverter.ToInt32(data, 13);
            uint    targetId = BitConverter.ToUInt32(data, 17);
            RPGHero target   = null;

            if (targetId != 172)
            {
                target = (RPGHero)room.GetGameObjectFromId(targetId);
            }

            Console.WriteLine("Attacker : {0}, skill: {1}, Target: {2}", hero.ID, skillId, targetId);
            room.SetTurnParameters(hero, skillId, target);
        }
Exemple #11
0
 public void SetTurnParamaters(int skillID = -1, RPGHero target = null)
 {
     this.skillID = skillID;
     this.target  = target;
     turnReady    = true;
 }
Exemple #12
0
 public void SetTurnParameters(RPGHero attacker, int skill = -1, RPGHero target = null)
 {
     gameLogic.TurnSettings(attacker, skill, target);
 }
Exemple #13
0
 public void AddNewTurn(RPGHero attacker)
 {
     gameLogic.AddTurn(attacker);
 }