示例#1
0
        public static void HandleGameRolePlayAttackMonsterRequest(GameRolePlayAttackMonsterRequestMessage message, WorldClient client)
        {
            if (client.Character.Map != null)
            {
                MonsterGroup group = client.Character.Map.Instance.GetEntity <MonsterGroup>((long)message.monsterGroupId);

                if (group != null && client.Character.CellId == group.CellId)
                {
                    if (client.Character.Map.BlueCells.Count >= group.MonsterCount && client.Character.Map.RedCells.Count() >= client.Character.FighterCount)
                    {
                        client.Character.Map.Instance.RemoveEntity(group);

                        FightPvM fight = FightProvider.Instance.CreateFightPvM(group, client.Character.Map, (short)group.CellId);

                        fight.RedTeam.AddFighter(client.Character.CreateFighter(fight.RedTeam));

                        foreach (var fighter in group.CreateFighters(fight.BlueTeam))
                        {
                            fight.BlueTeam.AddFighter(fighter);
                        }

                        fight.StartPlacement();
                    }
                    else
                    {
                        client.Character.ReplyError("Unable to fight on this map");
                    }
                }
                else
                {
                    client.Character.NoMove();
                }
            }
        }
        public static void HandleAttackRequest(GameRolePlayAttackMonsterRequestMessage message, WorldClient client)
        {
            if (client.Character.Map == null)
            {
                return;
            }
            if (client.Character.CancelMonsterAgression)
            {
                client.Character.CancelMonsterAgression = false;
                return;
            }
            if (!client.Character.Map.IsValid())
            {
                client.Character.Reply("Unable to start placement,this map is not valid");
                return;
            }
            var group = client.Character.Map.Instance.GetMapMonsterGroup(message.monsterGroupId);

            if (group != null)
            {
                FightPvM fight = FightProvider.Instance.CreatePvMFight(group, client.Character.Map, (short)group.CellId);

                fight.BlueTeam.AddFighter(client.Character.CreateFighter(fight.BlueTeam));             // on ajoute le perso

                group.Monsters.ForEach(x => fight.RedTeam.AddFighter(x.CreateFighter(fight.RedTeam))); // on ajoute les monstres

                fight.StartPlacement();
            }
            else
            {
                client.Character.NotificationError("Unable to fight, MonsterGroup dosent exist...");
            }
        }