//copy constructor public Engine(Engine e) { Speed = e.GetSpeed(); Acceleration = e.GetAcceleration(); Heading = 0; IsGoing = false; Velocity = new Vector2(0, 0); //Pattern = new MovementPattern(); }
//standard constructor. location, hitbox radius, and the relevant graphics device. public Actor(Vector2 _position, int _hitRadius, Engine _engine, Hull _hull, GraphicsDevice _Graphics) { this.Position = _position; this.Delete = false; this.Graphics = _Graphics; /* NOTE: this constructor is used * to create base instances of an actor. Copy * constructors are needed when we create new concrete instances of * actors on the gamespace. For this however we can use shared references */ this.hull = _hull; this.engine = _engine; this.WeaponList = new List<Weapon>(); this.CollisionSetting = 0; this.Box = new Hitbox(_hitRadius, this.CollisionSetting, _position, _Graphics); this.CollisionEffects = new Dictionary<int, Effect>(); this.ActiveEffects = new Dictionary<int,Effect>(); }
//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>(); }
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(); }