Inheritance: AgentAction
Ejemplo n.º 1
0
 public PlayedFighter(PlayedCharacter character, Fight fight)
     : base(fight)
 {
     Character = character;
     Map = character.Map;
     Cell = character.Cell;
     Direction = character.Direction;
 }
Ejemplo n.º 2
0
        public void ShowFight()
        {
            var firstFighter = new Fighter("Rolandas", new FlagGameAI());
            var secondFighter = new Fighter("Jonas", new JonoAi());

            var fight = new Fight(firstFighter, secondFighter, new FightRulesGenerator().Generate());

            fight.GetWinner(true);
        }
Ejemplo n.º 3
0
        public PlayedFighter(PlayedCharacter character, Fight fight)
            : base(fight)
        {
            Character = character;
            Fight = fight;

            if (character.Position != null)
                Position = character.Position.Clone();
        }
Ejemplo n.º 4
0
 public PlayedFighter(PlayedCharacter character, Fight fight)
     : base(fight)
 {
     Character = character;
     Map = character.Map;
     Cell = character.Cell;
     Direction = character.Direction;
     CanFight = true;
     CanCastSpells = true;
 }
Ejemplo n.º 5
0
 public CharacterFighter(GameFightCharacterInformations msg, Map map, Fight fight)
 {
     Id = msg.contextualId;
     Fight = fight;
     Look = msg.look;
     Position = new ObjectPosition(map, msg.disposition);
     Team = fight.GetTeam((FightTeamColor) msg.teamId);
     IsAlive = msg.alive;
     Alignment = new AlignmentInformations(msg.alignmentInfos);
     Breed = DataProvider.Instance.Get<Breed>(msg.breed);
 }
Ejemplo n.º 6
0
 public MonsterFighter(GameFightMonsterInformations msg, Map map, Fight fight)
 {
     Id = msg.contextualId;
     Fight = fight;
     Look = msg.look;
     Position = new ObjectPosition(map, msg.disposition);
     Team = fight.GetTeam((FightTeamColor) msg.teamId);
     IsAlive = msg.alive;
     MonsterTemplate = DataProvider.Instance.Get<Monster>(msg.creatureGenericId);
     MonsterGrade = MonsterTemplate.grades[msg.creatureGrade];
 }
Ejemplo n.º 7
0
    public void FightComplete(Fight.Outcome outcome)
    {
        if (outcome == Fight.Outcome.Draw)
            Say ("Draw!",3);
        else if (outcome == Fight.Outcome.Dog1Won)
            Say ("Dog 1 won!",3);
        else if (outcome == Fight.Outcome.Dog2Won)
            Say ("Dog 2 won!",3);

        Invoke("MainMenu",3);
    }
Ejemplo n.º 8
0
 public MonsterFighter(GameFightMonsterInformations msg, Fight fight)
 {
     Id = msg.contextualId;
     Fight = fight;
     Look = msg.look;
     Map = fight.Map;
     Update(msg.disposition);
     Team = fight.GetTeam((FightTeamColor) msg.teamId);
     IsAlive = msg.alive;
     MonsterTemplate = DataProvider.Instance.Get<Monster>(msg.creatureGenericId);
     MonsterGrade = MonsterTemplate.grades[msg.creatureGrade - 1];
     Stats = new MinimalStats(msg.stats);
 }
Ejemplo n.º 9
0
 public CharacterFighter(GameFightCharacterInformations msg, Fight fight)
 {
     Id = msg.contextualId;
     Fight = fight;
     Look = msg.look;
     Map = fight.Map;
     Update(msg.disposition);
     Team = fight.GetTeam((FightTeamColor) msg.teamId);
     IsAlive = msg.alive;
     Alignment = new AlignmentInformations(msg.alignmentInfos);
     Breed = DataProvider.Instance.Get<Breed>(msg.breed);
     Stats = new MinimalStats(msg.stats);
 }
Ejemplo n.º 10
0
        public SpellCast(Fight fight, GameActionFightSpellCastMessage msg)
        {
            Caster = fight.GetFighter(msg.sourceId);

            if (Caster == null)
                logger.Error("Fighter {0} not found as he casted spell {1}", msg.sourceId, msg.spellId);

            Spell = DataProvider.Instance.Get<Spell>(msg.spellId);
            SpellLevel = DataProvider.Instance.Get<SpellLevel>((int)Spell.spellLevels[msg.spellLevel - 1]);
            Target = fight.Map.Cells[msg.destinationCellId];
            RoundCast = fight.Round;
            Critical = (FightSpellCastCriticalEnum) msg.critical;
            SilentCast = msg.silentCast;
            TargetedFighter = fight.GetFighter(msg.targetId);
        }
Ejemplo n.º 11
0
        List<string> verbs; // Different fighting verbs

        #endregion Fields

        #region Methods

        // Function for Feint button - Doubles opponent attack, chance at double damage
        public void Feint()
        {
            if (playerTurn)
            {
                // Battle characters
                Fight fighter = new Fight ();
                damage = fighter.CharacterFightFeint<Bandit> (playerMerchant, playerTurn, die);
                enemyEntity.AttackPower *= 2;
                GameObject.Find ("Battler2Attack").GetComponent<Text> ().text = enemyEntity.AttackPower.ToString ();

                // Generate fight box verb
                randomVerb = "feinted at";

                // Process fight
                Invoke ("Fight", 0.0f);
            } //end if
        }
Ejemplo n.º 12
0
    public Fighter(GameFightFighterInformations msg, Fight fight) : this()
        {
            Id = msg.contextualId;
            Fight = fight;
            Look = msg.look;
            Map = fight.Map;
            Update(msg.disposition);
            Team = fight.GetTeam((FightTeamColor) msg.teamId);
            IsAlive = msg.alive;
            Stats = new MinimalStats(msg.stats);
            Summoned = msg.stats.summoned;
            if (Summoned)
            {
                Summoner = Fight.GetActor(msg.stats.summoner);

                if (Summoner == null)
                    logger.Error("Summoner {0} of fighter {1} not found", msg.stats.summoner, this);
            }
        }
Ejemplo n.º 13
0
        public static bool AddFight(byte zoneid, int x, int y, byte realm1, byte realm2)
        {
            if (!ServerProperties.Properties.ENABLE_WARMAPMGR)
                return false;

            Zone zone = WorldMgr.GetZone(zoneid);
            if (zone == null) return false;
            long time = NFTime;
            Fight fight = new Fight();
            fight.Zone = zoneid;
            fight.X = (byte)((x - zone.XOffset) >> 14);
            fight.Y = (byte)((y - zone.YOffset) >> 14);
            fight.Realm1 = realm1;
            fight.Realm2 = realm2;
            lock (m_fights)
            {
                while (m_fights.ContainsKey(time)) time++;
                m_fights.Add(time, fight);
            }
            return true;
        }
Ejemplo n.º 14
0
    void InitializeFight()
    {
        if (managerReference.ActiveTeam == null)
        {
            yourTeam = managerReference.SelectTeam();
        }
        else
        {
            yourTeam = managerReference.ActiveTeam;
        }

        FighterTeam AlphaTeam = yourTeam;
        yourTeam.Info.TeamName = "Alpha Team";

        FighterTeamInfo betaInfo = new FighterTeamInfo(true);
        FighterTeam BetaTeam = new FighterTeam(betaInfo);
        betaInfo.TeamName = "Beta Team";

        Fight = new Fight(AlphaTeam, BetaTeam);

        StartCoroutine(Fight.Run());
    }
