/* Board constructor. This Constructor * is used once per actor. One actor only ever * has one AI, though they may go through multiple states * and triggers. */ public AI(AI ai, Actor _body) { //IMP this.CurrentState = ai.CurrentState.Copy(); this.Attach(_body); this.ActiveTriggers = new List<AITrigger>(); this.ResetActiveTriggers(); }
private Actor Projectile; // the things it shoots #endregion Fields #region Constructors public Weapon(Actor _projectile, List<double> _headings, float CDownMax, double _AccOffset) { this.Projectile = _projectile; this.HeadingOffsets = _headings; MaxCooldown = CDownMax; AccOffset = _AccOffset; CurrCooldown = 0; Heading = Math.PI * 3 / 2; //this means straight "up" (no x vector, negative y vector) }
//Copy constructor public Weapon(Weapon w) { Projectile = w.Projectile; this.HeadingOffsets = new List<double>(); foreach (var d in w.HeadingOffsets) HeadingOffsets.Add(d); MaxCooldown = w.MaxCooldown; AccOffset = w.AccOffset; CurrCooldown = 0; Heading = w.Heading; }
//default constructor with default input settings public PlayerControls(Actor _player) { Player = _player; Up = Keys.Up; Down = Keys.Down; Left = Keys.Left; Right = Keys.Right; Shoot = Keys.Z; Special = Keys.X; RespawnTimeMax = 3f; RespawnTimeCurr = RespawnTimeMax; }
//COPY CONSTRUCTOR //for use when creating new instances of an actor public Actor(Actor a, Vector2 _position) { this.Position = _position; this.Graphics = a.Graphics; this.engine = new Engine(a.engine); this.hull = a.hull.Copy(); SetHeading(a.engine.GetHeading()); this.WeaponList = new List<Weapon>(); foreach (Weapon w in a.WeaponList) AddWeapon(w); this.Box = new Hitbox(a.Box, Position); SetCollision(a.GetCollisionSetting()); this.CollisionEffects = new Dictionary<int, Effect>(); foreach (int e in a.CollisionEffects.Keys) AddEffect(a.CollisionEffects[e]); /* Active effects refer to things currently happening * to the actor, and thus are not copied when we create * a new actor */ this.ActiveEffects = new Dictionary<int, Effect>(); }
public List<Actor> GetShots() { List<Actor> retList = new List<Actor>(); foreach (var weapon in WeaponList) { if (weapon.GetCurrentCooldown() <= 0) { var projectile = weapon.GetProjectile(); double projHeading = weapon.GetHeading(); double deviation = weapon.GetAccOffset(); foreach (var h in weapon.GetHeadingOffsets()) { Actor tempProj = new Actor(projectile, this.GetPosition()); double offset = deviation * (random.NextDouble() * 2 - 1); double newHeading = projHeading + offset + h; tempProj.SetHeading(newHeading); tempProj.Go(); retList.Add(tempProj); } weapon.Reload(); } } return retList; }
//what happens when the effect is removed // (use this for removing status effects) public virtual void OnEnd(Actor a) { }
//what happens during the tick protected virtual void OnTick(Actor a, GameTime gt) { }
protected override void OnTick(Actor a, Microsoft.Xna.Framework.GameTime gt) { }
public void NewEnemy() { Random r = new Random(); int xpos = r.Next(50, 400); int ypos = r.Next(50, 400); Vector2 pos = new Vector2(xpos, ypos); Actor a = new Actor(Data.baseEnemyActor, pos); AI ai = new AI(Data.AIHoming, a); InsertCollidable(a); AddAI(ai); }
public void Attach(Actor a) { Body = a; }
private void InitializeBases() { ActorHull = new Hull(75, 5, 2); PlayerHull = new Hull(100, 5, 2); ProjectileHull = new Hull(1, -1, 0); baseDestroy = new EffectDestroy(); baseDamage = new EffectDamage(20); baseEngine1 = new Engine(5, 50); baseEngine2 = new Engine(10, 100); baseEngine3 = new Engine(2, 20); Vector2 v = new Vector2(0, 0); baseFriendlyActor = new Actor(v, 10, baseEngine1, PlayerHull, Device); //baseFriendlyActor.AddEffect(baseDestroy); baseFriendlyActor.SetCollision(0); baseEnemyActor = new Actor(v, 10, baseEngine3, ActorHull, Device); baseEnemyActor.SetCollision(2); //baseEnemyActor.AddEffect(baseDestroy); baseProjectile1 = new Actor(v, 5, baseEngine2, ProjectileHull, Device); baseProjectile1.AddEffect(baseDamage); baseProjectile1.SetCollision(1); //baseProjectile1.AddEffect(baseDestroy); List<double> d = new List<double>(); for (int i = 0; i < 3; i++) d.Add(0); baseWeapon1 = new Weapon(baseProjectile1, d, 0.075f, 0.12); InitializeAIStartStop(); InitializeAICloseStop(); InitializeAIHoming(); }
public override void Attach(Actor a) { this.body = a; cCounter.SetPosition(a.GetPosition()); }
public override void OnEnd(Actor a) { a.Damage(damage); }
//PROJECTILE COPY CONSTRUCTOR /* For this, we do copy active effects. * projectiles might have all sorts of timers, etc. * that are required for proper behavior, so we copy those. */ public Actor(Actor a, Vector2 _position, double _heading) : this(a, _position) { SetHeading(_heading); }
public override void OnAttach(Actor a) { }
public override void OnEnd(Actor a) { a.Destroy(); }
// public void NewPlayer(Vector2 _position) { Actor a = new Actor(Data.baseFriendlyActor, _position); //AI ai = new AI(a); a.AddWeapon(Data.baseWeapon1); PlayerControls p = new PlayerControls(a); //AIList.Add(ai); InsertCollidable(a); AddPlayer(p); }
public virtual void Attach(Actor a) { this.Body = a; }
private void ProcessShooting(Actor a) { if (a.IsShooting()) { var shots = a.GetShots(); if (shots.Count > 0) InsertShots(shots); } }
//what happens when the effect is added public virtual void OnAttach(Actor a) { }
//this processes each individual actor and extracts weapon data private void UpdateActor(Actor a, GameTime gt) { ProcessShooting(a); a.Update(gt); }
//ongoing status effects of the effect public void UpdateEffect(Actor a, GameTime gt) { CurrTime -= (float)gt.ElapsedGameTime.TotalSeconds; OnTick(a, gt); }
//point the AI unit at a given actor public void Attach(Actor a) { this.Body = a; this.CurrentState.Attach(a); }
public TargetActor(Actor a) { body = a; }
public override void Collide(Collidable c) { this.count++; if (c is Actor) lastActor = (Actor)c; }