示例#1
0
 private void Attack(Unit other)
 {
     other.hp = other.hp - this.strength;
 }
示例#2
0
 public void SetOccupant(Unit u)
 {
     this.occupant = u;
 }
示例#3
0
 private void deselectUnit()
 {
     selected.Deselect();
     selected = null;
     unitSelected = false;
     foreach (Square s in map.Squares())
     {
         s.SetDistanceFrom(999);
         s.SPath().Clear();
     }
 }
示例#4
0
        // helper function for keyboard input on the map. Here to keep update method cleaner.
        private void MapInput()
        {
            if(input.KeyPressed(Keys.W) && (int)cursor.Y != 0)
            {
                cursor.Y -= 1;
            }
            if (input.KeyPressed(Keys.S) && (int)cursor.Y != map.Rows()-1)
            {
                cursor.Y += 1;
            }
            if (input.KeyPressed(Keys.A) && (int)cursor.X != 0)
            {
                cursor.X -= 1;
            }
            if (input.KeyPressed(Keys.D) && (int)cursor.X != map.Cols()-1)
            {
                cursor.X += 1;
            }

            if(unitSelected)
            {
                if (input.KeyPressed(Keys.RightShift))
                {
                    deselectUnit();
                }
                if(input.KeyPressed(Keys.Enter) && selected.InMoveRange().Contains(map.Square((int)cursor.Y, (int)cursor.X)))
                {
                    selected.MoveTo(map.Square((int)cursor.Y, (int)cursor.X));
                    deselectUnit();
                }
            }
            else
            {
                if (input.KeyPressed(Keys.Enter) && (map.Square((int)cursor.Y, (int)cursor.X).Occupant() != null))
                {
                    map.Square((int)cursor.Y, (int)cursor.X).Occupant().Select();
                    selected = map.Square((int)cursor.Y, (int)cursor.X).Occupant();
                    unitSelected = true;
                }

            }
        }
示例#5
0
 public void AddUnit(Unit unit)
 {
     units.Add(unit);
 }