예제 #1
0
        public void LoadArena(string arenaFile)
        {
            XmlDocument xml = new XmlDocument();

            xml.Load(arenaFile);

            XmlNodeList nodes = xml.DocumentElement.ChildNodes;

            foreach (XmlNode node in nodes.Item(0).SelectNodes("object"))
            {
                Vector2 pos = new Vector2(Int32.Parse(node.Attributes["x"].Value), Int32.Parse(node.Attributes["y"].Value));
            }

            Units = new List <ArenaObj>();

            foreach (XmlNode node in nodes.Item(1).SelectNodes("enemy"))
            {
                ArenaObj enemy = (ArenaObj)Activator.CreateInstance(EnemyTypes[node.Attributes["type"].Value]);
                Units.Add(enemy);
            }


            int[,] formation = CreateFormation(Units.Count);

            FormationSize = new Vector2(formation.GetLength(0), formation.GetLength(1)) * (UnitSpacing + Vector2.One) - UnitSpacing;

            int enemyId = 0;

            _formationAlignY = formation.GetLength(1) * ((int)UnitSpacing.Y + 1) / 2 - 1;
            for (var x = 0; x < formation.GetLength(0); x += 1)
            {
                for (var y = 0; y < formation.GetLength(1); y += 1)
                {
                    if (formation[x, y] == 1)
                    {
                        Units[enemyId].Pos = FormationPos + new Vector2(x, y) * (UnitSpacing + Vector2.One) - new Vector2(0, _formationAlignY);
                        enemyId           += 1;
                    }
                }
            }

            ArenaPlayer player = new ArenaPlayer();

            player.Pos = _playerPos;

            Units.Add(player);
        }
예제 #2
0
        public int Attack(ArenaObj obj)
        {
            int buffAttack = 0;

            foreach (StatEffect effect in Effects)
            {
                buffAttack += effect.AttackBuff;
            }
            int buffDefence = 0;

            foreach (StatEffect effect in obj.Effects)
            {
                buffDefence += effect.DefenceBuff;
            }

            int resDmg = Math.Max(1,
                                  (int)MathHelper.Lerp(
                                      MinAttack + buffAttack,
                                      MaxAttack + 1 + buffAttack,
                                      (float)GameplayController.Random.NextDouble()
                                      ) - (obj.Defence + buffDefence)
                                  );

            obj.Health -= resDmg;
            if (obj.Health <= 0)
            {
                obj.Health = 0;
                SoundController.PlaySound(SoundController.Death);
            }
            else
            {
                SoundController.PlaySound(SoundController.Hit);
            }
            obj.DmgAnim = true;
            return(resDmg);
        }
예제 #3
0
        public StatEffect(StatEffect effect, ArenaObj owner, int stage)
        {
            RegenerationBuff = effect.RegenerationBuff;
            PoisonBuff       = effect.PoisonBuff;

            AttackBuff  = effect.AttackBuff;
            DefenceBuff = effect.DefenceBuff;
            SpeedBuff   = effect.SpeedBuff;
            Duration    = effect.Duration;

            IsInfective     = effect.IsInfective;
            InfectionChance = effect.InfectionChance;

            InfectionStage    = stage;
            InfectionMaxStage = effect.InfectionMaxStage;

            Color = effect.Color;

            Owner = owner;
            Name  = effect.Name;
            Token = effect.Token;

            ProcChance = effect.ProcChance;
        }
예제 #4
0
        protected void PerformBasicAttack()
        {
            Enemy enemy = GetMostLeftUnit();

            if ((enemy != this && !_rabies) || Health <= 0)
            {
                Arena arena = (Arena)Objects.ObjFind <Arena>(0);
                arena.GiveInitiative();
                return;
            }

            if (_attackDialogue == null)
            {
                if (_skipTurn)
                {
                    var dialogueString = Strings.EnemySkipTurn
                                         .Replace("{0}", Name);
                    _attackDialogue = new Dialogue(new string[] { "" }, new string[] { dialogueString });
                    _skipTurn       = false;
                }
                else
                {
                    if (_rabies)
                    {
                        int objId = (int)(GameplayController.Random.NextDouble() * (float)Objects.Count <ArenaObj>());

                        ArenaObj obj = (ArenaObj)Objects.ObjFind <ArenaObj>(objId);

                        int dmg = Attack(obj);


                        var dialogueString = Strings.EnemyRabid
                                             .Replace("{0}", Name.ToLower())
                                             .Replace("{1}", obj.Name1.ToLower())
                                             .Replace("{2}", dmg.ToString());

                        _attackDialogue = new Dialogue(new string[] { "" }, new string[] { dialogueString });
                    }
                    else
                    {
                        int dmg = Attack((ArenaPlayer)Objects.ObjFind <ArenaPlayer>(0));

                        var dialogueString = Strings.EnemyAttack
                                             .Replace("{0}", Name)
                                             .Replace("{1}", dmg.ToString());

                        _attackDialogue = new Dialogue(new string[] { "" }, new string[] { dialogueString });
                    }
                }
            }
            else
            {
                if (_attackDialogue.Destroyed)
                {
                    _attackDialogue = null;
                    Arena arena = (Arena)Objects.ObjFind <Arena>(0);
                    arena.GiveInitiative();
                    _rabies = false;
                }
            }
        }