Exemplo n.º 1
0
 public UnitController(Unit u, GameplayManager gm)
 {
     controlledUnit = u;
     this.gm = gm;
     u.Controller = this;
     fsm = new UnitFSM(this,gm);
     SetSteering(new StandStill(gm, u));
 }
 public void SpawnUnit(Unit u, Vector2 position)
 {
     u.Enable();
     u.Position = position;
     //u.Nudge();
     attackables.Add(u);
     controllers.Add(new UnitController(u, this));
     
 }
Exemplo n.º 3
0
 /// <summary>
 /// Move unit to a suitable location and then enable it
 /// </summary>
 /// <param name="u"></param>
 private void SpawnUnit(Unit u)
 {
     for (int i = gridX - 1; i < gridX + tileWidth + 1; i++) {
         for (int j = gridY - 1; j < gridY + tileHeight + 1; i++) {
             if (grid.IsPassable(i, j)) {
                 gm.SpawnUnit(u, new Vector2(Grid.TileSize * (i + 0.5f), Grid.TileSize * (j + 0.5f)) + Vector2.Normalize(new Vector2((float)Game1.rand.NextDouble() * 2 - 1, (float)Game1.rand.NextDouble() * 2 - 1))*0.1f);
                 return;
             }
         }
     }
 }
Exemplo n.º 4
0
 private void QueueUnit(Unit u)
 {
     productionQueue.Enqueue(u);
 }
 public List<Attackable> GetAllFriendlyUnitsInRange(Unit u, float range)
 {
     List<Attackable> friendly = new List<Attackable>();
     foreach (Attackable a in attackables) {
         if (a != u && a.Faction == u.Faction && AttackableHelper.Distance(u, a) <= range)
             friendly.Add(a);
     }
     return friendly;
 }
Exemplo n.º 6
0
 public void Detach()
 {
     controlledUnit = null;
 }
 public UnitController(Unit u, GameplayManager gm) {
     controlledUnit = u;
     this.gm = gm;
     u.Controller = this;
     fsm = new UnitFSM(this);
 }
Exemplo n.º 8
0
 public static Unit CreateRangedUnit(GameplayManager gm, Vector2 position,int faction, World world)
 {
     Unit u = new Unit(gm, world, position, faction, 100, 5.0f, 60.0f, 80.0f, 100.0f, 6, 0.5f, 5.0f, 0.3f, 3.0f, 50);
     return u;
 }
Exemplo n.º 9
0
 public static Unit CreateMeleeUnit(GameplayManager gm, Vector2 position, int faction, World world)
 {
     Unit u = new Unit(gm, world, position, faction, 50, 8.0f, 2.0f, 80.0f, 100.0f, 12, 0.8f, 6.0f, 0.2f, 3.0f, 100);
     return u;
 }