//public InputManager( MovementManager newMovementManager) public InputManager(ref ModelManager newmodelManager) { //movementManager = newMovementManager; this.modelManager = newmodelManager; mouseRec = Rectangle.Empty; mouseRecOrigin = Vector2.Zero; }
public static ModelManager getInstance(ref Map newMap){ if (instance == null) { instance = new ModelManager(ref newMap); return instance; } else return instance; }
public GUIButtons(ref ModelManager mod) { modMan = mod; waveNum = 0; aiScore = 0; playerScore = 0; timeDrain = 0; disAd = 0; active = false; buttonCols = new Dictionary<String,Rectangle>(); labs = new List<String>(new string[] { "ARCHER", "PAWN", "TOWER", "WARRIOR", "COMMANDER", "CLERIC", "ROGUE", "APPRENTICE", "CATAPULT" }); init(); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { try { Window.AllowUserResizing = true; //graphics.CreateDevice(); graphics.PreferredBackBufferHeight = 704; graphics.PreferredBackBufferWidth = 1024; graphics.IsFullScreen = false; // graphics.ToggleFullScreen(); graphics.ApplyChanges(); } catch { } // Create a new SpriteBatch, which can be used to draw textures. ClickTimer = 0; groupedUnits = new Dictionary<Keys, List<GameObject>>(); spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: Add your initialization logic here defeatScreen = new Map("Content/defeatScreen.txt"); mainScreen = new Map("Content/MainScreen.txt"); levelSelect = new Map("Content/levelSelect.txt"); castleDefense = new Map("Content/castleDefense.txt"); riverDefense = new Map("Content/riverDefense.txt"); castleSiege = new Map("Content/castleSiege.txt"); victoryScreen = new Map("Content/victoryScreen.txt"); mainScreenSelector = new Selector(new Rectangle(448, 0, 128, 64), mainScreen, levelSelect, true); castleDefenseSelector = new Selector(new Rectangle(96, 320, 192, 96), levelSelect, castleDefense, false); riverDefenseSelector = new Selector(new Rectangle(416, 320, 192, 96), levelSelect, riverDefense, false); castleSiegeSelector = new Selector(new Rectangle(736, 320, 192, 96), levelSelect, castleSiege, false); defeatScreenSelector = new Selector(new Rectangle(448, 256, 128, 64), defeatScreen, mainScreen, false); victoryScreenSelector = new Selector(new Rectangle(448, 288, 128, 64), victoryScreen, mainScreen, false); modMan = ModelManager.getInstance(ref mainScreen); loadMan = LoadManager.getInstance(); projMan = ProjectileManager.getInstance(); screenManager = ScreenManager.getInstance(); // Add all maps to screenManager.allMaps screenManager.allMaps.Add(defeatScreen); screenManager.allMaps.Add(mainScreen); screenManager.allMaps.Add(levelSelect); screenManager.allMaps.Add(castleDefense); screenManager.allMaps.Add(riverDefense); screenManager.allMaps.Add(castleSiege); screenManager.allMaps.Add(victoryScreen); // Add all selectors to screenManager.allSelectors screenManager.allSelectors.Add(defeatScreenSelector); screenManager.allSelectors.Add(mainScreenSelector); screenManager.allSelectors.Add(castleDefenseSelector); screenManager.allSelectors.Add(riverDefenseSelector); screenManager.allSelectors.Add(castleSiegeSelector); screenManager.allSelectors.Add(victoryScreenSelector); // Set initial maps; These will always be defeatScreen, mainScreen and levelSelect, // since the user spawns on mainScreen screenManager.prevMap = defeatScreen; screenManager.currentMap = mainScreen; screenManager.nextMap = levelSelect; healthChecker = new HealthSystem(ModelManager.player, ModelManager.artificial); attackChecker = new AttackSystem(ref ModelManager.player, ref ModelManager.artificial); attackChecker.linkSystem(projMan); attackChecker.linkContent(Content); movementManager = MovementManager.getInstance(); movementManager.setMap(mainScreen); inputManager = new InputManager(ref modMan); aiManager = AIManager.getInstance(ref mainScreen); mBar = new MoraleBar(ref modMan); gui = new GUIButtons(ref modMan); info = new InfoCard(ref modMan); inputManager.linkGUI(gui); MoraleBar.resourceVal(buildResources); mousePrev = Mouse.GetState(); //Create Player's units //testInitialization(); testCommander(); base.Initialize(); this.IsMouseVisible = true; }
// Ensures that the managers all know which map to work on. public void updateManagerMap(Map myMap) { modMan = ModelManager.getInstance(ref myMap); movementManager.setMap(myMap); aiManager = AIManager.getInstance(ref myMap); }
public InfoCard(ref ModelManager mod) { modMan = mod; }
public void fireProjectiles() { foreach (Projectile item in proj) { item.move(); } foreach (Projectile projectile in proj) // pobj stands for projectile object { foreach (GameObject aobj in ModelManager.getArtificial()) { if (projectile.isAlive()) { if (projectile.collisionType == "homing") { if (projectile.position.X <= projectile.end_point.X && projectile.position.X >= projectile.prev_point.X && projectile.position.Y <= projectile.end_point.Y && projectile.position.Y >= projectile.prev_point.Y) //equivalent to IsInRange { projectile.health = -1; projectile.collided = true; if (projectile.target.isAlive()) { projectile.target.health -= projectile.damage; } if (String.Compare(projectile.type, "ICEBALL", true) == 0 && projectile.target.isAlive()) { if (projectile.target.attackRange > 5) { projectile.target.attackRange -= 5; } projectile.target.attackSpeed += 10; } } } else if (projectile.collisionType == "straight" && aobj.aiTarget != aobj) { if (projectile.IsInRange(aobj)) { projectile.health = -1; projectile.collided = true; if (aobj.isAlive()) { aobj.health -= projectile.damage; } } } else if (projectile.collisionType == "arc") { if (projectile.position.X <= projectile.end_point.X && projectile.position.X >= projectile.prev_point.X && projectile.position.Y <= projectile.end_point.Y && projectile.position.Y >= projectile.prev_point.Y) { projectile.health = -1; projectile.collided = true; if (aobj.isAlive() && projectile.IsInRange(aobj)) { aobj.health -= projectile.damage; } } } } }//check AI units foreach (GameObject pobj in ModelManager.player) { if (projectile.isAlive()) { if (projectile.collisionType == "homing") { if (projectile.position.X <= projectile.end_point.X && projectile.position.X >= projectile.prev_point.X && projectile.position.Y <= projectile.end_point.Y && projectile.position.Y >= projectile.prev_point.Y) //equivalent to IsInRange { projectile.health = -1; projectile.collided = true; if (projectile.target.isAlive()) { projectile.target.health -= projectile.damage; } if (String.Compare(projectile.type, "ICEBALL", true) == 0 && projectile.target.isAlive()) { if (projectile.target.attackRange > 5) { projectile.target.attackRange -= 5; } projectile.target.attackSpeed += 10; } } } else if (projectile.collisionType == "straight" && projectile.target != pobj) { if (projectile.IsInRange(pobj)) { projectile.health = -1; projectile.collided = true; if (pobj.isAlive()) { pobj.health -= projectile.damage; } } } else if (projectile.collisionType == "arc") { if (projectile.position.X <= projectile.end_point.X && projectile.position.X >= projectile.prev_point.X && projectile.position.Y <= projectile.end_point.Y && projectile.position.Y >= projectile.prev_point.Y) { projectile.collided = true; projectile.health = -1; if (pobj.isAlive() && projectile.IsInRange(pobj)) { pobj.health -= projectile.damage; } } } } }//check AI units if (projectile.collisionType == "arc") // Kills the arc projectile at the end, after checking collision with all objects { if (projectile.position.X <= projectile.end_point.X && projectile.position.X >= projectile.prev_point.X && projectile.position.Y <= projectile.end_point.Y && projectile.position.Y >= projectile.prev_point.Y) { projectile.health = -1; } } if (projectile.collisionType == "straight") { if (projectile.position.X > 1024 || projectile.position.Y > 704 || projectile.position.X < 0 || projectile.position.Y < 0) { projectile.collided = true; projectile.health = -1; } } } refreshProjectiles(); }
public MoraleBar (ref ModelManager mod) { modMan = mod; }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { try { Window.AllowUserResizing = true; //graphics.CreateDevice(); graphics.PreferredBackBufferHeight = 704; graphics.PreferredBackBufferWidth = 1024; graphics.IsFullScreen = false; // graphics.ToggleFullScreen(); graphics.ApplyChanges(); } catch { } // Create a new SpriteBatch, which can be used to draw textures. ClickTimer = 0; groupedUnits = new Dictionary <Keys, List <GameObject> >(); spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: Add your initialization logic here defeatScreen = new Map("Content/defeatScreen.txt"); mainScreen = new Map("Content/MainScreen.txt"); levelSelect = new Map("Content/levelSelect.txt"); castleDefense = new Map("Content/castleDefense.txt"); riverDefense = new Map("Content/riverDefense.txt"); castleSiege = new Map("Content/castleSiege.txt"); victoryScreen = new Map("Content/victoryScreen.txt"); mainScreenSelector = new Selector(new Rectangle(448, 0, 128, 64), mainScreen, levelSelect, true); castleDefenseSelector = new Selector(new Rectangle(96, 320, 192, 96), levelSelect, castleDefense, false); riverDefenseSelector = new Selector(new Rectangle(416, 320, 192, 96), levelSelect, riverDefense, false); castleSiegeSelector = new Selector(new Rectangle(736, 320, 192, 96), levelSelect, castleSiege, false); defeatScreenSelector = new Selector(new Rectangle(448, 256, 128, 64), defeatScreen, mainScreen, false); victoryScreenSelector = new Selector(new Rectangle(448, 288, 128, 64), victoryScreen, mainScreen, false); modMan = ModelManager.getInstance(ref mainScreen); loadMan = LoadManager.getInstance(); projMan = ProjectileManager.getInstance(); screenManager = ScreenManager.getInstance(); // Add all maps to screenManager.allMaps screenManager.allMaps.Add(defeatScreen); screenManager.allMaps.Add(mainScreen); screenManager.allMaps.Add(levelSelect); screenManager.allMaps.Add(castleDefense); screenManager.allMaps.Add(riverDefense); screenManager.allMaps.Add(castleSiege); screenManager.allMaps.Add(victoryScreen); // Add all selectors to screenManager.allSelectors screenManager.allSelectors.Add(defeatScreenSelector); screenManager.allSelectors.Add(mainScreenSelector); screenManager.allSelectors.Add(castleDefenseSelector); screenManager.allSelectors.Add(riverDefenseSelector); screenManager.allSelectors.Add(castleSiegeSelector); screenManager.allSelectors.Add(victoryScreenSelector); // Set initial maps; These will always be defeatScreen, mainScreen and levelSelect, // since the user spawns on mainScreen screenManager.prevMap = defeatScreen; screenManager.currentMap = mainScreen; screenManager.nextMap = levelSelect; healthChecker = new HealthSystem(ModelManager.player, ModelManager.artificial); attackChecker = new AttackSystem(ref ModelManager.player, ref ModelManager.artificial); attackChecker.linkSystem(projMan); attackChecker.linkContent(Content); movementManager = MovementManager.getInstance(); movementManager.setMap(mainScreen); inputManager = new InputManager(ref modMan); aiManager = AIManager.getInstance(ref mainScreen); mBar = new MoraleBar(ref modMan); gui = new GUIButtons(ref modMan); info = new InfoCard(ref modMan); inputManager.linkGUI(gui); MoraleBar.resourceVal(buildResources); mousePrev = Mouse.GetState(); //Create Player's units //testInitialization(); testCommander(); base.Initialize(); this.IsMouseVisible = true; }
public MoraleBar(ref ModelManager mod) { modMan = mod; }