public virtual void AI(Player ENEMY, SquareGrid GRID) { rePathTimer.UpdateTimer(); if (pathNodes == null || (pathNodes.Count == 0 && pos.X == moveTo.X && pos.Y == moveTo.Y) || rePathTimer.Test()) { if (!currentlyPathing) { Task repathTask = new Task(() => { currentlyPathing = true; pathNodes = FindPath(GRID, GRID.GetSlotFromPixel(ENEMY.hero.pos, Vector2.Zero)); moveTo = pathNodes[0]; pathNodes.RemoveAt(0); rePathTimer.ResetToZero(); currentlyPathing = false; }); repathTask.Start(); } } else { MoveUnit(); if (Globals.GetDistance(pos, ENEMY.hero.pos) < GRID.slotDims.X * 1.2f) { ENEMY.hero.GetHit(this, 1); dead = true; } } }
public override void Update(Vector2 OFFSET, Player ENEMY, SquareGrid GRID) { spawnTimer.UpdateTimer(); if (spawnTimer.Test()) { SpawnMob(); spawnTimer.ResetToZero(); } base.Update(OFFSET, ENEMY, GRID); }
public virtual List <Vector2> FindPath(SquareGrid GRID, Vector2 ENDSLOT) { pathNodes.Clear(); Vector2 tempStartSlot = GRID.GetSlotFromPixel(pos, Vector2.Zero); List <Vector2> tempPath = GRID.GetPath(tempStartSlot, ENDSLOT, true); if (tempPath == null || tempPath.Count == 0) { } return(tempPath); }
public virtual void Update(Player ENEMY, Vector2 OFFSET, SquareGrid GRID) { if (hero != null) { hero.Update(OFFSET, ENEMY, GRID); } for (int i = 0; i < spawnPoints.Count; i++) { spawnPoints[i].Update(OFFSET, ENEMY, GRID); if (spawnPoints[i].dead) { spawnPoints.RemoveAt(i); i--; } } for (int i = 0; i < units.Count; i++) { units[i].Update(OFFSET, ENEMY, GRID); if (units[i].dead) { ChangeScore(1); units.RemoveAt(i); i--; } } for (int i = 0; i < buildings.Count; i++) { buildings[i].Update(OFFSET, ENEMY, GRID); if (buildings[i].dead) { buildings.RemoveAt(i); i--; } } }
public override void Update(Player ENEMY, Vector2 OFFSET, SquareGrid GRID) { base.Update(ENEMY, OFFSET, GRID); if (Globals.keyboard.GetSinglePress("R")) { if (gold >= 10 && hero.health < 10) { hero.health++; if (hero.health <= 0) { hero.dead = true; } gold -= 10; } } }
public virtual void LoadData(int LEVEL) { XDocument xml = XDocument.Load("XML\\Levels\\Level" + LEVEL + ".xml"); XElement tempElement = null; if (xml.Element("Root").Element("User") != null) { tempElement = xml.Element("Root").Element("User"); } user = new User(1, tempElement); tempElement = null; if (xml.Element("Root").Element("AIPlayer") != null) { tempElement = xml.Element("Root").Element("AIPlayer"); } grid = new SquareGrid(new Vector2(25, 25), new Vector2(-100, -100), new Vector2(Globals.screenWidth + 200, Globals.screenHeight + 200), xml.Element("Root").Element("GridItems")); aIPlayer = new AIPlayer(2, tempElement); List <XElement> sceneItemList = (from t in xml.Element("Root").Element("Scene").Descendants("SceneItem") select t).ToList <XElement>(); Type sType = null; for (int i = 0; i < sceneItemList.Count; i++) { sType = Type.GetType("ShooterGame200." + sceneItemList[i].Element("type").Value, true); sceneItems.Add((SceneItem)(Activator.CreateInstance(sType, new Vector2(Convert.ToInt32(sceneItemList[i].Element("Pos").Element("x").Value, Globals.culture), Convert.ToInt32(sceneItemList[i].Element("Pos").Element("y").Value, Globals.culture)), new Vector2((float)Convert.ToDouble(sceneItemList[i].Element("scale").Value, Globals.culture))))); } }
public override void AI(Player ENEMY, SquareGrid GIRD) { if (ENEMY.hero != null && (Globals.GetDistance(pos, ENEMY.hero.pos) < attackRange * .9f || isAttacking)) { isAttacking = true; attackTimer.UpdateTimer(); if (attackTimer.Test()) { GameGlobals.PassProjectile(new AcidSplash(new Vector2(pos.X, pos.Y), this, new Vector2(ENEMY.hero.pos.X, ENEMY.hero.pos.Y))); attackTimer.ResetToZero(); isAttacking = false; } } else { base.AI(ENEMY, GIRD); } }
public override void Update(Vector2 OFFSET, Player ENEMY, SquareGrid GRID) { base.Update(OFFSET, ENEMY, GRID); }
public override void Update(Player ENEMY, Vector2 OFFSET, SquareGrid GRID) { base.Update(ENEMY, OFFSET, GRID); }
public virtual void Update(Vector2 OFFSET, Player ENEMY, SquareGrid GRID) { base.Update(OFFSET); }
public override void Update(Vector2 OFFSET, Player ENEMY, SquareGrid GRID) { bool checkScoll = false; if (Globals.keyboard.GetPress("A") && pos.X > -50) { pos = new Vector2(pos.X - speed, pos.Y); checkScoll = true; } if (Globals.keyboard.GetPress("D") && pos.X < 1250) { pos = new Vector2(pos.X + speed, pos.Y); checkScoll = true; } if (Globals.keyboard.GetPress("W") && pos.Y > -50) { pos = new Vector2(pos.X, pos.Y - speed); checkScoll = true; } if (Globals.keyboard.GetPress("S") && pos.Y < 750) { pos = new Vector2(pos.X, pos.Y + speed); checkScoll = true; } if (Globals.keyboard.GetSinglePress("D1")) { currentSkill = skills[0]; currentSkill.Active = true; } if (Globals.keyboard.GetSinglePress("D2")) { currentSkill = skills[1]; currentSkill.Active = true; } GameGlobals.CheckScroll(pos); if (checkScoll) { SetAnimationByName("Walk"); } else { SetAnimationByName("Stand"); } rot = Globals.RotateTowards(pos, new Vector2(Globals.mouse.newMousePos.X, Globals.mouse.newMousePos.Y) - OFFSET); if (currentSkill == null) { if (Globals.mouse.LeftClick()) { GameGlobals.PassProjectile(new Fireball(new Vector2(pos.X, pos.Y), this, new Vector2(Globals.mouse.newMousePos.X, Globals.mouse.newMousePos.Y) - OFFSET)); } } else { currentSkill.Update(OFFSET, ENEMY); if (currentSkill.done) { currentSkill.Reset(); currentSkill = null; } } base.Update(OFFSET, ENEMY, GRID); }