コード例 #1
0
ファイル: AI.cs プロジェクト: tht5cs/Space-Truck-Defender
 /* 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();
 }
コード例 #2
0
ファイル: Weapon.cs プロジェクト: tht5cs/Space-Truck-Defender
        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)
        }
コード例 #3
0
ファイル: Weapon.cs プロジェクト: tht5cs/Space-Truck-Defender
 //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;
 }
コード例 #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;
        }
コード例 #5
0
ファイル: Actor.cs プロジェクト: tht5cs/Space-Truck-Defender
        //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>();
        }
コード例 #6
0
ファイル: Actor.cs プロジェクト: tht5cs/Space-Truck-Defender
 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;
 }
コード例 #7
0
ファイル: Effect.cs プロジェクト: tht5cs/Space-Truck-Defender
 //what happens when the effect is removed
 // (use this for removing status effects)
 public virtual void OnEnd(Actor a)
 {
 }
コード例 #8
0
ファイル: Effect.cs プロジェクト: tht5cs/Space-Truck-Defender
 //what happens during the tick
 protected virtual void OnTick(Actor a, GameTime gt)
 {
 }
コード例 #9
0
 protected override void OnTick(Actor a, Microsoft.Xna.Framework.GameTime gt)
 {
 }
コード例 #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);
 }
コード例 #11
0
 public void Attach(Actor a)
 {
     Body = a;
 }
コード例 #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();
        }
コード例 #13
0
 public override void Attach(Actor a)
 {
     this.body = a;
     cCounter.SetPosition(a.GetPosition());
 }
コード例 #14
0
 public override void OnEnd(Actor a)
 {
     a.Damage(damage);
 }
コード例 #15
0
ファイル: Actor.cs プロジェクト: tht5cs/Space-Truck-Defender
 //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);
 }
コード例 #16
0
 public override void OnAttach(Actor a)
 {
 }
コード例 #17
0
 public override void OnEnd(Actor a)
 {
     a.Destroy();
 }
コード例 #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);
 }
コード例 #19
0
 public virtual void Attach(Actor a)
 {
     this.Body = a;
 }
コード例 #20
0
 private void ProcessShooting(Actor a)
 {
     if (a.IsShooting())
     {
         var shots = a.GetShots();
         if (shots.Count > 0)
             InsertShots(shots);
     }
 }
コード例 #21
0
ファイル: Effect.cs プロジェクト: tht5cs/Space-Truck-Defender
 //what happens when the effect is added
 public virtual void OnAttach(Actor a)
 {
 }
コード例 #22
0
 //this processes each individual actor and extracts weapon data
 private void UpdateActor(Actor a, GameTime gt)
 {
     ProcessShooting(a);
     a.Update(gt);
 }
コード例 #23
0
ファイル: Effect.cs プロジェクト: tht5cs/Space-Truck-Defender
 //ongoing status effects of the effect
 public void UpdateEffect(Actor a, GameTime gt)
 {
     CurrTime -= (float)gt.ElapsedGameTime.TotalSeconds;
     OnTick(a, gt);
 }
コード例 #24
0
ファイル: AI.cs プロジェクト: tht5cs/Space-Truck-Defender
 //point the AI unit at a given actor
 public void Attach(Actor a)
 {
     this.Body = a;
     this.CurrentState.Attach(a);
 }
コード例 #25
0
 public TargetActor(Actor a)
 {
     body = a;
 }
コード例 #26
0
 public override void Collide(Collidable c)
 {
     this.count++;
     if (c is Actor)
         lastActor = (Actor)c;
 }