public MainWindow() { AllyUnits.CollectionChanged += Base_CollectionChanged; EnemyUnits.CollectionChanged += Base_CollectionChanged; for (int i = 0; i < 10; i++) { AllyUnits.Add(new Unit()); EnemyUnits.Add(new Unit()); } foreach (Unit unit in AllyUnits) { unit.SetEnemyUnits(EnemyUnits); unit.SetAllyUnits(AllyUnits); unit.SetPlayerBonus(PlayerBonus); } foreach (Unit unit in EnemyUnits) { unit.SetEnemyUnits(AllyUnits); unit.SetAllyUnits(EnemyUnits); } InitializeComponent(); Ally.ItemsSource = AllyUnits; Enemy.ItemsSource = EnemyUnits; DataContext = PlayerBonus; }
public override void InitialiseEnemies() { int offset = 2; //Enemy 1 Enemy enemy = new Enemy(); List <Vector2> course = new List <Vector2>(); course.Add(new Vector2(LeftBoundary + (offset * Ostacle.Width), TopBoundary + (offset * Ostacle.Height))); course.Add(new Vector2(RightBoundary - (offset * Ostacle.Width), TopBoundary + (offset * Ostacle.Height))); course.Add(new Vector2(RightBoundary - (offset * Ostacle.Width), BottomBoundary - (offset * Ostacle.Height))); course.Add(new Vector2(LeftBoundary + (offset * Ostacle.Width), BottomBoundary - (offset * Ostacle.Height))); enemy.Initialise(this, Content, graphics, course[0], course); EnemyUnits.Add(enemy); //Enemy 2 offset = 4; enemy = new Enemy(); course = new List <Vector2>(); course.Add(new Vector2(LeftBoundary + (offset * Ostacle.Width), BottomBoundary - (offset * Ostacle.Height))); course.Add(new Vector2(RightBoundary - (offset * Ostacle.Width), BottomBoundary - (offset * Ostacle.Height))); course.Add(new Vector2(RightBoundary - (offset * Ostacle.Width), TopBoundary + (offset * Ostacle.Height))); course.Add(new Vector2(LeftBoundary + (offset * Ostacle.Width), TopBoundary + (offset * Ostacle.Height))); enemy.Initialise(this, Content, graphics, course[0], course); EnemyUnits.Add(enemy); }
public void AddUnit(Unit unit, ConflicSide side) { if (side == ConflicSide.Player) { PlayerUnits.Add(unit); } else { EnemyUnits.Add(unit); } }
public void Add(Unit unit) { if (unit.hasAuthority && unit.playerId == playerId) { FriendlyUnits.Add(unit); } else { EnemyUnits.Add(unit); } }
public override void InitialiseEnemies() { int offset = 2; //Enemy 1 Enemy enemy = new Enemy(); List <Vector2> course = new List <Vector2>(); course.Add(new Vector2(512, 688)); course.Add(new Vector2(512, 944)); course.Add(new Vector2(753, 944)); course.Add(new Vector2(753, 688)); enemy.Initialise(this, Content, graphics, course[0], course); EnemyUnits.Add(enemy); ////Enemy 2 enemy = new Enemy(); course = new List <Vector2>(); course.Add(new Vector2((7 * RightBoundary) / 8, TopBoundary + (offset * Ostacle.Height))); course.Add(new Vector2((7 * RightBoundary) / 8, BottomBoundary - (offset * Ostacle.Height))); course.Add(new Vector2((5 * RightBoundary) / 8, BottomBoundary - (offset * Ostacle.Height))); course.Add(new Vector2((5 * RightBoundary) / 8, TopBoundary + (offset * Ostacle.Height))); enemy.Initialise(this, Content, graphics, course[0], course); EnemyUnits.Add(enemy); ////Enemy 3 enemy = new Enemy(); course = new List <Vector2>(); course.Add(new Vector2((7 * RightBoundary) / 8, TopBoundary + (offset * Ostacle.Height))); course.Add(new Vector2((7 * RightBoundary) / 8, BottomBoundary - (offset * Ostacle.Height))); course.Add(new Vector2((5 * RightBoundary) / 8, BottomBoundary - (offset * Ostacle.Height))); course.Add(new Vector2((5 * RightBoundary) / 8, TopBoundary + (offset * Ostacle.Height))); enemy.Initialise(this, Content, graphics, course[0], course); EnemyUnits.Add(enemy); ////Enemy 4 enemy = new Enemy(); course = new List <Vector2>(); course.Add(new Vector2(RightBoundary / 8, TopBoundary + (offset * Ostacle.Height))); course.Add(new Vector2((3 * RightBoundary) / 8, TopBoundary + (offset * Ostacle.Height))); course.Add(new Vector2((3 * RightBoundary) / 8, BottomBoundary - (offset * Ostacle.Height))); course.Add(new Vector2(RightBoundary / 8, BottomBoundary - (offset * Ostacle.Height))); enemy.Initialise(this, Content, graphics, course[0], course); EnemyUnits.Add(enemy); }
void OnEntityFound(System.Object obj) { IGameEntity g = ((GameObject)obj).GetComponent <IGameEntity>(); if (g.info.isUnit) { if (!EnemyUnits.Contains((Unit)g)) { g.registerFatalWounds(OnEnemyDied); EnemyUnits.Add((Unit)g); } } else if (g.info.isBuilding) { if (!EnemyBuildings.Contains(g)) { g.registerFatalWounds(OnEnemyDied); EnemyBuildings.Add(g); } } }