示例#1
0
        public void AppendFight(Character character, int mapId, MonsterRecord[] templates)
        {
            if (Exist(mapId, character))
            {
                throw new Exception(string.Format("Instance on mapId: {0} already exist!", mapId));
            }
            else
            {
                character.Teleport(mapId);

                MapRecord map = MapRecord.GetMap(mapId);

                var newFight = FightProvider.Instance.CreateFreeFightInstancePvM(templates, map);

                FightTeam characterTeam = newFight.GetTeam(TeamTypeEnum.TEAM_TYPE_PLAYER);
                FightTeam monsterTeam   = newFight.GetTeam(TeamTypeEnum.TEAM_TYPE_MONSTER);

                characterTeam.AddFighter(character.CreateFighter(characterTeam));

                foreach (var monster in newFight.Group.CreateFighters(monsterTeam))
                {
                    monsterTeam.AddFighter(monster);
                }

                newFight.FightStartEvt   += newFight_FightStartEvt;
                newFight.OnFightEndedEvt += newFight_OnFightEndedEvt;
                newFight.StartPlacement();

                m_fights.Add(mapId, newFight);
            }
        }
示例#2
0
        public void SetTeam(FightTeam team)
        {
            if (Team != null)
            {
                throw new Exception("Team already defined !");
            }

            Team = team;
            Team.AddFighter(this);
        }
示例#3
0
        public void Join(Character character, int mapId)
        {
            character.Teleport(mapId);
            FightTeam team = m_fights[mapId].GetTeam(TeamTypeEnum.TEAM_TYPE_PLAYER);

            if (team.GetFighter(x => x.Id == character.Id) != null)
            {
                return;
            }
            else
            {
                team.AddFighter(character.CreateFighter(team));
            }
        }
示例#4
0
        public CharacterFighter CreateFighter(FightTeam team)
        {
            Look.UnsetAura();
            RefreshOnMapInstance();
            Map.Instance.RemoveClient(Client);
            Client.Send(new GameContextDestroyMessage());
            Client.Send(new GameContextCreateMessage(2));
            Client.Send(new GameFightStartingMessage((sbyte)team.Fight.FightType, 0, 1));
            var fighter = new CharacterFighter(Client, team);

            FighterInstance = fighter;
            if (EquipedCompanion != null)
            {
                var cfighter = new CompanionFighter(EquipedCompanion, fighter, team);
                team.AddFighter(cfighter);
            }
            return(fighter);
        }
        public async void fight(short monsterId)
        {
            var action = new Action(() => {
                var newFight = FightProvider.Instance.CreateFreeFightInstancePvM(new MonsterRecord[] { MonsterRecord.GetMonster((ushort)monsterId) }, this.Character.Map);

                FightTeam characterTeam = newFight.GetTeam(TeamTypeEnum.TEAM_TYPE_PLAYER);
                FightTeam monsterTeam   = newFight.GetTeam(TeamTypeEnum.TEAM_TYPE_MONSTER);

                characterTeam.AddFighter(this.Character.CreateFighter(characterTeam));

                foreach (var monster in newFight.Group.CreateFighters(monsterTeam))
                {
                    monsterTeam.AddFighter(monster);
                }
            });

            await this.Execute(action);
        }
        public override void Execute(TriggerBase trigger)
        {
            Character target = base.GetTarget(trigger);
            Fight     fight  = trigger.Get <Fight>("fight");
            string    text   = trigger.Get <string>("team");

            if (!text.Equals("blue", System.StringComparison.InvariantCultureIgnoreCase) && !text.Equals("red", System.StringComparison.InvariantCultureIgnoreCase))
            {
                trigger.ReplyError("Specify a team (red or blue)");
            }
            else
            {
                bool flag = text.Equals("red", System.StringComparison.InvariantCultureIgnoreCase);
                if (target.IsFighting())
                {
                    if (target.Fight == fight)
                    {
                        trigger.ReplyError("{0} is already in the given fight", new object[]
                        {
                            target
                        });
                        return;
                    }
                    target.Fighter.LeaveFight();
                }
                FightTeam        fightTeam        = flag ? fight.RedTeam : fight.BlueTeam;
                CharacterFighter characterFighter = target.CreateFighter(fightTeam);
                Cell             cell;
                if (!fight.FindRandomFreeCell(characterFighter, out cell, true))
                {
                    foreach (FightActor current in fightTeam.Fighters)
                    {
                        using (System.Collections.Generic.IEnumerator <MapPoint> enumerator2 = current.Position.Point.GetAdjacentCells((short x) => fight.IsCellFree(fight.Map.Cells[(int)x])).GetEnumerator())
                        {
                            if (enumerator2.MoveNext())
                            {
                                MapPoint current2 = enumerator2.Current;
                                cell = fight.Map.GetCell((int)current2.CellId);
                            }
                        }
                        if (cell != null)
                        {
                            break;
                        }
                    }
                }
                if (cell == null)
                {
                    target.RejoinMap();
                    trigger.ReplyError("{0} cannot join fight {1}, no free cell were found !", new object[]
                    {
                        target,
                        fight.Id
                    });
                }
                else
                {
                    characterFighter.Cell = cell;
                    fightTeam.AddFighter(characterFighter);
                    trigger.ReplyBold("{0} joined fight {1}", new object[]
                    {
                        target,
                        fight.Id
                    });
                }
            }
        }
示例#7
0
        public void SetTeam(FightTeam team)
        {
            if (Team != null)
                throw new Exception("Team already defined !");

            Team = team;
            Team.AddFighter(this);
        }