コード例 #1
0
 public Policy()
 {
     activeState    = new ActiveState(this);
     lapsedState    = new lapsedState(this);
     terminateState = new terminateState(this);
     State          = activeState;
     RiderList      = new List <Rider>();
 }
コード例 #2
0
        public void setBoost(double boostdur, Vector2 boostvel)
        {
            boosttime     = 0;
            boostduration = boostdur;
            boostvelocity = boostvel;
            pstate        = Pstate.boost;
            this.velocity = boostvelocity;

            cjumps = 0;
        }
コード例 #3
0
 //Base constructor
 public Player()
     : base()
 {
     life                = maxlife;
     lives               = 3;
     jumping             = false;
     attacking           = false;
     cjumps              = 0;
     invincible          = false;
     invincibleTime      = invConst;
     cooldowntime        = attackCooldown;
     facing              = Facing.Right;
     cWeapon             = Weapon.Pyrokinesis;
     base.acceleration.Y = basegrav;
     pstate              = Pstate.normal;
 }
コード例 #4
0
        //Basic player update method
        public override void Update(GameTime gtime)
        {
            //base and position related updates
            base.Update(gtime);
            bbox.X   = (int)position.X;
            bbox.Y   = (int)position.Y;
            hitbox.X = (int)(position.X + ((baseR[0].Width - bbox.Width) / 2));
            hitbox.Y = (int)(position.Y + ((baseR[0].Height - bbox.Height) / 2));

            //update dt. dt used for animation calculations, etc.
            deltaTime += gtime.ElapsedGameTime.TotalSeconds;

            //update boost
            if (pstate == Pstate.boost)
            {
                boosttime      += gtime.ElapsedGameTime.TotalSeconds;
                this.velocity.X = boostvelocity.X;
                if (boosttime >= boostduration)
                {
                    pstate = Pstate.normal;
                }
            }

            //temp. invincibility updates
            if (invincible)
            {
                invincibleTime -= gtime.ElapsedGameTime.TotalSeconds;
                if (invincibleTime <= 0)
                {
                    invincible = false;
                }
            }
            //attack status updates
            if (attacking)
            {
                cooldowntime -= gtime.ElapsedGameTime.TotalSeconds;
                if (cooldowntime <= 0)
                {
                    attacking    = false;
                    cooldowntime = attackCooldown;
                }
            }
        }
コード例 #5
0
 public void setState(Pstate state)
 {
     this.State = state;
 }