Ejemplo n.º 1
0
 internal Unit(
     float posX,
     float posY,
     string name,
     Map context
     )
 {
     _job           = name;
     _lifePoints    = Convert.ToUInt32(context.GetVillage.Beasts.Beasts[name]["Vie"]);
     _maxLifePoints = Convert.ToUInt32(context.GetVillage.Beasts.Beasts[name]["Vie"]);;
     _dmg           = Convert.ToUInt32(context.GetVillage.Beasts.Beasts[name]["Dégâts"]);;
     _armor         = Convert.ToUInt32(context.GetVillage.Beasts.Beasts[name]["Armure"]);;
     _isMoving      = false;
     _aaCooldown    = new Cooldown(Convert.ToUInt32(context.GetVillage.Beasts.Beasts[name]["Cooldown"]));
     _speed         = (float)Convert.ToDouble(context.GetVillage.Beasts.Beasts[name]["Vitesse"]);;
     _context       = context;
     _range         = (float)Convert.ToDouble(context.GetVillage.Beasts.Beasts[name]["Range"]);;
     _position      = new Vectors(posX, posY);
 }
Ejemplo n.º 2
0
 internal Building(float posX, float posY,
                   uint lifePoints, uint maxLifePoints,
                   uint armor, uint rank,
                   uint woodCost, uint foodCost, uint stoneCost, uint villagerCost,
                   Map context, string name, string desc)
 {
     _position      = new Vectors(posX, posY);
     _lifePoints    = lifePoints;
     _maxLifePoints = _lifePoints;
     _armor         = armor;
     _rank          = 1;
     _woodCost      = woodCost;
     _stoneCost     = stoneCost;
     _foodCost      = foodCost;
     _villagerCost  = villagerCost;
     _context       = context;
     _count++;
     _name = name;
     _desc = desc;
 }
Ejemplo n.º 3
0
        Vectors FindClosestEnemy(Map map)
        {
            List <Building> units = map.BuildList;

            if (units.Count == 0)
            {
                throw new IndexOutOfRangeException("Aucune unité n'est disponible!");
            }

            var     magnitude    = Position.X + Position.Y;
            float   min          = Math.Abs((units[0].Position.X + units[0].Position.Y) - magnitude);
            Vectors unitToReturn = units[0].Position;

            foreach (Building n in units)
            {
                var newMin = Math.Abs((n.Position.X + n.Position.Y) - magnitude);
                if (newMin < min)
                {
                    min          = newMin;
                    unitToReturn = n.Position;
                }
            }
            return(unitToReturn);
        }
Ejemplo n.º 4
0
 internal float TotDistance(Vectors origin, Vectors arrival)
 {
     return((float)(Math.Pow(arrival.X - origin.X, 2) + Math.Pow(arrival.Y - origin.Y, 2)));
 }
Ejemplo n.º 5
0
        float SubstractY(Vectors origin, Vectors arrival)
        {
            float y = Math.Abs((origin._posY) - Math.Abs(arrival._posY));

            return(y);
        }
Ejemplo n.º 6
0
        float SubstractX(Vectors origin, Vectors arrival)
        {
            float x = Math.Abs((origin._posX) - Math.Abs(arrival._posX));

            return(x);
        }
Ejemplo n.º 7
0
        internal bool IsInRange(Vectors origin, Vectors arrival, float range)
        {
            float result = (float)(Math.Pow(arrival.X - origin.X, 2) + Math.Pow(arrival.Y - origin.Y, 2));

            return(result <= (float)Math.Pow(range, 2));
        }
Ejemplo n.º 8
0
        internal void SpawnWave()
        {
            GobAmount = Round * 4;

            for (int i = 0; i < GobAmount; i++)
            {
                Vectors placeToSpawn = SpawnLocation();
                Barbar  v1           = new Barbar(
                    placeToSpawn.X,
                    placeToSpawn.Y,
                    WavesContext.Vill.Beasts.Beasts["Gobelin"]["Nom"], WavesContext
                    );
            }

            uint magesToSpawn;

            if (Round >= 4)
            {
                magesToSpawn = Round;
                for (int i = 0; i < magesToSpawn; i++)
                {
                    Vectors placeToSpawn = SpawnLocation();
                    Mage    m            = new Mage(
                        placeToSpawn.X,
                        placeToSpawn.Y,
                        WavesContext.Vill.Beasts.Beasts["Mage"]["Nom"], WavesContext
                        );
                }
            }

            if (Round >= 8)
            {
                uint gargoylesToSpawn = (uint)Math.Ceiling((double)Round / 2);

                for (int i = 0; i < gargoylesToSpawn; i++)
                {
                    Vectors  placeToSpawn = SpawnLocation();
                    Gargoyle g            = new Gargoyle(
                        placeToSpawn.X,
                        placeToSpawn.Y,
                        WavesContext.Vill.Beasts.Beasts["Gargoyle"]["Nom"], WavesContext
                        );
                }
            }

            if (Round >= 12)
            {
                uint giantsToSpawn = (uint)Math.Ceiling((double)Round / 2);

                for (int i = 0; i < giantsToSpawn; i++)
                {
                    Vectors placeToSpawn = SpawnLocation();
                    Giant   g            = new Giant(
                        placeToSpawn.X,
                        placeToSpawn.Y,
                        WavesContext.Vill.Beasts.Beasts["Giant"]["Nom"], WavesContext
                        );
                }
            }
            Round++;
        }