Ejemplo n.º 15
0
        public void StartFightTournament()
        {
            var secondFighter = new Fighter("Rolandas", new FlagGameAI());
            var firstFighter = new Fighter("Jonas", new JonoAi());

            var generator = new FightRulesGenerator();

            const int fightCouplesCount = 100;

            var fights = new List<Fight>();

            for (var i = 0; i < fightCouplesCount; i++)
            {
                var rules = generator.Generate();
                var fight1 = new Fight(firstFighter, secondFighter, rules);
                var fight2 = new Fight(secondFighter, firstFighter, rules);

                fights.Add(fight1);
                fights.Add(fight2);
            }

            var winners = new List<Fighter>();

            foreach (var fight in fights)
            {
                try
                {
                    winners.Add(fight.GetWinner());
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Console.WriteLine(fight.ToString());
                }
            }

            Console.WriteLine("{0} won {1} fights.", firstFighter.Author, winners.Count(w => w == firstFighter));
            Console.WriteLine("{0} won {1} fights.", secondFighter.Author, winners.Count(w => w == secondFighter));
        }
Ejemplo n.º 16
0
 public void RemoveFight(Fight fight)
 {
     this.Fights.Remove(fight);
 }
Ejemplo n.º 17
0
        public override bool CastSpell(SpellCastInformations cast)
        {
            if (!IsFighterTurn() && !cast.Force)
            {
                return(false);
            }

            // not a weapon attack
            if (cast.Spell.Id != 0 || Character.Inventory.TryGetItem(CharacterInventoryPositionEnum.ACCESSORY_POSITION_WEAPON) == null)
            {
                return(base.CastSpell(cast));
            }

            var weapon = Character.Inventory.TryGetItem(CharacterInventoryPositionEnum.ACCESSORY_POSITION_WEAPON);

            if (!(weapon.Template is WeaponTemplate weaponTemplate) || !CanUseWeapon(cast.TargetedCell, weaponTemplate))
            {
                OnSpellCastFailed(cast);
                return(false);
            }

            using (Fight.StartSequence(SequenceTypeEnum.SEQUENCE_WEAPON))
            {
                var random   = new AsyncRandom();
                var critical = RollCriticalDice(weaponTemplate);

                switch (critical)
                {
                case FightSpellCastCriticalEnum.CRITICAL_FAIL:
                    OnWeaponUsed(weaponTemplate, cast.TargetedCell, critical, false);

                    if (!cast.ApFree)
                    {
                        UseAP((short)weaponTemplate.ApCost);
                    }

                    PassTurn();

                    return(false);

                case FightSpellCastCriticalEnum.CRITICAL_HIT:
                    m_criticalWeaponBonus = weaponTemplate.CriticalHitBonus;
                    break;
                }

                m_isUsingWeapon = true;
                var effects =
                    weapon.Effects.Where(entry => EffectManager.Instance.IsUnRandomableWeaponEffect(entry.EffectId)).OfType <EffectDice>();
                var handlers = new List <SpellEffectHandler>();
                foreach (var effect in effects)
                {
                    if (effect.Random > 0)
                    {
                        if (random.NextDouble() > effect.Random / 100d)
                        {
                            // effect ignored
                            continue;
                        }
                    }

                    var handler = EffectManager.Instance.GetSpellEffectHandler(effect, this, new DefaultSpellCastHandler(cast), cast.TargetedCell,
                                                                               critical == FightSpellCastCriticalEnum.CRITICAL_HIT);

                    handler.EffectZone = new Zone(weaponTemplate.Type.ZoneShape, (byte)weaponTemplate.Type.ZoneSize, (byte)weaponTemplate.Type.ZoneMinSize,
                                                  handler.CastPoint.OrientationTo(handler.TargetedPoint), (int)weaponTemplate.Type.ZoneEfficiencyPercent, (int)weaponTemplate.Type.ZoneMaxEfficiency);

                    handler.Targets = new TargetCriterion[]
                    { new TargetTypeCriterion(SpellTargetType.ALLY_ALL_EXCEPT_SELF, false), new TargetTypeCriterion(SpellTargetType.ENEMY_ALL, false) };     // everyone but caster

                    handlers.Add(handler);
                }

                var silentCast = handlers.Any(entry => entry.RequireSilentCast());

                OnWeaponUsed(weaponTemplate, cast.TargetedCell, critical, silentCast);

                if (!cast.ApFree)
                {
                    UseAP((short)weaponTemplate.ApCost);
                }

                foreach (var handler in handlers)
                {
                    handler.Apply();
                }
            }

            m_isUsingWeapon       = false;
            m_criticalWeaponBonus = 0;

            // is it the right place to do that ?
            Fight.CheckFightEnd();

            return(true);
        }
Ejemplo n.º 18
0
 public SummonedFighter(GameFightMonsterInformations msg, Map map, Fight fight)
     : base(msg, map, fight)
 {
 }
Ejemplo n.º 19
0
 public MonsterFighter(GameFightMonsterInformations msg, Fight fight) : base (msg, fight)
 {
     MonsterTemplate = ObjectDataManager.Instance.Get<Monster>(msg.creatureGenericId);
     MonsterGrade = MonsterTemplate.grades[msg.creatureGrade - 1];
     Level = (int) MonsterGrade.level;        
 }
Ejemplo n.º 20
0
 public FightScreen(Fight fight, GameLog gameLog, Character player)
 {
     Fight    = fight;
     _gameLog = gameLog;
     _player  = player;
 }
Ejemplo n.º 21
0
 private void OnFightLeft(Fight fight)
 {
     var evnt = FightLeft;
     if (evnt != null)
         evnt(this, fight);
 }
Ejemplo n.º 22
0
 public NomadeChallenge(Fight fight, FightTeam team)
     : base(fight, team, Enums.ChallengesTypeID.Nomade)
 {
 }
Ejemplo n.º 23
0
 public FightSpectator(Character character, Fight fight)
 {
     this.Character = character;
     this.Fight     = fight;
 }
 public FigthCellsInformationProvider(Fight fight)
 {
     this.Fight = fight;
 }
