/* Doesn't look like it, but this is a Copy Constructor */ public EnemyPlaneObj(EnemyPlaneObj rhs) : this(rhs.sprite, (int)rhs.position.X, (int)rhs.position.Y, (int)rhs.velocity.X, (int)rhs.velocity.Y, rhs.srcRect.Width, rhs.srcRect.Height, rhs.MoveRate, rhs.hp, (rhs.Path != null) ? rhs.Path.createMirror(false, false) : null) { foreach(Behavior behavior in rhs.Behaviors) Behaviors.Add(behavior.clone(this)); currentBehavior = rhs.currentBehavior.clone(this); foreach(BulletObj bulletObj in rhs.BulletType) BulletType.Add(bulletObj); }
// returns a clone of this object with newParent reference public abstract Behavior clone(EnemyPlaneObj newParent);
public Behavior(EnemyPlaneObj parent) { this.parent = parent; rand = new Random((int)DateTime.Now.Ticks); }
public ShootingCircleBehavior(EnemyPlaneObj parent) : base(parent) { behaviorState = BehaviorState.ShootCircle; }
public override Behavior clone(EnemyPlaneObj newParent) { return new ShootingTargetBehavior(newParent); }
public ShootingTargetBehavior(EnemyPlaneObj parent) : base(parent) { behaviorState = BehaviorState.ShootTarget; }
private void convertEnemyPlaneObj(XmlTag element) { string key = ""; PlaneObj baseObj = null; EnemyPlaneObj value = null; int x, y; x = y = 0; Path enemyPath = null; foreach (KeyValuePair<string, string> attrib in element.Attributes) { if (attrib.Key == "id") key = attrib.Value; else if (attrib.Key == "planeobj") baseObj = planeObjs[attrib.Value]; else if (attrib.Key == "x") x = Int32.Parse(attrib.Value); else if (attrib.Key == "y") y = Int32.Parse(attrib.Value); else if (attrib.Key == "path") if(paths.ContainsKey(attrib.Value)) enemyPath = paths[attrib.Value].createMirror(false, false); } value = new EnemyPlaneObj(baseObj.sprite, x, y, (int)baseObj.velocity.X, (int)baseObj.velocity.Y, baseObj.srcRect.Width, baseObj.srcRect.Height, baseObj.MoveRate, baseObj.hp, enemyPath); foreach (BulletObj bullet in baseObj.BulletType) value.addBulletType(bullet); value.ID = key; enemyPlaneObjs.Add(key, value); }
public LinearBehavior(EnemyPlaneObj parent) : base(parent) { behaviorState = BehaviorState.LinearBehavior; }
public SelfDestructingBehavior(EnemyPlaneObj parent) : base(parent) { behavior = new ChasingBehavior(parent); behaviorState = BehaviorState.SelfDestruct; }
public override Behavior clone(EnemyPlaneObj newParent) { return new ChasingBehavior(newParent); }
private float yDistance = 0; // negative = hero is in front of parent #endregion Fields #region Constructors public ChasingBehavior(EnemyPlaneObj parent) : base(parent) { behaviorState = BehaviorState.Chase; }
public override Behavior clone(EnemyPlaneObj newParent) { return new BehaviorController(newParent); }
public BehaviorController(EnemyPlaneObj parent) : base(parent) { behaviorState = BehaviorState.BehaviorController; timer = new TimeEventHandler(); }
/* Needs an improvement, something like parentRef.behaviors.Add(new Behavior(behaviors[value], parentRef) sould eliminate this routine of if/elseif checkings; */ private Behavior getBehaviorFromString(string value, ref EnemyPlaneObj parentRef) { if (value.ToLower() == "shootstraight") return new ShootingStraightBehavior(parentRef); else if (value.ToLower() == "shoottarget") return new ShootingTargetBehavior(parentRef); else if (value.ToLower() == "shootcircle") return new ShootingCircleBehavior(parentRef); else if (value.ToLower() == "shootstraightangle") return new ShootingStraightAngleBehavior(parentRef); else if (value.ToLower() == "evade") return new EvadingBehavior(parentRef); else if (value.ToLower() == "chase") return new ChasingBehavior(parentRef); else if (value.ToLower() == "selfdestruct") return new SelfDestructingBehavior(parentRef); else if (value.ToLower() == "shoot") return new ShootingBehavior(parentRef); else if (value.ToLower() == "behaviorcontroller") return new BehaviorController(parentRef); else if (value.ToLower() == "linear") return new LinearBehavior(parentRef); return null; }
private void convertEnemyPlaneObject(XmlTag element) { Texture2D img = null; int x, y, vx, vy, moverate, hp, width, height; x = y = vx = vy = moverate = hp = width = height = 0; EnemyPlaneObj value = null; Path enemyPath = null; foreach (KeyValuePair<string, string> attrib in element.Attributes) { if (attrib.Key == "src") img = (Texture2D)Texture.FromFile(_GLOBAL.Graphics.GraphicsDevice, attrib.Value);// dynamic loading else if (attrib.Key == "x") x = Int32.Parse(attrib.Value); else if (attrib.Key == "y") y = Int32.Parse(attrib.Value); else if (attrib.Key == "vx") vx = Int32.Parse(attrib.Value); else if (attrib.Key == "vy") vy = Int32.Parse(attrib.Value); else if (attrib.Key == "width") width = (attrib.Value == "default") ? img.Width : Int32.Parse(attrib.Value); // default value else if (attrib.Key == "height") height = (attrib.Value == "default") ? img.Height : Int32.Parse(attrib.Value); // default value else if (attrib.Key == "moverate") moverate = Int32.Parse(attrib.Value); else if (attrib.Key == "hp") hp = Int32.Parse(attrib.Value); else if (attrib.Key == "path") enemyPath = paths[attrib.Value].createMirror(false, false); } value = new EnemyPlaneObj(img, x, y, vx, vy, width, height, moverate, hp, enemyPath); enemyPlaneObjs.Add(value.ID, value); }
public ShootingStraightAngleBehavior(EnemyPlaneObj parent) : base(parent) { behaviorState = BehaviorState.ShootStraightAngle; }
public override Behavior clone(EnemyPlaneObj newParent) { return new ShootingStraightAngleBehavior(newParent); }
public override Behavior clone(EnemyPlaneObj newParent) { return new SelfDestructingBehavior(newParent); }
public override Behavior clone(EnemyPlaneObj newParent) { return new LinearBehavior(newParent); }
private float yDistance = 0; // negative = hero is in front of parent #endregion Fields #region Constructors public EvadingBehavior(EnemyPlaneObj parent) : base(parent) { behaviorState = BehaviorState.Evade; }