コード例 #1
0
        public void initialize()
        {
            controlPads = new ControlPad[NUMBER_OF_CONTROLLERS];
            controllersUsed = new bool[NUMBER_OF_CONTROLLERS];
            for (int i = 0; i < NUMBER_OF_CONTROLLERS; ++i)
            {
                controlPads[i] = new ControlPad();
                controllersUsed[i] = false;
            }

            // TODO apaño
            controllersUsed[0] = true;
        }
コード例 #2
0
ファイル: Player.cs プロジェクト: doanhtdpl/naughty-invaders
        void updateSavingiItemsMode(Vector2 direction, ControlPad controls)
        {
            direction.Y = 0.0f;
            if (direction.X > 0.75f) direction.X = 1.0f;
            if (direction.X < -0.75f) direction.X = -1.0f;

            updatePositionNormally(direction);

            checkDash(direction, controls);
        }
コード例 #3
0
ファイル: Player.cs プロジェクト: doanhtdpl/naughty-invaders
        void updateGarlicGunMode(Vector2 direction, ControlPad controls)
        {
            updatePositionNormally(direction);

            garlicGunCooldownTime -= SB.dt;

            // orient the player in the direction of move
            if (controls.getLS().LengthSquared() > 0.01f)
            {
                orientation = Calc.directionToAngle(new Vector2(controls.getLS().X, controls.getLS().Y)) - Calc.PiOver2;
            }

            // controls of garlic gun
            if (controls.getRS().LengthSquared() > 0.01f)
            {
                shotDirection = controls.getRS();
                shotDirection.Normalize();

                if (garlicGunCooldownTime <= 0.0f)
                {
                    playAction("attack");
                    Projectile p = new GarlicGunShot(position, shotDirection);
                    garlicGunCooldownTime = p.cooldown;
                    ProjectileManager.Instance.addProjectile(p);
                    Vector3 particlesDirection = (shotDirection.toVector3() * 700.0f) + Calc.randomVector3(new Vector3(30.0f, 30.0f, 30.0f), new Vector3(30.0f, 30.0f, 30.0f));
                    ParticleManager.Instance.addParticles("playerGarlicShot", position + (shotDirection.toVector3() * 100.0f), particlesDirection, Color.White);

                    SoundManager.Instance.playEffect("garlicGunShot");
                }
            }
        }
コード例 #4
0
ファイル: Player.cs プロジェクト: doanhtdpl/naughty-invaders
        void updateArcadeMode(Vector2 direction, ControlPad controls)
        {
            updatePositionNormally(direction);

            // dash move
            checkDash(direction, controls);

            // fast shot attack
            if (controls.X_pressed())
            {
                //EnemyManager.Instance.renderDebug();
                if (fastShotCooldownTime <= 0.0f)
                {
                    playAction("attack");
                    Projectile p = null;
                    // applies to damage and scale of projectile and particles
                    float projectileFactor = 1.0f;
                    Color projectileColor = Color.White;
                    if (owner.data.skills["plasma"].obtained)
                    {
                        projectileFactor = 1.2f;
                        projectileColor = Color.Yellow;
                    }

                    p = new PlayerFastShot(position, projectileFactor, projectileColor);
                    ParticleManager.Instance.addParticles("playerFastShot", position + new Vector3(0, 50, 0), new Vector3(direction, 0.0f), projectileColor, projectileFactor);

                    fastShotCooldownTime = p.cooldown;
                    ProjectileManager.Instance.addProjectile(p);

                    SoundManager.Instance.playEffect("wishFastShot");
                }
            }
            // big shot attack
            else if (owner.data.skills["powerShot"].obtained)
            {
                if (controls.Y_firstPressed() && bigShotCooldownTime <= 0.0f)
                {
                    bigShotCharging = true;
                }

                if (bigShotCharging)
                {
                    if (controls.Y_pressed())
                    {
                        bigShotChargeTimer += SB.dt;
                        bigShotParticlesTimer -= SB.dt;
                        if (bigShotParticlesTimer < 0.0f)
                        {
                            bigShotParticlesTimer = BIG_SHOT_PARTICLES_TIME;
                            ParticleManager.Instance.addParticles("chargingBigShot", position + new Vector3(0, 50, 0), Vector3.Up, Color.White);
                        }
                    }
                    else if (controls.Y_released())
                    {
                        playAction("attack");
                        // value that goes from 1 to 3 (minimum and maximum charge)
                        float bigShotValue = (MathHelper.Clamp(bigShotChargeTimer, 0.0f, MAX_BIG_SHOT_CHARGE) * 0.1f) + 1.0f;
                        // from 0 to 1
                        float chargeValue = MathHelper.Clamp(bigShotChargeTimer, 0.0f, MAX_BIG_SHOT_CHARGE) / MAX_BIG_SHOT_CHARGE;
                        Projectile p = new PlayerBigShot(position, bigShotValue, chargeValue);
                        ProjectileManager.Instance.addProjectile(p);
                        ParticleManager.Instance.addParticles("playerBigShot", position + new Vector3(0, 50, 0), new Vector3(direction, 0.0f), Color.White,
                            bigShotValue * 0.6f, (int)(5 * bigShotValue), bigShotValue);

                        bigShotCooldownTime = p.cooldown;
                        bigShotChargeTimer = 0.0f;
                        bigShotCharging = false;
                    }
                }
            }
        }