Ejemplo n.º 25
0
        protected override void Seed(GameDbContext context)
        {
            var itemAxe = new Item
            {
                Id       = _guid1,
                Name     = "Sekera",
                Attack   = 20,
                Defense  = 5,
                Weight   = 12,
                ItemType = ItemType.Weapon,
                Equipped = true
            };

            var itemAxe2 = new Item
            {
                Id       = _guid2,
                Name     = "Lepsia Sekera",
                Attack   = 25,
                Defense  = 10,
                Weight   = 8,
                ItemType = ItemType.Weapon
            };

            var itemBow = new Item
            {
                Id       = _guid3,
                Name     = "Luk",
                Attack   = 44,
                Defense  = 3,
                Weight   = 3,
                ItemType = ItemType.Weapon,
                Equipped = true
            };

            Character characterSlayer = new Character
            {
                Name         = "KingSlayer",
                Money        = 666,
                Health       = 98,
                Score        = 12,
                Strength     = 5,
                Perception   = 8,
                Endurance    = 2,
                Charisma     = 8,
                Intelligence = 1,
                Agility      = 5,
                Luck         = 9
            };

            characterSlayer.Items = new List <Item>
            {
                itemAxe
            };

            Character Ch = new Character
            {
                Name         = "BelaKing",
                Money        = 666,
                Health       = 98,
                Score        = 12,
                Strength     = 5,
                Perception   = 8,
                Endurance    = 2,
                Charisma     = 8,
                Intelligence = 1,
                Agility      = 5,
                Luck         = 9
            };

            Ch.Items = new List <Item>
            {
                itemAxe2
            };

            var characterWalker = new Character
            {
                Name         = "White Walker",
                Money        = 1200,
                Health       = 50,
                Score        = 89,
                Strength     = 9,
                Perception   = 2,
                Endurance    = 5,
                Charisma     = 1,
                Intelligence = 2,
                Agility      = 6,
                Luck         = 4
            };

            characterWalker.Items = new List <Item>
            {
                itemBow
            };

            var     pass1        = CreateHash("12345678");
            Account accountPeter = new Account
            {
                Id           = _guid7,
                Username     = "******",
                Email        = "*****@*****.**",
                PasswordHash = pass1.Item1,
                PasswordSalt = pass1.Item2,
                Roles        = "Admin,HasCharacter",
                Character    = Ch,
            };

            var pass2       = CreateHash("IvanJeBoh");
            var accountIvan = new Account
            {
                Id           = _guid8,
                Username     = "******",
                Email        = "*****@*****.**",
                PasswordHash = pass2.Item1,
                PasswordSalt = pass2.Item2,
                Roles        = ",HasCharacter",
                Character    = characterSlayer
            };

            var pass3        = CreateHash("QWE123975");
            var accountVedro = new Account
            {
                Id           = _guid9,
                Username     = "******",
                Email        = "*****@*****.**",
                PasswordHash = pass3.Item1,
                PasswordSalt = pass3.Item2,
                Roles        = ",HasCharacter",
                Character    = characterWalker
            };

            var group1 = new Group
            {
                Id          = _guid10,
                Name        = "Prva skupina",
                Description = "Toto je prva a posledna skupina!",
                Picture     = "/Img/img1.jpg"
            };

            group1.Members = new List <Character>
            {
                characterSlayer,
                characterWalker
            };

            var fight1 = new Fight
            {
                Id             = _guid11,
                Attacker       = characterSlayer,
                Defender       = characterWalker,
                AttackerWeapon = itemAxe,
                DefenderWeapon = itemBow,
                Timestamp      = DateTime.Now,
                AttackSuccess  = true
            };

            var gpost = new GroupPost
            {
                Id        = _guid12,
                Author    = characterSlayer,
                Group     = group1,
                Text      = "Hi",
                Timestamp = DateTime.Now
            };

            var chat = new Chat
            {
                Id       = _guid13,
                Receiver = characterSlayer,
                Sender   = characterWalker,
                Subject  = "Destruction",
            };

            var message1 = new Message
            {
                Id        = _guid14,
                Author    = characterSlayer,
                Chat      = chat,
                Text      = "This is war",
                Timestamp = DateTime.Now,
            };

            var message2 = new Message
            {
                Id        = _guid15,
                Author    = characterWalker,
                Chat      = chat,
                Text      = "ok",
                Timestamp = DateTime.Now,
            };

            context.Items.Add(itemAxe);
            context.Items.Add(itemAxe2);
            context.Items.Add(itemBow);

            context.Characters.Add(characterSlayer);
            context.Characters.Add(characterWalker);
            context.Characters.Add(Ch);

            context.Accounts.Add(accountPeter);
            context.Accounts.Add(accountIvan);
            context.Accounts.Add(accountVedro);

            context.Messages.Add(message1);
            context.Messages.Add(message2);

            context.Fights.Add(fight1);

            context.Groups.Add(group1);

            context.GroupPosts.Add(gpost);

            base.Seed(context);
        }
Ejemplo n.º 26
0
        private static void OnTurnStarted(Fight fight, Fighter fighter)
        {
            var bot = BotManager.Instance.GetCurrentBot();

            bot.Character.SendMessage(string.Format("This is '{0}' turn.", fighter.Name), Color.Violet);
        }
Ejemplo n.º 27
0
 private static void OnFightLeft(PlayedCharacter character, Fight fight)
 {
     character.Fight.TurnStarted -= OnTurnStarted;
 }
Ejemplo n.º 28
0
 private static void OnFightJoined(PlayedCharacter character, Fight fight)
 {
     character.Fight.TurnStarted += OnTurnStarted;
 }
Ejemplo n.º 29
0
 private static Dictionary <int, FightPointModel.RoundPointsModel> GetRoundPointsDictionary(Fight fight, IGrouping <string, FightPoint> groupedPoints)
 {
     return(groupedPoints.OrderBy(r => r.RoundId).GroupBy(r => r.RoundId).Select(r =>
                                                                                 new FightPointModel.RoundPointsModel
     {
         RoundId = r.Key,
         RedFighterPoints = r.Where(f => f.FighterId == fight.RedAthleteId).Select(fp =>
                                                                                   new FightPointModel.PointsModel
         {
             Accepted = fp.Accepted,
             Cautions = fp.Cautions,
             FighterPoints = fp.Points,
             Injury = fp.Injury,
             InjuryTime = fp.InjuryTime,
             J = fp.J,
             KnockDown = fp.KnockDown,
             Warnings = fp.Warnings,
             X = fp.X
         }).FirstOrDefault(),
         BlueFighterPoints = r.Where(f => f.FighterId == fight.BlueAthleteId).Select(fp =>
                                                                                     new FightPointModel.PointsModel
         {
             Accepted = fp.Accepted,
             Cautions = fp.Cautions,
             FighterPoints = fp.Points,
             Injury = fp.Injury,
             InjuryTime = fp.InjuryTime,
             J = fp.J,
             KnockDown = fp.KnockDown,
             Warnings = fp.Warnings,
             X = fp.X
         }).FirstOrDefault(),
     }).ToDictionary(t => t.RoundId, t => t));
 }
Ejemplo n.º 30
0
        private static List <FightPointModel.RoundPointsModel> ConvertToRoundPointsModels(Fight fight, IGrouping <string, FightPoint> groupedPoints)
        {
            var roundPointsList = new List <FightPointModel.RoundPointsModel>();

            var roundPointsDictionary = GetRoundPointsDictionary(fight, groupedPoints);

            for (var i = 1; i <= fight.Structure.Round.RoundsCount; i++)
            {
                var points = roundPointsDictionary.ContainsKey(i) ? roundPointsDictionary[i] : GetEmptyRoundPoints(i);
                roundPointsList.Add(points);
            }
            return(roundPointsList);
        }
Ejemplo n.º 31
0
        public (FightOutcome outcome, List <FightStats> Stats) SimulateFightWithDetails(Fight fight)
        {
            FightState liveFight = new FightState(fight);

            liveFight.SimulateFight();

            return(liveFight.Outcome, liveFight.FightStats);
        }
Ejemplo n.º 32
0
        public static Couple <List <FightCell>, List <FightCell> > GenRandomFightPlaces(Fight fight)
        {
            List <FightCell> team1 = new List <FightCell>();
            List <FightCell> team2 = new List <FightCell>();

            /*
             * BaseCells
             */
            Couple <int, int> baseCells = GetRandomBaseCellPlaces(fight.Map);

            team1.Add(fight.GetCell(baseCells.first));
            team2.Add(fight.GetCell(baseCells.second));

            /*
             * Remplissage
             */
            int boucles = 0;

            while (team1.Count < 8)
            {
                if (boucles > 500)
                {
                    break;
                }
                if (boucles > 25)
                {
                    int       randomCellId = fight.Map.getRandomCell();
                    FightCell cell         = fight.GetCell(randomCellId);
                    if (cell != null && cell.IsWalkable())
                    {
                        if (!team1.Contains(cell))
                        {
                            team1.Add(cell);
                        }
                    }
                    boucles++;
                    continue;
                }
                boucles++;
                FightCell toDir = team1[Random(0, team1.Count - 1)];
                if (toDir == null)
                {
                    continue;
                }
                FightCell randomCell = fight.GetCell(Pathfinder.DirToCellID(toDir.Id, RandomDirection(), fight.Map, false));
                if (randomCell != null)
                {
                    if (!team1.Contains(randomCell) && randomCell.IsWalkable())
                    {
                        team1.Add(randomCell);
                    }
                }
            }

            boucles = 0;
            while (team2.Count < 8)
            {
                if (boucles > 500)
                {
                    break;
                }
                if (boucles > 25)
                {
                    int       randomCellId = fight.Map.getRandomCell();
                    FightCell cell         = fight.GetCell(randomCellId);
                    if (cell != null && cell.IsWalkable())
                    {
                        if (!team1.Contains(cell) && !team2.Contains(cell))
                        {
                            team2.Add(cell);
                        }
                    }
                    boucles++;
                    continue;
                }
                boucles++;
                FightCell toDir = team2[Random(0, team2.Count - 1)];
                if (toDir == null)
                {
                    continue;
                }
                FightCell randomCell = fight.GetCell(Pathfinder.DirToCellID(toDir.Id, RandomDirection(), fight.Map, false));
                if (randomCell != null)
                {
                    if (!team1.Contains(randomCell) && !team2.Contains(randomCell) && randomCell.IsWalkable())
                    {
                        team2.Add(randomCell);
                    }
                }
            }

            return(new Couple <List <FightCell>, List <FightCell> >(team1, team2));
        }
