Esempio n. 1
0
 public void Shoot(Vector2 spawnPosition, bool direction, Projectile_Trajectory pt = Projectile_Trajectory.MEDIUM)
 {
     GameObjectState            = GameObject_State.Air;
     ActiveAnimation            = Animation_State.jumping;
     Active                     = true;
     Position                   = spawnPosition + new Vector2(50, 15);
     ProjectileTrajectory       = pt;
     Velocity                   = Vector2.Zero;
     GoingRight                 = direction;
     ProjectileState            = Projectile_State.CHARGING;
     PositionRectangle.Location = Position.ToPoint();
     Wait        = 400;
     WaitCounter = 0;
 }
Esempio n. 2
0
        public void Update(Level lvl, GameTime gt, Vector2 OwnerPosition)
        {
            if (Active)
            {
                UpdateCounter += gt.ElapsedGameTime.Milliseconds;
                WaitCounter   += gt.ElapsedGameTime.Milliseconds;
            }

            if (Active && UpdateCounter >= UpdateDelay)
            {
                UpdateCounter = 0;

                switch (ProjectileState)
                {
                case Projectile_State.IN_MOTION:
                    Movement();
                    Gravity();
                    LevelCollision(lvl, gt);
                    if (lvl.LevelProjectileObjectCollision(this, gt))
                    {
                        Active   = false;
                        Position = Vector2.Zero;
                    }
                    Position += Velocity;
                    StaticSpawnableEffect.AddSpawnableEffect(SpawnableEffect_Type.FIRE_SPARK, Position, 75, 1);
                    if (WaitCounter >= Wait * 2)
                    {
                        Active = false;
                    }
                    break;

                case Projectile_State.CHARGING:
                    Position = OwnerPosition;
                    if (WaitCounter >= Wait)
                    {
                        WaitCounter     = 0;
                        ProjectileState = Projectile_State.IN_MOTION;
                        SetProjectileTrajectory();
                        if (!GoingRight)
                        {
                            Velocity.X = -Velocity.X;
                        }
                    }
                    break;
                }
            }
            UpdatePositionRectangle();
            UpdateAnimations(gt);
        }