예제 #1
0
 //Static methods
 /// <summary>
 /// Creates new units based on an array of unit types.
 /// </summary>
 /// <param name="units">Ints representing unit types.</param>
 /// <param name="unitList">List where finished units will be placed.</param>
 public static void CreateUnits(int[] units, ref List<Unit> unitList)
 {
     for (int i = 0; i < units.Length; i++)
     {
         Unit newUnit = new Unit(units[i]);
         unitList.Add(newUnit);
     }
 }
예제 #2
0
 //Constructors
 /// <summary>
 /// Creates a new instance of Ammunition.
 /// </summary>
 /// <param name="type">The tower type.</param>
 /// <param name="position">The center of the tower.</param>
 /// <param name="rotation">The rotation of the tower.</param>
 /// <param name="speed">How fast the ammunition moves.</param>
 /// <param name="damage">The towers damage.</param>
 public Ammunition(int type, Vector2 position, float rotation, int speed, int damage, ref Unit target)
     : base(Ammunition.sprites[type], position)
 {
     this.type = type;
     this.rotation = rotation;
     this.speed = speed;
     this.damage = damage;
     this.target = target;
 }
예제 #3
0
파일: Tower.cs 프로젝트: ProfChaos/Immunity
 protected void GetClosestEnemy(ref List<Unit> enemies)
 {
     target = null;
     float shortestRange = range;
     foreach (Unit enemy in enemies)
     {
         if (Vector2.Distance(center, enemy.Center) < shortestRange)
         {
             shortestRange = Vector2.Distance(center, enemy.Center);
             target = enemy;
         }
     }
 }
예제 #4
0
파일: Wave.cs 프로젝트: ProfChaos/Immunity
 //Methods
 private void AddEnemy(int unitType)
 {
     Unit enemy = new Unit(unitType, waveNumber);
     enemies.Add(enemy);
     spawnTimer = 0;
     enemiesSpawned++;
 }