コード例 #5
0
ファイル: Player.cs プロジェクト: doanhtdpl/naughty-invaders
        void checkDash(Vector2 direction, ControlPad controls)
        {
            if (owner.data.skills["dash1"].obtained)
            {
                // update dash velocity
                dashVelocity -= dashVelocity * DASH_FRICTION * SB.dt;

                if (controls.A_firstPressed() && dashCooldownTime <= 0.0f)
                {
                    dashVelocity = direction * DASH_VELOCITY;
                    dashCooldownTime = owner.data.getDashCooldown();
                    SoundManager.Instance.playEffect("dash");
                }
            }
        }
コード例 #6
0
ファイル: Player.cs プロジェクト: doanhtdpl/naughty-invaders
        public void update(ControlPad controls)
        {
            base.update();

            if (updateState == tUpdateState.NoUpdate|| entityState == tEntityState.Dying) return;

            // TODO as there is no player manager, auto delete. There must be a PlayerManager
            if (entityState == tEntityState.ToDelete)
            {
                delete();
            }

            updateInvulnerableAfterHit();

            fastShotCooldownTime -= SB.dt;
            bigShotCooldownTime -= SB.dt;
            dashCooldownTime -= SB.dt;

            updateCameraMove();

            Vector2 direction = Vector2.Zero;
            if (dashVelocity != Vector2.Zero)
            {
                updateDash();
            }
            else // in the middle of a dash the controls are blocked...
            {
                direction = controls.getLS();
            }

            switch (mode)
            {
                case tMode.Arcade:
                    updateArcadeMode(direction, controls);
                    updateMoveAnimations(direction);
                    break;
                case tMode.GarlicGun:
                    updateGarlicGunMode(direction, controls);
                    break;
                case tMode.SavingItems:
                    updateSavingiItemsMode(direction, controls);
                    updateMoveAnimations(direction);
                    break;
            }

            #if DEBUG
            //if (controls.RB_firstPressed())
            //{
            //    EnemySpawnZone esz = new EnemySpawnZone("grape", new Rectangle(-300, 900, 600, 500), 3);
            //    EnemyManager.Instance.addEnemySpawnZone(esz);
            //}
            //if (controls.LT_firstPressed())
            //{
            //    Trigger t = new Trigger();
            //    t.addFunction(true, "isPlayersLastLife", null);
            //    t.addFunction(false, "addParticles", null);
            //    TriggerManager.Instance.addTrigger(t);
            //}
            //if (controls.RT_pressed())
            //{
            //    lifeValue -= 0.01f;
            //}
            #endif
        }
コード例 #7
0
 public void update(ControlPad controls)
 {
     base.update();
 }