Ejemplo n.º 33
0
 public GameFight(Fighter Fighter, Fight Fight)
     : base(GameActionTypeEnum.FIGHT, Fighter)
 {
     this.Fight = Fight;
 }
Ejemplo n.º 34
0
        /// <summary>
        /// </summary>
        /// <param name="eventType"> </param>
        /// <param name="eventArgs"> </param>
        public void PublishTimelineEvent(TimelineEventType eventType, params object[] eventArgs)
        {
            var args = (eventArgs != null && eventArgs.Any()) ? eventArgs[0] : "(no args)";

            Logging.Log(Logger, String.Format("TimelineEvent : {0} {1}", eventType, args));
            if (eventArgs != null)
            {
                var monsterName = eventArgs.First() as String;
                switch (eventType)
                {
                case TimelineEventType.PartyJoin:
                case TimelineEventType.PartyDisband:
                case TimelineEventType.PartyLeave:
                    break;

                case TimelineEventType.PartyMonsterFighting:
                case TimelineEventType.AllianceMonsterFighting:
                case TimelineEventType.OtherMonsterFighting:
                    DeathFound = false;
                    if (monsterName != null && (monsterName.ToLower()
                                                .Contains("target") || monsterName == ""))
                    {
                        break;
                    }
                    Fight fighting;
                    if (!Fights.TryGet(monsterName, out fighting))
                    {
                        fighting = new Fight(monsterName);
                        Fights.Add(fighting);
                    }
                    Controller.Timeline.LastEngaged = monsterName;
                    break;

                case TimelineEventType.PartyMonsterKilled:
                case TimelineEventType.AllianceMonsterKilled:
                case TimelineEventType.OtherMonsterKilled:
                    DeathFound = true;
                    if (monsterName != null && (monsterName.ToLower()
                                                .Contains("target") || monsterName == ""))
                    {
                        break;
                    }
                    Fight killed;
                    if (!Fights.TryGet(monsterName, out killed))
                    {
                        killed = new Fight(monsterName);
                        Fights.Add(killed);
                    }
                    switch (eventType)
                    {
                    case TimelineEventType.PartyMonsterKilled:
                        GetSetMonster(monsterName)
                        .SetKill(killed);
                        break;

                    case TimelineEventType.AllianceMonsterKilled:
                        GetSetMonster(monsterName)
                        .SetKill(killed);
                        break;

                    case TimelineEventType.OtherMonsterKilled:
                        GetSetMonster(monsterName)
                        .SetKill(killed);
                        break;
                    }
                    Controller.Timeline.LastKilled = monsterName;
                    break;
                }
            }
            RaiseTimelineChangedEvent(this, new TimelineChangedEvent(eventType, eventArgs));
        }
Ejemplo n.º 35
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="mono"></param>
 public FightFinish(MonoBehaviour mono, string procName)
     : base(mono, procName)
 {
     fight = mono as Fight;
 }
Ejemplo n.º 36
0
 public MarkShape(Fight fight, MapPoint point, Color color)
 {
     this.Fight = fight;
     this.Point = point;
     this.Color = color;
 }
Ejemplo n.º 37
0
 public void Start(Fight fight)
 {
     fight.Send(new SequenceStartMessage(SequenceType, SourceId));
     this.Started = true;
 }
Ejemplo n.º 38
0
 public void Destroy()
 {
     FirstBomb.Walls.Remove(this);
     SecondBomb.Walls.Remove(this);
     Fight.RemoveMark(FirstBomb, this);
 }
Ejemplo n.º 39
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="mono"></param>
 public FightWarning(MonoBehaviour mono, string procName)
     : base(mono, procName)
 {
     fight = mono as Fight;
 }
Ejemplo n.º 40
0
 public CFViewModel()
 {
     fight = new Fight();
     User  = new User();
     Bet   = new Dictionary <string, int>();
 }
Ejemplo n.º 41
0
 /// <summary>
 /// </summary>
 /// <param name="eventType"> </param>
 /// <param name="eventArgs"> </param>
 public void PublishTimelineEvent(TimelineEventType eventType, params object[] eventArgs)
 {
     var args = (eventArgs != null && eventArgs.Any()) ? eventArgs[0] : "(no args)";
     Logging.Log(Logger, String.Format("TimelineEvent : {0} {1}", eventType, args));
     if (eventArgs != null)
     {
         var monsterName = eventArgs.First() as String;
         switch (eventType)
         {
             case TimelineEventType.PartyJoin:
             case TimelineEventType.PartyDisband:
             case TimelineEventType.PartyLeave:
                 break;
             case TimelineEventType.PartyMonsterFighting:
             case TimelineEventType.AllianceMonsterFighting:
             case TimelineEventType.OtherMonsterFighting:
                 DeathFound = false;
                 if (monsterName != null && (monsterName.ToLower()
                                                        .Contains("target") || monsterName == ""))
                 {
                     break;
                 }
                 Fight fighting;
                 if (!Fights.TryGet(monsterName, out fighting))
                 {
                     fighting = new Fight(monsterName);
                     Fights.Add(fighting);
                 }
                 Controller.Timeline.LastEngaged = monsterName;
                 break;
             case TimelineEventType.PartyMonsterKilled:
             case TimelineEventType.AllianceMonsterKilled:
             case TimelineEventType.OtherMonsterKilled:
                 DeathFound = true;
                 if (monsterName != null && (monsterName.ToLower()
                                                        .Contains("target") || monsterName == ""))
                 {
                     break;
                 }
                 Fight killed;
                 if (!Fights.TryGet(monsterName, out killed))
                 {
                     killed = new Fight(monsterName);
                     Fights.Add(killed);
                 }
                 switch (eventType)
                 {
                     case TimelineEventType.PartyMonsterKilled:
                         GetSetMonster(monsterName)
                             .SetKill(killed);
                         break;
                     case TimelineEventType.AllianceMonsterKilled:
                         GetSetMonster(monsterName)
                             .SetKill(killed);
                         break;
                     case TimelineEventType.OtherMonsterKilled:
                         GetSetMonster(monsterName)
                             .SetKill(killed);
                         break;
                 }
                 Controller.Timeline.LastKilled = monsterName;
                 break;
         }
     }
     RaiseTimelineChangedEvent(this, new TimelineChangedEvent(eventType, eventArgs));
 }
Ejemplo n.º 42
0
        // Function for Torso button - Regular damage
        public void Torso()
        {
            if (playerTurn)
            {
                // Battle characters
                Fight fighter = new Fight ();
                damage = fighter.CharacterFightTorso<Bandit> (playerMerchant, playerTurn, die);

                // Generate fight box verb
                randomVerb = verbs [Random.Range (0, verbs.Count)];

                // Process fight
                Invoke ("Fight", 0.0f);
            } //end if
        }
Ejemplo n.º 43
0
 protected CharacterFighter(Fight fight)
 {
     Fight = fight;
 }
