Exemplo n.º 1
0
 /* 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();
 }
Exemplo n.º 2
0
        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)
        }
Exemplo n.º 3
0
 //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;
 }
Exemplo n.º 4
0
        //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;
        }
Exemplo n.º 5
0
        //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>();
        }
Exemplo n.º 6
0
 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;
 }
Exemplo n.º 7
0
 //what happens when the effect is removed
 // (use this for removing status effects)
 public virtual void OnEnd(Actor a)
 {
 }
Exemplo n.º 8
0
 //what happens during the tick
 protected virtual void OnTick(Actor a, GameTime gt)
 {
 }
Exemplo n.º 9
0
 protected override void OnTick(Actor a, Microsoft.Xna.Framework.GameTime gt)
 {
 }
Exemplo n.º 10
0
 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);
 }
Exemplo n.º 11
0
 public void Attach(Actor a)
 {
     Body = a;
 }
Exemplo n.º 12
0
        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();
        }
Exemplo n.º 13
0
 public override void Attach(Actor a)
 {
     this.body = a;
     cCounter.SetPosition(a.GetPosition());
 }
Exemplo n.º 14
0
 public override void OnEnd(Actor a)
 {
     a.Damage(damage);
 }
Exemplo n.º 15
0
 //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);
 }
Exemplo n.º 16
0
 public override void OnAttach(Actor a)
 {
 }
Exemplo n.º 17
0
 public override void OnEnd(Actor a)
 {
     a.Destroy();
 }
Exemplo n.º 18
0
 //
 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);
 }
Exemplo n.º 19
0
 public virtual void Attach(Actor a)
 {
     this.Body = a;
 }
Exemplo n.º 20
0
 private void ProcessShooting(Actor a)
 {
     if (a.IsShooting())
     {
         var shots = a.GetShots();
         if (shots.Count > 0)
             InsertShots(shots);
     }
 }
Exemplo n.º 21
0
 //what happens when the effect is added
 public virtual void OnAttach(Actor a)
 {
 }
Exemplo n.º 22
0
 //this processes each individual actor and extracts weapon data
 private void UpdateActor(Actor a, GameTime gt)
 {
     ProcessShooting(a);
     a.Update(gt);
 }
Exemplo n.º 23
0
 //ongoing status effects of the effect
 public void UpdateEffect(Actor a, GameTime gt)
 {
     CurrTime -= (float)gt.ElapsedGameTime.TotalSeconds;
     OnTick(a, gt);
 }
Exemplo n.º 24
0
 //point the AI unit at a given actor
 public void Attach(Actor a)
 {
     this.Body = a;
     this.CurrentState.Attach(a);
 }
Exemplo n.º 25
0
 public TargetActor(Actor a)
 {
     body = a;
 }
Exemplo n.º 26
0
 public override void Collide(Collidable c)
 {
     this.count++;
     if (c is Actor)
         lastActor = (Actor)c;
 }