public Projectile(Vector2 position, int damage, GameObject target, int health = 1, int attackRange = 0) : base(health, position, damage, attackRange) { this.target = target; this.isMoving = true; //this.attackWait = 60; collided = false; }
public void isColliding(GameObject unit) { if (this.selectionSpace.Intersects(unit.Bounds) && this.isInteractable == true) { this.setOccupied(true); } else this.setOccupied(false); }
public Arrow(Vector2 position, int damage, GameObject target, int health = 1, int attackRange = 0) : base(position, damage, target, health, attackRange) { this.damage = 1; this.position = position; this.moveSpeed = 3; //attackWait = 300; }
public void create(String s, GameObject start, GameObject obj) { if(s=="arrow") { // Arrow arr=new Arrow(obj, start); //need to add arrow to projectileManager } }
public override void Attack(GameObject target, ContentManager content, ProjectileManager projMan) { //attackSound(content); Vector2 corrected = Vector2.Add(position, new Vector2(16, 16)); Projectile projectile = new Rocktile(corrected, 100, target, 100, 0); Vector2 direction = MovementManager.getNormalizedVector(projectile.position, target.position); projectile.setDestination(direction, target.position); projectile.LoadContent(content); projMan.proj.Add(projectile); this.animateState = "attack"; this.animateTime = 0; }
// TyDo: Create a new projectile that deals less damage than an arrow, but for now just make it the fireball // Attack the target (not homing). Create a new object projectile sent in the direction of target // The new attack code public override void Attack(GameObject target, ContentManager content, ProjectileManager projMan) { this.soundEffect = content.Load<SoundEffect>("fireball.wav"); soundEffect.Play(); Vector2 corrected = Vector2.Add(position, new Vector2(16, 16)); Projectile projectile = new Iceball(corrected, 0, target, 1, 0); Vector2 direction = MovementManager.getNormalizedVector(projectile.position, target.position); projectile.setDestination(direction, target.position); projectile.LoadContent(content); projMan.proj.Add(projectile); this.animateState = "attack"; this.animateTime = 0; }
public override void Attack(GameObject target, ContentManager content, ProjectileManager projMan) { base.Attack(target, content, projMan); if (stealthTimer.Enabled) { //stealthTimer.Start(); foreach (GameObject unit in ModelManager.artificial) { if (unit.aiTarget == this) unit.aiTarget = null; } } this.animateState = "attack"; this.animateTime = 0; }
public override void Attack(GameObject target, ContentManager content, ProjectileManager projMan) { //if (!juggernautTimer.Enabled) //{ // damage = 15; // attackSpeed = 320; // moveSpeed = 1; // specialAttack = false; // attackRange = 50; //} attackSound(content); target.health -= this.damage; this.animateState = "attack"; this.animateTime = 0; }
// On skill key press, conjur a fireball and send it to target location // TyNote: Create a fireball unit and set destination to target location (not homing). Dies on first collision or at end of path. // TyDo: Fireball has a life timer // TyDo: Make this a spell. For now, it's implemented as the autoattack public void fireball(ProjectileManager projMan, ContentManager content, GameObject target, Vector2 destination) { Fireball fireballTest = null; if (!fireballTimer.Enabled) { fireballTimer.Start(); fireballTest = new Fireball(this.position,10, target, 1, 0); this.myArrow = fireballTest; Vector2 direction = MovementManager.getNormalizedVector(this.position, destination); fireballTest.setDestination(direction, destination); fireballTest.LoadContent(content); projMan.proj.Add(fireballTest); this.animateState = "attack"; this.animateTime = 0; } }
public static void info(GameObject unit) { cost = getCost(unit.type); name = unit.type; texture = unit.texture; descrip = pullText(unit.type); range = unit.attackRange.ToString(); if (unit.GetType().BaseType == typeof(Mobile)) movespeed = ((Mobile)unit).moveSpeed.ToString(); else movespeed = "0"; damage=unit.damage.ToString(); health=unit.basehealth.ToString(); attackspeed=unit.attackSpeed.ToString(); special=specialText(unit.type); }
// The new attack code public override void Attack(GameObject target, ContentManager content, ProjectileManager projMan) { //if (!rapidFireTimer.Enabled) //{ // specialAttack = false; // attackSpeed = 180; //} attackSound(content); Vector2 corrected = Vector2.Add(position, new Vector2(16, 16)); Projectile projectile = new Arrow(corrected, 100, target, 100, 0); myArrow = projectile; Vector2 direction = MovementManager.getNormalizedVector(projectile.position, target.position); projectile.setDestination(direction, target.position); projectile.LoadContent(content); projMan.proj.Add(projectile); this.animateState = "attack"; this.animateTime = 0; }
//public string state; //public Texture2D image; public Iceball(Vector2 position, int damage, GameObject target, int health = 1, int attackRange = 0) : base(position, damage, target, health, attackRange) { this.position = position; this.moveSpeed = 6; this.type = "ICEBALL"; this.collisionType = "homing"; //this.health = 1000; //this.damage = 6; //this.attackSpeed = 0; //this.attackRange = 1; //this.moveSpeed = 20; //this.position = position; //this.animationState // The actual animation the object is performing (moving left, moving right, attacking, etc.) //this.animationFrame // Keeps track of the animation frame the object is on //this.animationTime // Calculates how much time has passed since animation began //this.attackReady = true; //this.collisionType = "object"; }
public void pursue(GameObject unit) { //Unit is the AI unit set to pursue List<GameObject> attackParty = new List<GameObject>(); unit.selected = true; attackParty.Add(unit); int size = random.Next(1, aiUnits.Count); if (String.Compare(unit.type, "COMMANDER",true) == 0) size = aiUnits.Count; special(unit); for (int x = 0; x < size; x++) // "Count/3" was breaking the game once a user got the enemy units to less than 3 { GameObject gunit = aiUnits[x]; if (gunit.aiTarget == null && gunit.GetType().BaseType == typeof(Mobile))//if doesn't have target already and can move { special(gunit); gunit.aiTarget = unit.aiTarget; gunit.selected = true; attackParty.Add(gunit);//band with this guy } } MovementManager.changeDestination(attackParty, unit.aiTarget.position); //foreach (GameObject cunit in attackParty) //{ // if (cunit.GetType().BaseType == typeof(Mobile)) // { // ((Mobile)cunit).setDestination( unit.aiTarget.position); // List<Tile> newList = new List<Tile>(); // ((Mobile)cunit).pathList.Clear(); // ((Mobile)cunit).pathList.AddRange(myMap.GetPath(unit.position, ((Mobile)cunit).destination, newList)); // ((Mobile)cunit).isMoving = true; // ((Mobile)cunit).isPaused=false; // } //} }
public override void Attack(GameObject target, ContentManager content, ProjectileManager projMan) { attackSound(content); Vector2 corrected = Vector2.Add(position, new Vector2(16, 16)); Projectile projectile = new Arrow(corrected, 100, target, 100, 0); projectile.damage = this.damage; Vector2 direction = MovementManager.getNormalizedVector(projectile.position, target.position); projectile.setDestination(direction, target.position); projectile.LoadContent(content); projMan.proj.Add(projectile); }
public void explore(GameObject unit) { //if (random.NextDouble()*100<=4) //{ List<GameObject> searchParty = new List<GameObject>(); unit.selected = true; searchParty.Add(unit); int randpull = random.Next(0, aiUnits.Count); for (int x = 0; x < randpull; x++) { GameObject gunit = aiUnits[x]; if (gunit.aiTarget == null && gunit.GetType().BaseType == typeof(Mobile)) { searchParty.Add(gunit); gunit.selected = true; } } Vector2 explore = new Vector2(random.Next(0, 704), random.Next(600, 1024)); MovementManager.changeDestination(searchParty, explore); //foreach (GameObject cunit in searchParty) //{ //((Mobile)cunit).setDestination(MovementManager.getNormalizedVector(cunit.position,explore), explore); //((Mobile)cunit).setDestination(explore); //List<Tile> newList = new List<Tile>(); //((Mobile)cunit).pathList.Clear(); //((Mobile)cunit).pathList.AddRange(myMap.GetPath(cunit.position, ((Mobile)cunit).destination, newList)); //((Mobile)cunit).isMoving = true; // } //} }
public int getCost(GameObject gobj) { switch (gobj.GetType().Name.ToString()) { case "Archer": return Archer.cost; case "Tower": return Tower.cost; case "Warrior": return Warrior.cost; case "PAWN": return Pawn.cost; case "APPRENTICE": return Apprentice.cost; case "COMMANDER": return Commander.cost; case "CATAPULT": return Catapult.cost; case "ROGUE": return Rogue.cost; case "CLERIC": return Cleric.cost; } return 0; }
public void special(GameObject unit) { switch (unit.type) { case "ARCHER": ((Archer)unit).rapidFire(); break; case "COMMANDER": ((Commander)unit).rally(); break; case "ROGUE": ((Rogue)unit).stealth(); break; case "WARRIOR": ((Warrior)unit).juggernaut(); break; case "BOSS": ((BossUnit)unit).pound(); break; } }
// Issue attack. Alpha method that damages target. No other skills or actions are implemented in the Alpha Version public virtual void Attack(GameObject target, ContentManager content, ProjectileManager projMan) { attackSound(content); target.health -= this.damage; this.animateState = "attack"; this.animateTime = 0; }
public Boolean IsInRange(GameObject target) { double distance; distance = (int) Math.Sqrt(Math.Pow((this.position.X - target.position.X), 2) + Math.Pow((this.position.Y - target.position.Y), 2)); if (distance <= this.attackRange) { //aiTarget = target; return true; } else return false; }
//public abstract void Die(); // Return true if this object collides with target object public bool collidesWith(GameObject target) { if (this.Bounds.Intersects(target.Bounds)) return true; else return false; }
public Tile GetContainingTile(GameObject myObject) { float xPosition = myObject.Bounds.Center.X; float yPosition = myObject.Bounds.Center.Y; //List<Tile> intersectingTiles = new List<Tile>(); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { if(xPosition >= mapTiles[y,x].origin.X && xPosition <= mapTiles[y,x].origin.X + mapTiles[y,x].width && yPosition >= mapTiles[y,x].origin.Y && yPosition <= mapTiles[y,x].origin.Y + mapTiles[y,x].width ) { return mapTiles[y, x]; } } } return null; }
public override void Attack(GameObject target, ContentManager content, ProjectileManager projMan) { Vector2 corrected = Vector2.Add(position, new Vector2(16, 16)); for (int x = 0; x < 4; x++) { Fireball projectile = new Fireball(corrected, 0, this, 1, 0); Vector2 direction = MovementManager.getNormalizedVector(projectile.position, circleFire(x)); projectile.setDestination(direction, circleFire(x)); projectile.LoadContent(content); projMan.proj.Add(projectile); } }