Ejemplo n.º 44
0
        static public void GetRandomEvent()
        {
            Fancies();

            Monster test = new Monster();

            Console.WriteLine("\nИгрок:" +
                              $"\nHP: {HP}/{MaxHP} [{HPLine}]");

            if (LVL != 15)
            {
                Console.WriteLine($"УР {LVL}: {XP}/{MaxXP} [{XPLine}]");
            }
            else
            {
                Dialogue($"LVL {LVL}: {XP}/{MaxXP} [{XPLine}] " +
                         $"\nОчки мастерства: {MasteryPoints}", true, ConsoleColor.Yellow);
            }

            Console.WriteLine($"Деньги: {Player.Money}");

            Console.WriteLine("\nЛес - 1, Задание - 2, Город - 3");
            if (towerLoc)
            {
                Console.WriteLine("Заброшенная башня - 9");
            }
            Console.WriteLine("Сохранить игру - s, Загрузить игру - l, Достижения - a, Инвентарь - i");

            switch (Console.ReadLine())
            {
            case "1":

                Console.Clear();
                int Event = rnd.Next(0, 10);

                if (Event < 5)
                {
                    Console.WriteLine("Тут ничего");
                }
                else if (Event == 5)
                {
                    Money         = rnd.Next(0, 10) + 2 * LVL;
                    Player.Money += Money;
                    Dialogue("Ого, сундук" +
                             "\nВы получили " + Money + " монет", true, ConsoleColor.Yellow);
                }
                else
                {
                    Fight.Init();
                }
                break;

            case "2":

                Console.Clear();

                if (City.currentPlotState == City.QuestState.Accepted)
                {
                    Console.WriteLine("Доступно сюжетное задание.");

                    switch (questNum)
                    {
                    case 1:
                        Console.WriteLine("Рекомендуемый уровень: 4");
                        break;

                    case 2:
                        Console.WriteLine("Рекомендуемый уровень: 7");
                        break;

                    case 3:
                        Console.WriteLine("Рекомендуемый уровень: 8");
                        break;
                    }

                    Console.WriteLine("Вы хотите начать это задание? Да - 1, Нет - 2");

                    if (Console.ReadLine() == "1")
                    {
                        PlotQuests.Quest();
                    }
                }

                else
                {
                    Console.WriteLine("Нет доступных заданий.");
                }
                break;

            case "3":
                City.GoToCity();
                break;

            case "4":
                Dungeons.Init(0);
                Console.Clear();
                break;

            case "9":
                if (towerLoc)
                {
                    Tower.Entry();
                    Console.Clear();
                }
                else
                {
                    goto default;
                }
                break;

            case "a":
                AchievementMenu.ShowList();
                Console.Clear();
                break;

            case "i":
                InventoryMenu.ShowMenu();
                break;

            case "l":
                LoadProgress(false);
                Console.Clear();
                break;

            case "s":
                SaveProgress(true);
                Console.Clear();
                break;

            case "fight poison":
                test.Type = Monster.MType.Poisonous;
                goto case "fight";

            case "fight explosive":
                test.Type = Monster.MType.Explosive;
                goto case "fight";

            case "fight thorned":
                test.Type = Monster.MType.Thorned;
                goto case "fight";

            case "fight fire":
                test.Type = Monster.MType.Fire;
                goto case "fight";

            case "fight ice":
                test.Type = Monster.MType.Ice;
                goto case "fight";

            case "fight dark":
                test.Type = Monster.MType.Dark;
                goto case "fight";

            case "fight light":
                test.Type = Monster.MType.Luminous;
                goto case "fight";

            case "fight":
                test.HP     = 262260;
                test.Damage = 0;
                test.Name   = "тестовый монстр-босс";
                Fight.Init(new Monster[1] {
                    test
                }, true);
                break;

            case "fight 2":
                Fight.Init(2);
                break;

            case "bring balance":
                for (int i = 0; i < Passive_Inventory.Length; i++)
                {
                    if (Passive_Inventory[i].ID == 0)
                    {
                        Passive_Inventory[i] = new Yang_W();
                        break;
                    }
                }
                for (int i = 0; i < Passive_Inventory.Length; i++)
                {
                    if (Passive_Inventory[i].ID == 0)
                    {
                        Passive_Inventory[1] = new Ying_A();
                        break;
                    }
                }
                break;

            case "scrooge":
                Console.Clear();
                Player.Money += 1000000;
                break;

            case "gototavern":
                if (questNum == 0)
                {
                    questNum = 1;
                }
                City.GoToTavern();
                break;

            case "lvlup":
                LvlUp(true);
                break;

            case "gearupg":
                City.GearUpgrade(true);
                break;

            case "allthexp":     //Дать максимальный уровень.
                //Кол-во опыта считается так: a*(1 + 2^0 + 2^1 + 2^2 + 2^3 + 2^4 + 2^5 ... + 2^n-3), где a - начальное кол-во опыта, n - необходимый уровень
                XP = 204800;
                LvlUp();
                break;

            case "questscomplete":     //"Выполнить" квесты
                Console.Clear();
                questNum = 15;
                break;

            case "cheatsheet":    //Список отладочных команд
                Console.Clear();
                Console.WriteLine("scrooge - +1.000.000 монет\n" +
                                  "gototavern - пойти в таверну\n" +
                                  "lvlup - повысить уровень\n" +
                                  "gearupg - улучшить экипировку\n" +
                                  "allthexp - получить двадцатый уровень\n" +
                                  "questscomplete - выполнить все квесты (без награды)");
                break;

            default:
                Console.Clear();
                Console.WriteLine("Нет команды.");
                break;
            }

            GetRandomEvent();
        }
Ejemplo n.º 45
0
 public FightException(String message, Fight fight) : base(message)
 {
     this.fight = fight;
 }
Ejemplo n.º 46
0
 public ItemsForm(ref Fight fight)
 {
     InitializeComponent();
     this.fight = fight;
     InitButtons();
 }
Ejemplo n.º 47
0
        // Enemy fighting function
        void EnemyFight()
        {
            int dieRoll = die.Roll (1, 3);
            switch (dieRoll)
            {
                case 1:
                {
                    // Battle characters
                    Fight fighter = new Fight();
                    damage = fighter.CharacterFightHead<Bandit>(playerMerchant, playerTurn, die);
                    if(playerMerchant.DefencePower > 0)
                    {
                        playerMerchant.DefencePower -= 1;
                    } //end if
                    GameObject.Find ("Battler1Defense").GetComponent<Text> ().text = playerMerchant.DefencePower.ToString ();

                    // Generate fight box verb
                    randomVerb = verbs [Random.Range (0, verbs.Count)];

                    // Process fight
                    Invoke ("Fight", 0.0f);
                    break;
                } //end case Head
                case 2:
                {
                    // Battle characters
                    Fight fighter = new Fight();
                    damage = fighter.CharacterFightTorso<Bandit>(playerMerchant, playerTurn, die);

                    // Generate fight box verb
                    randomVerb = verbs [Random.Range (0, verbs.Count)];

                    // Process fight
                    Invoke ("Fight", 0.0f);
                    break;
                } //end case Torso
                case 3:
                {
                    // Battle characters
                    Fight fighter = new Fight();
                    damage = fighter.CharacterFightFeint<Bandit>(playerMerchant, playerTurn, die);
                    playerMerchant.AttackPower *= 2;
                    GameObject.Find ("Battler1Attack").GetComponent<Text> ().text = playerMerchant.AttackPower.ToString ();

                    // Generate fight box verb
                    randomVerb = "feinted at";

                    // Process fight
                    Invoke ("Fight", 0.0f);
                    break;
                } //end case Feint
                default:
                {
                    break;
                } //end case default
            } //end switch
        }
Ejemplo n.º 48
0
 public FirstKillChallenge(Fight fight, FightTeam team, Fighter toKill)
     : base(fight, team, Enums.ChallengesTypeID.FirstDie)
 {
     this.Target = toKill;
 }
Ejemplo n.º 49
0
        // Function for Head button - Lower opponent defense, lower damage
        public void Head()
        {
            if(playerTurn)
            {
                // Battle characters
                Fight fighter = new Fight();
                damage = fighter.CharacterFightHead<Bandit>(playerMerchant, playerTurn, die);
                if(enemyEntity.DefencePower > 0)
                {
                    enemyEntity.DefencePower -= 1;
                } // end if
                GameObject.Find ("Battler2Defense").GetComponent<Text> ().text = enemyEntity.DefencePower.ToString ();

                // Generate fight box verb
                randomVerb = verbs [Random.Range (0, verbs.Count)];

                // Process fight
                Invoke ("Fight", 0.0f);
            } //end if
        }
