Esempio n. 1
0
        public override AttackInfoList Defend(CreepUnitList InRange)
        {
            AttackInfoList infos = new AttackInfoList();
            if (InRange.Count > 3)
            {
                Random rand = new Random();
                int toAtk = rand.Next(2);
                toAtk += 2;

                for (int i = 0; i < toAtk; i++)
                {
                    infos.Add(Defend(InRange[i]));
                }
            }
            else
            {
                for (int i = 0; i < InRange.Count; i++)
                {
                    infos.Add(Defend(InRange[i]));
                }
            }

            return infos;
        }
Esempio n. 2
0
        public AttackInfoList StealGold(CreepUnitList InRange)
        {
            AttackInfoList infos = new AttackInfoList();
            if (InRange.Count > 3)
            {
                Random rand = new Random();
                int toSteal = rand.Next(2);
                toSteal += 2;

                for (int i = 0; i < toSteal; i++)
                {
                    infos.Add(StealGold(InRange[i]));
                }
            }
            else
            {
                for (int i = 0; i < InRange.Count; i++)
                {
                    infos.Add(StealGold(InRange[i]));
                }
            }

            return infos;
        }
Esempio n. 3
0
        public override ProjectileList ThrowProjectile(CreepUnitList InRange)
        {
            ProjectileList Projectiles = new ProjectileList();
            if (InRange.Count > 3)
            {
                Random rand = new Random();
                int toAtk = rand.Next(2);
                toAtk += 2;

                for (int i = 0; i < toAtk; i++)
                {
                    Projectiles.Add(ThrowProjectile(InRange[i]));
                }
            }
            else
            {
                for (int i = 0; i < InRange.Count; i++)
                {
                    Projectiles.Add(ThrowProjectile(InRange[i]));
                }
            }

            return Projectiles;
        }
Esempio n. 4
0
        public Surface Render(CreepUnitList ToRender, Map map)
        {
            Surface CreepsLayer = new Surface(map.Columns*Tile.TILE_WIDTH,map.Rows*Tile.TILE_HEIGHT);
            CreepsLayer.Fill(Color.Magenta);
            CreepsLayer.TransparentColor = Color.Magenta;
            CreepsLayer.Transparent = true;

            foreach (CreepUnit Unit in ToRender)
            {
                if (!Unit.Position.IsEmpty && Unit.Health > 0)
                {
                    if (!Sprites.ContainsKey(Unit))
                    {
                        Sprites.Add(Unit, new DirectionnalSprite(Textures));
                    }
                    /*Surface Creep = new Surface(CreepUnit.CREEP_WIDTH_PX, CreepUnit.CREEP_HEIGHT_PX);
                    Creep.Fill(Color.Red);
                    Circle c = new Circle(11, 11, 3);

                    Creep.Draw(c, Color.SeaGreen, true);
                    Rectangle Clip = new Rectangle(Unit.Position, Creep.Size);
                    CreepsLayer.Blit(Creep, Clip);*/
                }
                else if (Unit.Health <= 0 || Unit.Position.IsEmpty)
                {
                    if (Sprites.ContainsKey(Unit))
                    {
                        Sprites[Unit].Visible = false;
                        Sprites.Remove(Unit);
                    }
                }
                else if (Unit.Position.X == 0 && Unit.Position.Y == 0 && !Unit.Position.IsEmpty)
                {
                    if (Sprites.ContainsKey(Unit))
                    {
                        Sprites[Unit].Visible = false;
                        Sprites.Remove(Unit);
                    }
                }
            }

            foreach(CreepUnit Unit in Sprites.Keys)
            {
                Sprites[Unit].Direction = Unit.Direction;

                Sprites[Unit].X = Unit.Position.X;
                Sprites[Unit].Y = Unit.Position.Y;

                Sprites[Unit].UpdateFrame();

                if(Sprites[Unit].Position.X != 0 && Sprites[Unit].Position.Y != 0)
                {
                    CreepsLayer.Blit(Sprites[Unit]);
                }

            }

                //Healh Bar Render
                foreach (CreepUnit Unit in ToRender)
                {
                    if (!Unit.Position.IsEmpty && Unit.Health != 0)
                    {
                        if (Unit.Health != 0)
                        {
                            Surface HealthBSur = RenderHealthBar(Unit.TotalHealth, Unit.Health);
                            Point HealthBarP = new Point(Unit.Position.X, Unit.Position.Y - 6);
                            Rectangle Clip = new Rectangle(HealthBarP, HealthBSur.Size);
                            CreepsLayer.Blit(RenderHealthBar(Unit.TotalHealth, Unit.Health), Clip);
                        }
                    }
                }

            return CreepsLayer;
        }
Esempio n. 5
0
 public virtual ProjectileList ThrowProjectile(CreepUnitList InRange)
 {
     return new ProjectileList();
 }
Esempio n. 6
0
 public virtual AttackInfoList Defend(CreepUnitList InRange)
 {
     return new AttackInfoList();
 }
Esempio n. 7
0
 /// <summary>
 /// Start the next wave
 /// </summary>
 public void StartWave()
 {
     if (State == GameState.NoAttack)
     {
         Tick = 0;
         StartNewCreep = true;
         int WaveId = Wave - 1;
         Creeps = new CreepUnitList(CreepWaves.Wave[Wave - 1].ToCreepUnit(), CreepWaves.Wave[Wave - 1].Numbers);
         State = GameState.CreepAttack;
         Score += Gold;
     }
 }
Esempio n. 8
0
        /// <summary>
        /// Remove the creep that have no more health
        /// </summary>
        public void RemoveDeadCreeps()
        {
            int DeadCreeps = 0;
            CreepUnitList toRemove = new CreepUnitList();

            foreach (CreepUnit Unit in Creeps)
            {
                if (Unit.Health <= 0)
                {
                    toRemove.Add(Unit);
                    DeadCreeps++;
                    Gold += Unit.Level * 3;
                    Score += Unit.Level * 200;
                }
            }

            foreach(CreepUnit Unit in toRemove)
            {
                Unit.Position = new Point();
                Unit.Health = 0;
                Creeps.Remove(Unit);
            }
        }