コード例 #1
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");
                }
            }
        }
コード例 #2
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
        }