Ejemplo n.º 50
0
        public async Task get_Movimientos_Personajes(TcpClient cliente, string paquete)
        {
            Account cuenta = cliente.Account;

            string[] separador_jugadores = paquete.Substring(3).Split('|'), informaciones;
            string   _loc6, nombre_template, tipo;

            for (int i = 0; i < separador_jugadores.Length; ++i)
            {
                _loc6 = separador_jugadores[i];
                if (_loc6.Length != 0)
                {
                    informaciones = _loc6.Substring(1).Split(';');
                    if (_loc6[0].Equals('+'))
                    {
                        Celda celda = cuenta.Game.Map.get_Celda_Id(short.Parse(informaciones[0]));
                        Fight fight = cuenta.Game.Fight;
                        int   id    = int.Parse(informaciones[3]);
                        nombre_template = informaciones[4];
                        tipo            = informaciones[5];
                        if (tipo.Contains(","))
                        {
                            tipo = tipo.Split(',')[0];
                        }

                        switch (int.Parse(tipo))
                        {
                        case -1:
                        case -2:
                            if (cuenta.AccountStatus == AccountStatus.Fighting)
                            {
                                int  vida   = int.Parse(informaciones[12]);
                                byte pa     = byte.Parse(informaciones[13]);
                                byte pm     = byte.Parse(informaciones[14]);
                                byte equipo = byte.Parse(informaciones[15]);

                                fight.get_Agregar_Luchador(new Luchadores(id, true, vida, pa, pm, celda, vida, equipo));
                            }
                            break;

                        case -3:    //monstruos
                            string[] templates = nombre_template.Split(',');
                            string[] niveles   = informaciones[7].Split(',');

                            Monstruos monstruo = new Monstruos(id, int.Parse(templates[0]), celda, int.Parse(niveles[0]));
                            monstruo.lider_grupo = monstruo;

                            for (int m = 1; m < templates.Length; ++m)
                            {
                                monstruo.moobs_dentro_grupo.Add(new Monstruos(id, int.Parse(templates[m]), celda, int.Parse(niveles[m])));
                            }

                            cuenta.Game.Map.entidades.TryAdd(id, monstruo);
                            break;

                        case -4:    //NPC
                            cuenta.Game.Map.entidades.TryAdd(id, new Npcs(id, int.Parse(nombre_template), celda));
                            break;

                        case -5:
                        case -6:
                        case -7:
                        case -8:
                        case -9:
                        case -10:
                            break;

                        default:    // jugador
                            if (cuenta.AccountStatus != AccountStatus.Fighting)
                            {
                                if (cuenta.Game.Character.id != id)
                                {
                                    cuenta.Game.Map.entidades.TryAdd(id, new Personajes(id, nombre_template, byte.Parse(informaciones[7].ToString()), celda));
                                }
                                else
                                {
                                    cuenta.Game.Character.celda = celda;
                                }
                            }
                            else
                            {
                                int  vida   = int.Parse(informaciones[14]);
                                byte pa     = byte.Parse(informaciones[15]);
                                byte pm     = byte.Parse(informaciones[16]);
                                byte equipo = byte.Parse(informaciones[24]);

                                fight.get_Agregar_Luchador(new Luchadores(id, true, vida, pa, pm, celda, vida, equipo));

                                if (cuenta.Game.Character.id == id && cuenta.CombatExtensions.configuracion.posicionamiento != PosicionamientoInicioPelea.INMOVIL)
                                {
                                    await Task.Delay(300);

                                    /** la posicion es aleatoria pero el paquete GP siempre aparecera primero el team donde esta el pj **/
                                    short celda_posicion = fight.get_Celda_Mas_Cercana_O_Lejana(cuenta.CombatExtensions.configuracion.posicionamiento == PosicionamientoInicioPelea.CERCA_DE_ENEMIGOS, fight.celdas_preparacion);

                                    if (celda_posicion != celda.id)
                                    {
                                        cuenta.Connection.enviar_Paquete("Gp" + celda_posicion, true);
                                    }
                                    else
                                    {
                                        cuenta.Connection.enviar_Paquete("GR1");
                                    }
                                }
                                else if (cuenta.Game.Character.id == id)
                                {
                                    await Task.Delay(300);

                                    cuenta.Connection.enviar_Paquete("GR1");    //boton listo
                                }
                            }
                            break;
                        }
                    }
                    else if (_loc6[0].Equals('-'))
                    {
                        if (cuenta.AccountStatus != AccountStatus.Fighting)
                        {
                            int id = int.Parse(_loc6.Substring(1));
                            cuenta.Game.Map.entidades.TryRemove(id, out Entidad entidad);
                        }
                    }
                }
            }
        }
Ejemplo n.º 51
0
 public ClientsSynchronizer(Fight fight)
 {
     this.m_fight = fight;
     this.m_timout_timer = new Timer(Timeout);
     this.m_timout_timer.Elapsed += m_timout_timer_Elapsed;
 }
 public static void SendMapRunningFightDetailsMessage(IPacketReceiver client, Fight fight)
 {
     FightActor[] array  = fight.RedTeam.GetAllFighters().ToArray <FightActor>();
     FightActor[] second = fight.BlueTeam.GetAllFighters().ToArray <FightActor>();
     client.Send(new MapRunningFightDetailsMessage(fight.Id, array.Select(entry => entry.GetGameFightFighterLightInformations()), second.Select(entry => entry.GetGameFightFighterLightInformations())));
 }
Ejemplo n.º 53
0
 public FightOutcome SimulateFight(Fight fight)
 {
     return(new FightState(fight).SimulateFight());
 }
Ejemplo n.º 54
0
 public TaxCollectorFightResult(TaxCollectorNpc taxCollector, Fight fight)
 {
     this.TaxCollector = taxCollector;
     this.Fight        = fight;
     this.Loot         = new FightLoot();
 }
Ejemplo n.º 55
0
 private void OnFightJoined(Fight fight)
 {
     var evnt = FightJoined;
     if (evnt != null)
         evnt(this, fight);
 }
Ejemplo n.º 56
0
 void AttackMonster()
 {
     Fight.FightWithMonster(monsterAttr, this);
 }
Ejemplo n.º 57
0
        public void EnterFight(GameFightJoinMessage message)
        {
            if (IsFighting())
                throw new Exception("Player already fighting !");

            var fight = new Fight(message, Map);
            Fighter = new PlayedFighter(this, fight);

            Context = Fight;
            Bot.AddFrame(new FightHandler(Bot));
            OnFightJoined(Fight);
        }
Ejemplo n.º 58
0
        public async Task get_Iniciar_Accion(TcpClient cliente, string paquete)
        {
            string[]       separador = paquete.Substring(2).Split(';');
            int            id_accion = int.Parse(separador[1]);
            Account        cuenta    = cliente.account;
            CharacterClass personaje = cuenta.game.character;

            if (id_accion > 0)
            {
                int        id_entidad = int.Parse(separador[2]);
                byte       tipo_gkk_movimiento;
                Cell       celda;
                Luchadores luchador;
                Map        mapa  = cuenta.game.map;
                Fight      pelea = cuenta.game.fight;

                switch (id_accion)
                {
                case 1:
                    celda = mapa.GetCellFromId(Hash.Get_Cell_From_Hash(separador[3].Substring(separador[3].Length - 2)));

                    if (!cuenta.IsFighting())
                    {
                        if (id_entidad == personaje.id && celda.cellId > 0 && personaje.celda.cellId != celda.cellId)
                        {
                            tipo_gkk_movimiento = byte.Parse(separador[0]);

                            await cuenta.game.manager.movimientos.evento_Movimiento_Finalizado(celda, tipo_gkk_movimiento, true);
                        }
                        else if (mapa.entities.TryGetValue(id_entidad, out Entidad entidad))
                        {
                            entidad.celda = celda;

                            if (GlobalConfig.show_debug_messages)
                            {
                                cuenta.Logger.LogInfo("DEBUG", "Mouvement détecté d'une entité vers la cellule : " + celda.cellId);
                            }
                        }
                        mapa.GetEntitiesRefreshEvent();

                        int player_id = int.Parse(separador[2]);
                        if (cliente.account.chef == player_id)
                        {
                            bool starting_combat = false;
                            foreach (Monstruos monster in mapa.lista_monstruos())
                            {
                                if (monster.celda.GetDistanceBetweenCells(celda) < 3)
                                {
                                    starting_combat = true;
                                }
                            }
                            if (starting_combat == true)
                            {
                                cuenta.Logger.LogInfo("CHEF", "He's starting a combat, not going!");
                            }
                            else
                            {
                                cuenta.Logger.LogInfo("CHEF", "Following leader to cell : " + celda.cellId);
                                switch (cliente.account.game.manager.movimientos.get_Mover_A_Celda(celda, mapa.celdas_ocupadas()))
                                {
                                case Otros.Game.Entidades.Manejadores.Movimientos.ResultadoMovimientos.EXITO:
                                    cuenta.Logger.LogInfo("UI_MAPA", $"Personaje desplazado a la casilla: {celda.cellId}");
                                    break;

                                case Otros.Game.Entidades.Manejadores.Movimientos.ResultadoMovimientos.SameCell:
                                    cuenta.Logger.LogError("UI_MAPA", "El jugador está en la misma a la seleccionada");
                                    break;

                                default:
                                    cuenta.Logger.LogError("UI_MAPA", $"Error desplazando el personaje a la casilla: {celda.cellId}");
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        luchador = pelea.get_Luchador_Por_Id(id_entidad);
                        if (luchador != null)
                        {
                            luchador.celda = celda;

                            if (luchador.id == personaje.id)
                            {
                                tipo_gkk_movimiento = byte.Parse(separador[0]);

                                await Task.Delay(400 + (100 * personaje.celda.GetDistanceBetweenCells(celda)));

                                cuenta.connexion.SendPacket("GKK" + tipo_gkk_movimiento);
                            }
                        }
                    }
                    break;

                case 4:
                    separador = separador[3].Split(',');
                    celda     = mapa.GetCellFromId(short.Parse(separador[1]));

                    if (!cuenta.IsFighting() && id_entidad == personaje.id && celda.cellId > 0 && personaje.celda.cellId != celda.cellId)
                    {
                        personaje.celda = celda;
                        await Task.Delay(150);

                        cuenta.connexion.SendPacket("GKK1");
                        mapa.GetEntitiesRefreshEvent();
                        cuenta.game.manager.movimientos.movimiento_Actualizado(true);
                    }
                    break;

                case 5:
                    if (cuenta.IsFighting())
                    {
                        separador = separador[3].Split(',');
                        luchador  = pelea.get_Luchador_Por_Id(int.Parse(separador[0]));

                        if (luchador != null)
                        {
                            luchador.celda = mapa.GetCellFromId(short.Parse(separador[1]));
                        }
                    }
                    break;

                case 102:
                    if (cuenta.IsFighting())
                    {
                        luchador = pelea.get_Luchador_Por_Id(id_entidad);
                        byte pa_utilizados = byte.Parse(separador[3].Split(',')[1].Substring(1));

                        if (luchador != null)
                        {
                            luchador.pa -= pa_utilizados;
                        }
                    }
                    break;

                case 103:
                    if (cuenta.IsFighting())
                    {
                        int id_muerto = int.Parse(separador[3]);

                        luchador = pelea.get_Luchador_Por_Id(id_muerto);
                        if (luchador != null)
                        {
                            luchador.esta_vivo = false;
                        }
                    }
                    break;

                case 129:     //movimiento en pelea con exito
                    if (cuenta.IsFighting())
                    {
                        luchador = pelea.get_Luchador_Por_Id(id_entidad);
                        byte pm_utilizados = byte.Parse(separador[3].Split(',')[1].Substring(1));

                        if (luchador != null)
                        {
                            luchador.pm -= pm_utilizados;
                        }

                        if (luchador.id == personaje.id)
                        {
                            pelea.get_Movimiento_Exito(true);
                        }
                    }
                    break;

                case 151:    //obstaculos invisibles
                    if (cuenta.IsFighting())
                    {
                        luchador = pelea.get_Luchador_Por_Id(id_entidad);

                        if (luchador != null && luchador.id == personaje.id)
                        {
                            cuenta.Logger.LogError("INFORMATION", "Il n'est pas possible d'effectuer cette action à cause d'un obstacle invisible.");
                            pelea.get_Hechizo_Lanzado(short.Parse(separador[3]), false);
                        }
                    }
                    break;

                case 181:     //efecto de invocacion (pelea)
                    celda = mapa.GetCellFromId(short.Parse(separador[3].Substring(1)));
                    short id_luchador = short.Parse(separador[6]);
                    short vida        = short.Parse(separador[15]);
                    byte  pa          = byte.Parse(separador[16]);
                    byte  pm          = byte.Parse(separador[17]);
                    byte  equipo      = byte.Parse(separador[25]);

                    pelea.get_Agregar_Luchador(new Luchadores(id_luchador, true, vida, pa, pm, celda, vida, equipo, id_entidad));
                    break;

                case 302:    //fallo critico
                    if (cuenta.IsFighting() && id_entidad == cuenta.game.character.id)
                    {
                        pelea.get_Hechizo_Lanzado(0, false);
                    }
                    break;

                case 300:     //hechizo lanzado con exito
                    if (cuenta.IsFighting() && id_entidad == cuenta.game.character.id)
                    {
                        short celda_id_lanzado = short.Parse(separador[3].Split(',')[1]);
                        pelea.get_Hechizo_Lanzado(celda_id_lanzado, true);
                    }
                    break;

                case 501:
                    int tiempo_recoleccion = int.Parse(separador[3].Split(',')[1]);
                    celda = mapa.GetCellFromId(short.Parse(separador[3].Split(',')[0]));
                    byte tipo_gkk_recoleccion = byte.Parse(separador[0]);

                    await cuenta.game.manager.recoleccion.evento_Recoleccion_Iniciada(id_entidad, tiempo_recoleccion, celda.cellId, tipo_gkk_recoleccion);

                    break;

                case 900:
                    var task = Task.Run(async() => await Task.Delay(800));
                    task.Wait();
                    cuenta.connexion.SendPacket("GA902" + id_entidad, true);
                    cuenta.Logger.LogInfo("INFORMATION", "Le défi avec le personnage ID : " + id_entidad + " est annulée");
                    break;
                }
            }
        }
Ejemplo n.º 59
0
        public async Task get_Iniciar_Accion(TcpClient cliente, string paquete)
        {
            string[]      separador = paquete.Substring(2).Split(';');
            int           id_accion = int.Parse(separador[1]);
            Account       cuenta    = cliente.Account;
            GameCharacter personaje = cuenta.Game.Character;

            if (id_accion > 0)
            {
                int        id_entidad = int.Parse(separador[2]);
                byte       tipo_gkk_movimiento;
                Celda      celda;
                Luchadores luchador;
                Map        map   = cuenta.Game.Map;
                Fight      fight = cuenta.Game.Fight;

                switch (id_accion)
                {
                case 1:
                    celda = map.get_Celda_Id(Hash.get_Celda_Id_Desde_hash(separador[3].Substring(separador[3].Length - 2)));

                    if (!cuenta.IsFighting())
                    {
                        if (id_entidad == personaje.id && celda.id > 0 && personaje.celda.id != celda.id)
                        {
                            tipo_gkk_movimiento = byte.Parse(separador[0]);

                            await cuenta.Game.Handler.movimientos.evento_Movimiento_Finalizado(celda, tipo_gkk_movimiento, true);
                        }
                        else if (map.entidades.TryGetValue(id_entidad, out Entidad entidad))
                        {
                            entidad.celda = celda;

                            if (GlobalConf.mostrar_mensajes_debug)
                            {
                                cuenta.Logger.log_informacion("DEBUG", "Detectado movimiento de una entidad a la casilla: " + celda.id);
                            }
                        }
                        map.evento_Entidad_Actualizada();
                    }
                    else
                    {
                        luchador = fight.get_Luchador_Por_Id(id_entidad);
                        if (luchador != null)
                        {
                            luchador.celda = celda;

                            if (luchador.id == personaje.id)
                            {
                                tipo_gkk_movimiento = byte.Parse(separador[0]);

                                await Task.Delay(400 + (100 * personaje.celda.get_Distancia_Entre_Dos_Casillas(celda)));

                                cuenta.Connection.enviar_Paquete("GKK" + tipo_gkk_movimiento);
                            }
                        }
                    }
                    break;

                case 4:
                    separador = separador[3].Split(',');
                    celda     = map.get_Celda_Id(short.Parse(separador[1]));

                    if (!cuenta.IsFighting() && id_entidad == personaje.id && celda.id > 0 && personaje.celda.id != celda.id)
                    {
                        personaje.celda = celda;
                        await Task.Delay(150);

                        cuenta.Connection.enviar_Paquete("GKK1");
                        map.evento_Entidad_Actualizada();
                        cuenta.Game.Handler.movimientos.movimiento_Actualizado(true);
                    }
                    break;

                case 5:
                    if (cuenta.IsFighting())
                    {
                        separador = separador[3].Split(',');
                        luchador  = fight.get_Luchador_Por_Id(int.Parse(separador[0]));

                        if (luchador != null)
                        {
                            luchador.celda = map.get_Celda_Id(short.Parse(separador[1]));
                        }
                    }
                    break;

                case 102:
                    if (cuenta.IsFighting())
                    {
                        luchador = fight.get_Luchador_Por_Id(id_entidad);
                        byte pa_utilizados = byte.Parse(separador[3].Split(',')[1].Substring(1));

                        if (luchador != null)
                        {
                            luchador.pa -= pa_utilizados;
                        }
                    }
                    break;

                case 103:
                    if (cuenta.IsFighting())
                    {
                        int id_muerto = int.Parse(separador[3]);

                        luchador = fight.get_Luchador_Por_Id(id_muerto);
                        if (luchador != null)
                        {
                            luchador.esta_vivo = false;
                        }
                    }
                    break;

                case 129:     //movimiento en pelea con exito
                    if (cuenta.IsFighting())
                    {
                        luchador = fight.get_Luchador_Por_Id(id_entidad);
                        byte pm_utilizados = byte.Parse(separador[3].Split(',')[1].Substring(1));

                        if (luchador != null)
                        {
                            luchador.pm -= pm_utilizados;
                        }

                        if (luchador.id == personaje.id)
                        {
                            fight.get_Movimiento_Exito(true);
                        }
                    }
                    break;

                case 151:    //obstaculos invisibles
                    if (cuenta.IsFighting())
                    {
                        luchador = fight.get_Luchador_Por_Id(id_entidad);

                        if (luchador != null && luchador.id == personaje.id)
                        {
                            cuenta.Logger.log_Error("INFORMACIÓN", "No es posible realizar esta acción por culpa de un obstáculo invisible.");
                            fight.get_Hechizo_Lanzado(short.Parse(separador[3]), false);
                        }
                    }
                    break;

                case 181:     //efecto de invocacion (pelea)
                    celda = map.get_Celda_Id(short.Parse(separador[3].Substring(1)));
                    short id_luchador = short.Parse(separador[6]);
                    short vida        = short.Parse(separador[15]);
                    byte  pa          = byte.Parse(separador[16]);
                    byte  pm          = byte.Parse(separador[17]);
                    byte  equipo      = byte.Parse(separador[25]);

                    fight.get_Agregar_Luchador(new Luchadores(id_luchador, true, vida, pa, pm, celda, vida, equipo, id_entidad));
                    break;

                case 302:    //fallo critico
                    if (cuenta.IsFighting() && id_entidad == cuenta.Game.Character.id)
                    {
                        fight.get_Hechizo_Lanzado(0, false);
                    }
                    break;

                case 300:     //hechizo lanzado con exito
                    if (cuenta.IsFighting() && id_entidad == cuenta.Game.Character.id)
                    {
                        short celda_id_lanzado = short.Parse(separador[3].Split(',')[1]);
                        fight.get_Hechizo_Lanzado(celda_id_lanzado, true);
                    }
                    break;

                case 501:
                    int tiempo_recoleccion = int.Parse(separador[3].Split(',')[1]);
                    celda = map.get_Celda_Id(short.Parse(separador[3].Split(',')[0]));
                    byte tipo_gkk_recoleccion = byte.Parse(separador[0]);

                    await cuenta.Game.Handler.recoleccion.evento_Recoleccion_Iniciada(id_entidad, tiempo_recoleccion, celda.id, tipo_gkk_recoleccion);

                    break;

                case 900:
                    cuenta.Connection.enviar_Paquete("GA902" + id_entidad, true);
                    cuenta.Logger.log_informacion("INFORMACIÓN", "Desafio del Character id: " + id_entidad + " cancelado");
                    break;
                }
            }
        }
Ejemplo n.º 60
0
    protected override bool Init()
    {
        if (owner.IsDizzy)
        {
            return(false);
        }

        foreach (var b in owner.Buffs)
        {
            if (b.enabled && b is NfMovePosBuff)
            {
                return(false);
            }
        }

        cd = Time.time + float.Parse(buffdata.Grow);

        destPos = owner.position;
        List <Character> allChar = Fight.Inst.GetAllCharacter(owner.camp);
        List <int>       slots   = new List <int>();

        for (int i = 0; i < GameMgr.GamePlayer.MAXOPENSLOTNUM; ++i)
        {
            bool empty = true;
            for (int n = allChar.Count - 1; n >= 0; --n)
            {
                Character e = allChar[n];
                if (e.IsDead == false && e.slot == i)
                {
                    empty = false;
                    break;
                }
            }
            CampType camp = owner.camp == CampType.Friend ? CampType.Enemy : CampType.Friend;
            if (empty && owner.slot != i && Fight.Inst.FindForwardColumnTargets(camp, i).Count > 0)
            {
                slots.Add(i);
            }
        }

        if (slots.Count > 0)
        {
            destSlot = slots[Fight.Rand(0, slots.Count)];
        }
        else
        {
            destSlot = owner.slot;
        }
        destPos = Fight.Inst.GetSlotPos(owner.camp, destSlot);

        AddTbuff(owner);

        owner.slot = destSlot;
        Fight.Inst.SortAllChar();

        string[] anims = Anims;
        if (anims.Length >= 3)
        {
            float len = owner.PlayAnim(anims[0]);
            AddEvent(len, delegate {
                float moveSpeed = BaseValue;
                float animSpeed = (moveSpeed / owner.moveSpeed) * owner.moveAnimSpeed;

                owner.MoveTo(destPos, anims[1], moveSpeed, animSpeed, delegate
                {
                    AddEvent(owner.PlayAnim(anims[2]), delegate
                    {
                        OnFinish();
                        PushTskill();
                    });
                });
            });
        }
        else
        {
            float moveSpeed = BaseValue;
            float animSpeed = (moveSpeed / owner.moveSpeed) * owner.moveAnimSpeed;

            owner.MoveTo(destPos, Anim, moveSpeed, animSpeed, delegate
            {
                OnFinish();
                PushTskill();
            });
        }

        return(true);
    }