コード例 #1
0
ファイル: X20BoostService.cs プロジェクト: OlegGelezcov/boscs
        private void SetState(BoostState newState)
        {
            if (State != newState)
            {
                BoostState oldState = State;
                State = newState;
                switch (State)
                {
                case BoostState.ReadyToActivate: {
                }
                break;

                case BoostState.Active: {
                    ActiveTimer = Services.ResourceService.Defaults.x20BoostActiveInterval;
                }
                break;

                case BoostState.Locked: {
                    CooldownTimer = Services.ResourceService.Defaults.x20BoostStartCooldown * Mathf.Pow(2, NextCooldownPowerOfTwo);
                    NextCooldownPowerOfTwo++;
                    CooldownInterval = CooldownTimer;
                }
                break;
                }

                GameEvents.OnBoostX20StateChanged(oldState, State);
            }
        }
コード例 #2
0
 private void StopBoost()
 {
     speedAdjustorOn = false;
     //masterComp.speedCont.maxSpeedAdjustors.RemoveAdjustor(BOOST_ADJUSTER_NAME);
     masterComp.speedCont.RemoveMassAdjustor(BOOST_ADJUSTER_NAME);
     state = BoostState.READY;
 }
コード例 #3
0
 private void OnMegaboostStateChanged(BoostState oldState, BoostState newState)
 {
     if (IsLoaded)
     {
         SendEventToNonCompleted(new TutorialEventData(TutorialEventName.MegaboostStateChanged, newState));
     }
 }
コード例 #4
0
 private void CheckRemainingBoostCooldown()
 {
     remainingBoostCooldown -= Time.deltaTime;
     if (remainingBoostCooldown <= 0)
     {
         boostState = BoostState.Ready;
     }
 }
コード例 #5
0
 private void BoostShip()
 {
     playerStats.VerticalInputAcceleration   *= boostModifier;
     playerStats.HorizontalInputAcceleration *= boostModifier;
     playerStats.MaxSpeed         *= boostModifier;
     playerStats.MaxRotationSpeed *= boostModifier;
     remainingBoostTime            = boostTime;
     boostState = BoostState.Boosting;
 }
コード例 #6
0
 private void StopShipBoost()
 {
     playerStats.VerticalInputAcceleration   /= boostModifier;
     playerStats.HorizontalInputAcceleration /= boostModifier;
     playerStats.MaxSpeed         /= boostModifier;
     playerStats.MaxRotationSpeed /= boostModifier;
     boostState             = BoostState.Cooldown;
     remainingBoostCooldown = boostCooldown;
 }
コード例 #7
0
 void Start()
 {
     _lockTransform = deathCanvas.transform.rotation;
     _pVar          = GetComponent <PlayerVariables>();
     _phy           = GetComponent <CustomPhysics>();
     _normalState   = new NormalState(_pVar);
     _boostState    = new BoostState(_pVar);
     _currentState  = _normalState;
     _image         = deathCanvas.GetComponentInChildren <Image>();
 }
コード例 #8
0
ファイル: MainLogic.cs プロジェクト: jjcat/Air_Rush
    public void BoostUp()
    {
        if(_boostState == BoostState.BoostOn)
        {
            return;
        }
        if(_power<100.0f)
        {
            return;
        }

        _boostState = BoostState.BoostOn;
        OnBoostOn();
        _boostTime  = 6.0f;
    }
コード例 #9
0
    private void InitializeAirMachine()
    {
        AerialState      s_aerial      = new AerialState(ref c_playerData, ref c_collisionData, ref c_aerialMoveData, ref c_positionData);
        GroundedState    s_grounded    = new GroundedState(ref c_playerData, ref c_aerialMoveData, ref c_collisionData, ref c_positionData);
        BoostState       s_boost       = new BoostState(ref c_playerData, ref c_aerialMoveData, ref c_collisionData, ref c_positionData, ref c_turnData);
        JumpChargeState  s_jumpCharge  = new JumpChargeState(ref c_playerData, ref c_positionData, ref c_collisionData, ref c_aerialMoveData, ref cart_incr);
        AirDisabledState s_airDisabled = new AirDisabledState();

        c_airMachine = new StateMachine(StateRef.GROUNDED);
        c_airMachine.AddState(s_grounded, StateRef.GROUNDED);
        c_airMachine.AddState(s_aerial, StateRef.AIRBORNE);
        c_airMachine.AddState(s_jumpCharge, StateRef.CHARGING);
        c_airMachine.AddState(s_airDisabled, StateRef.DISABLED);
        c_airMachine.AddState(s_boost, StateRef.GROUNDED_BOOSTING);
    }
コード例 #10
0
ファイル: BoostFlag.cs プロジェクト: van01/TapRunner
 // Update is called once per frame
 public void Update()
 {
     switch (GameManager.Instance.getState())
     {
     case STATE.STATE_GAME:
         if (m_eBoostState == BoostState.NONE)
         {
             m_fBoostCheck += Time.deltaTime;
             if (m_fBoostCheck > m_fBoostEndTime)
             {
                 Debug.Log("boost failed");
                 m_eBoostState = BoostState.FAILED;
             }
         }
         break;
     }
 }
コード例 #11
0
ファイル: BoostFlag.cs プロジェクト: van01/TapRunner
    public void checkBoost()
    {
        if (m_eBoostState != BoostState.NONE)
        {
            return;
        }

        switch (GameManager.Instance.getState())
        {
        case STATE.STATE_READY:
            Debug.Log("boost failed at Ready");
            m_eBoostState = BoostState.FAILED;
            break;

        case STATE.STATE_GAME:
            Debug.Log("boost on");
            m_eBoostState = BoostState.ON;
            GameManager.Instance.setBoost();
            break;
        }
    }
コード例 #12
0
ファイル: MegaboostState.cs プロジェクト: OlegGelezcov/boscs
 public override void OnEvent(IBosServiceCollection context, TutorialEventData data)
 {
     if (IsActive)
     {
         if (isDialogShowed)
         {
             if (data.EventName == TutorialEventName.MegaBoostActivated)
             {
                 MoveToRepeatFingerState(context);
             }
             else if (data.EventName == TutorialEventName.MegaboostStateChanged)
             {
                 BoostState state = (BoostState)data.UserData;
                 if (state == BoostState.ReadyToActivate || state == BoostState.Active)
                 {
                     MoveToRepeatFingerState(context);
                 }
             }
         }
     }
 }
コード例 #13
0
ファイル: Player.cs プロジェクト: Nagisa-Ogawa/Runbrella
    /// <summary>
    /// 初期化処理
    /// </summary>
    void Awake()
    {
        // 子オブジェクトを取得
        feverEffect       = transform.Find("FeverEffect").GetComponent <ParticleSystem>();
        boostEffect       = transform.Find("BoostEffect").GetComponent <ParticleSystem>();
        chargeingEffect   = transform.Find("ChargeEffects/Charging").GetComponent <ParticleSystem>();
        chargeSignal      = transform.Find("ChargeEffects/ChargeSignal").GetComponent <ParticleSystem>();
        chargePauseEffect = transform.Find("ChargeEffects/ChargePause").GetComponent <ParticleSystem>();
        chargeMaxEffect   = transform.Find("ChargeEffects/ChargeMax").GetComponent <ParticleSystem>();

        // アタッチされているステートを取得
        aerialState     = GetComponent <AerialState>();
        afterSlideState = GetComponent <AfterSlideState>();
        boostState      = GetComponent <BoostState>();
        downState       = GetComponent <DownState>();
        glideState      = GetComponent <GlideState>();
        idleState       = GetComponent <IdleState>();
        runState        = GetComponent <RunState>();
        slideState      = GetComponent <SlideState>();
        afterGoalState  = GetComponent <AfterGoalState>();

        // ステートを管理するクラスを取得
        playerStateManager = new PlayerStateManager();
    }
コード例 #14
0
    public void StartBoost()
    {
        if (!disabled)
        {
            if (state == BoostState.BOOSTING)
            {
                StopBoost();
            }

            state = BoostState.BOOSTING;

            speedAdjustorOn = true;

            // determine adjusted direction of the ram
            boostDirection = transform.up;
            coolDownTimer.Activate();

            // apply boost to ship and increase speed cap
            speedWhenBoostStarted = masterComp.speedCont.GetVelocity().magnitude *Vector2.Dot(boostDirection, masterComp.speedCont.GetVelocity().normalized);
            masterComp.speedCont.SetVelocity(masterComp.speedCont.GetVelocity() + boostDirection * boostSpeed);
            masterComp.speedCont.maxSpeedAdjustors.SetAdjustor(BOOST_ADJUSTER_NAME, boostSpeed);
            masterComp.speedCont.SetMassAdjustor(BOOST_ADJUSTER_NAME, bonusMass);
        }
    }
コード例 #15
0
        private void SetState(BoostState newState)
        {
            if (State != newState)
            {
                BoostState oldState = State;
                State = newState;
                switch (State)
                {
                case BoostState.ReadyToActivate: { }
                break;

                case BoostState.Active: {
                    ActiveTimer = kActiveInterval;
                }
                break;

                case BoostState.Locked: {
                    CooldownTimer = kCooldownInterval;
                }
                break;
                }
                GameEvents.OnBoostX20StateChanged(oldState, State);
            }
        }
コード例 #16
0
    private void FixedUpdate()
    {
        Collider2D standingOn = groundDown.DoRaycast(transform.position);
        bool       grounded   = standingOn != null;

        if (grounded && lastGrounded == false)
        {
            audioManager.fx.PlayOneShot(landFX, 0.25f);
        }
        lastGrounded = grounded;

        switch (jumpState)
        {
        case JumpState.None:
            /*if(grounded && jumpStartTimer > 0) {
             *  jumpStartTimer = 0;
             *  jumpState = JumpState.Holding;
             *  jumpHoldTimer = 0;
             *  velocity.y = jumpStartSpeed;
             *  jumpSFX.Play();
             * }*/
            if (!stunned)
            {
                if (jumpStartTimer > 0)
                {
                    jumpStartTimer = 0;
                    jumpState      = JumpState.Holding;
                    jumpHoldTimer  = 0;
                    velocity.y     = jumpStartSpeed;
                    //jumpSFX.Play();
                }
            }
            break;

        case JumpState.Holding:
            jumpHoldTimer += Time.deltaTime;
            if (jumpInputDown == false || jumpHoldTimer >= jumpMaxHoldPeriod)
            {
                jumpState  = JumpState.None;
                velocity.y = Mathf.Lerp(jumpMinSpeed, jumpStartSpeed, jumpHoldTimer / jumpMaxHoldPeriod);

                // Lerp!
                //float p = jumpHoldTimer / jumpMaxHoldPeriod;
                //velocity.y = jumpMinSpeed + (jumpStartSpeed - jumpMinSpeed) * p;
            }
            break;
        }

        switch (dashState)
        {
        case DashState.None:
            if (!stunned)
            {
                if (dashStartTimer > 0)
                {
                    dashStartTimer = 0;
                    dashState      = DashState.Holding;
                    dashHoldTimer  = 0;
                    //dashFX.Play();
                }
            }
            break;

        case DashState.Holding:
            dashHoldTimer += Time.deltaTime;
            if (dashInputDown == false || dashHoldTimer >= dashMaxHoldPeriod)
            {
                dashState = DashState.None;
            }
            break;
        }

        switch (boostState)
        {
        case BoostState.None:
            if (!stunned)
            {
                if (boostStartTimer > 0)
                {
                    boostStartTimer = 0;
                    boostState      = BoostState.Holding;
                    boostHoldTimer  = 0;
                    //boostFX.Play();
                }
            }
            break;

        case BoostState.Holding:
            boostHoldTimer += Time.deltaTime;
            if (boostInputDown == false || boostHoldTimer >= boostMaxHoldPeriod)
            {
                boostState = BoostState.None;
            }
            break;
        }

        switch (eraseState)
        {
        case EraseState.None:
            if (!stunned)
            {
                if (eraseStartTimer > 0)
                {
                    eraseStartTimer = 0;
                    eraseState      = EraseState.Holding;
                    erasehHoldTimer = 0;
                    //eraseFX.Play();
                }
            }
            break;

        case EraseState.Holding:
            erasehHoldTimer += Time.deltaTime;
            if (eraseInputDown == false || erasehHoldTimer >= eraseMaxHoldPeriod)
            {
                eraseState = EraseState.None;
            }
            break;
        }

        switch (crouchState)
        {
        case CrouchState.None:
            if (grounded && !stunned)
            {
                if (crouchStartTimer > 0)
                {
                    crouchStartTimer    = 0;
                    crouchState         = CrouchState.Holding;
                    crouchHoldTimer     = 0;
                    boxCollider.enabled = false;
                }

                if (dropPlatform != null)
                {
                    dropPlatform.enabled = true;
                }
            }
            break;

        case CrouchState.Holding:
            crouchHoldTimer += Time.deltaTime;
            dropPlatform     = lastStandingOn;

            if (dropPlatform.gameObject.tag == "Droppable")
            {
                if (crouchInputDown == false || stunned)
                {
                    crouchState         = CrouchState.None;
                    boxCollider.enabled = true;
                }
                else if (crouchHoldTimer >= crouchDropPeriod)
                {
                    crouchState            = CrouchState.None;
                    boxCollider.enabled    = true;
                    lastStandingOn.enabled = false;
                }
            }
            else
            {
                if (crouchInputDown == false || stunned)
                {
                    crouchState         = CrouchState.None;
                    boxCollider.enabled = true;
                }
            }

            break;
        }

        float horizInput        = Input.GetAxisRaw("Horizontal");
        int   wantedDirection   = GetSign(horizInput);
        int   velocityDirection = GetSign(velocity.x);

        if (wantedDirection != 0)
        {
            if (wantedDirection != velocityDirection)
            {
                if (boost <= 0)
                {
                    velocity.x = horizSnapSpeed * wantedDirection;
                    //audioManager.fx.PlayOneShot(startMoveFX, 0.3f);
                }
                else
                {
                    if (dashState == DashState.Holding)
                    {
                        dash += (int)dashSpeed;

                        if (dash < 32)
                        {
                            if (!spriteRenderer.flipX)
                            {
                                velocity.x = dash;
                            }
                            else if (spriteRenderer.flipX)
                            {
                                velocity.x = -dash;
                            }
                        }
                        else
                        {
                            velocity.x = Mathf.MoveTowards(velocity.x, 0, 75 * Time.deltaTime);
                        }
                    }
                    else
                    {
                        velocity.x = 0;
                    }
                }
            }
            else
            {
                if (!stunned)
                {
                    if (dashState == DashState.Holding)
                    {
                        dash += (int)dashSpeed;

                        if (dash < 32)
                        {
                            if (!spriteRenderer.flipX)
                            {
                                velocity.x = dash;
                            }
                            else if (spriteRenderer.flipX)
                            {
                                velocity.x = -dash;
                            }
                        }
                        else
                        {
                            velocity.x = Mathf.MoveTowards(velocity.x, 0, 75 * Time.deltaTime);
                        }
                    }
                    else if (boostState == BoostState.Holding)
                    {
                        boost     += (int)boostSpeed;
                        velocity.x = 0;

                        if (boost <= 36)
                        {
                            velocity.y = boost;
                        }
                        else
                        {
                            velocity.y = Mathf.MoveTowards(velocity.y, 0, 125 * Time.deltaTime);
                        }
                    }
                    else
                    {
                        if (boost <= 0)
                        {
                            dash       = 0;
                            boost      = 0;
                            velocity.x = Mathf.MoveTowards(velocity.x, horizMaxSpeed * wantedDirection, horizSpeedUpAccel * Time.deltaTime);
                        }
                        else
                        {
                            velocity.x = 0;
                            velocity.y = Mathf.MoveTowards(velocity.y, 0, 200 * Time.deltaTime);
                        }
                    }
                }
            }
        }
        else
        {
            if (dashState == DashState.Holding)
            {
                dash += (int)dashSpeed;

                if (dash < 32)
                {
                    if (!spriteRenderer.flipX)
                    {
                        velocity.x = dash;
                    }
                    else if (spriteRenderer.flipX)
                    {
                        velocity.x = -dash;
                    }
                }
                else
                {
                    velocity.x = Mathf.MoveTowards(velocity.x, 0, 75 * Time.deltaTime);
                }
            }
            else if (boostState == BoostState.Holding)
            {
                boost     += (int)boostSpeed;
                velocity.x = 0;

                if (boost <= 36)
                {
                    velocity.y = boost;
                }
                else
                {
                    velocity.y = Mathf.MoveTowards(velocity.y, 0, 125 * Time.deltaTime);
                }
            }
            else
            {
                if (dash > 0)
                {
                    dash      -= (int)dashSpeed;
                    velocity.x = Mathf.MoveTowards(velocity.x, 0, 150 * Time.deltaTime);
                }
                else
                {
                    if (boost > 0)
                    {
                        velocity.x = 0;
                        velocity.y = Mathf.MoveTowards(velocity.y, 0, 200 * Time.deltaTime);
                    }
                    else
                    {
                        dash       = 0;
                        boost      = 0;
                        velocity.x = Mathf.MoveTowards(velocity.x, 0, horizSpeedDownAccel * Time.deltaTime);
                    }
                }
            }
        }

        if (dashState != DashState.Holding)
        {
            if (jumpState == JumpState.None)
            {
                if (boostState != BoostState.Holding)
                {
                    if (eraseState != EraseState.Holding)
                    {
                        if (boost > 0)
                        {
                            boost      -= (int)boostSpeed / 2;
                            velocity.y -= gravity * Time.deltaTime;
                            velocity.x  = 0;
                        }
                        else
                        {
                            velocity.y -= gravity * Time.deltaTime;

                            if (crouchState == CrouchState.Holding)
                            {
                                velocity.x = 0;
                            }
                        }
                    }
                    else
                    {
                        velocity.x = 0;
                        velocity.y = 0;
                    }
                }
                else if (boostState == BoostState.Holding)
                {
                    velocity.x = 0;
                    stunned    = false;
                }
            }

            if (stunned)
            {
                if (currentX != 0)
                {
                    velocity.x = (currentX * -1) * stunBounce;
                    stunTimer += Time.deltaTime;
                }
                else
                {
                    velocity.x = (enemyX * -3) * stunBounce;
                    stunTimer += Time.deltaTime;
                }

                if (stunTimer >= stunPeriod)
                {
                    stunned    = false;
                    velocity.x = 0;
                }
            }
            else
            {
                currentX  = velocity.x;
                stunTimer = 0;
            }
        }
        else if (dashState == DashState.Holding)
        {
            velocity.y += vertBoost * Time.deltaTime;
            stunned     = false;
        }

        Vector2 displacement = Vector2.zero;
        Vector2 wantedDispl  = velocity * Time.deltaTime;

        if (standingOn != null)
        {
            if (lastStandingOn == standingOn)
            {
                lastStandingOnVel = (Vector2)standingOn.transform.position - lastStandingOnPos;
                wantedDispl      += lastStandingOnVel;
            }
            else if (standingOn == null)
            {
                velocity    += lastStandingOnVel / Time.deltaTime;
                wantedDispl += lastStandingOnVel;
            }
            lastStandingOnPos = standingOn.transform.position;
        }
        lastStandingOn = standingOn;

        if (wantedDispl.x > 0)
        {
            displacement.x = moveRight.DoRaycast(transform.position, wantedDispl.x);
        }
        else if (wantedDispl.x < 0)
        {
            displacement.x = -moveLeft.DoRaycast(transform.position, -wantedDispl.x);
        }
        if (wantedDispl.y > 0)
        {
            displacement.y = moveUp.DoRaycast(transform.position, wantedDispl.y);
        }
        else if (wantedDispl.y < 0)
        {
            displacement.y = -moveDown.DoRaycast(transform.position, -wantedDispl.y);
        }

        if (Mathf.Approximately(displacement.x, wantedDispl.x) == false)
        {
            velocity.x = 0;
        }
        if (Mathf.Approximately(displacement.y, wantedDispl.y) == false)
        {
            velocity.y = 0;
        }

        transform.Translate(displacement);

        if (!stunned)
        {
            if (dashState == DashState.Holding)
            {
                if (playerAnim.cycleCounter != 4)
                {
                    playerAnim.flip         = true;
                    playerAnim.cycleCounter = 4;
                }
            }
            else
            {
                if (jumpState == JumpState.Holding)
                {
                    if (playerAnim.cycleCounter != 3)
                    {
                        playerAnim.flip         = true;
                        playerAnim.cycleCounter = 3;
                    }
                }
                else
                {
                    if (eraseState == EraseState.Holding)
                    {
                        if (playerAnim.cycleCounter != 8)
                        {
                            playerAnim.flip         = true;
                            playerAnim.cycleCounter = 8;
                        }
                    }
                    else
                    {
                        if (grounded)
                        {
                            if (wantedDirection == 0)
                            {
                                if (crouchState == CrouchState.Holding)
                                {
                                    if (playerAnim.cycleCounter != 6)
                                    {
                                        playerAnim.flip         = true;
                                        playerAnim.cycleCounter = 6;
                                    }
                                }
                                else
                                {
                                    if (playerAnim.cycleCounter != 0)
                                    {
                                        playerAnim.flip         = true;
                                        playerAnim.cycleCounter = 0;
                                    }
                                }
                            }
                            else
                            {
                                if (playerAnim.cycleCounter != 1)
                                {
                                    playerAnim.flip         = true;
                                    playerAnim.cycleCounter = 1;
                                }
                            }
                        }
                        else
                        {
                            if (velocity.y < 0)
                            {
                                if (playerAnim.cycleCounter != 2)
                                {
                                    playerAnim.flip         = true;
                                    playerAnim.cycleCounter = 2;
                                }
                            }
                            else
                            {
                                if (boostState == BoostState.Holding)
                                {
                                    if (playerAnim.cycleCounter != 5)
                                    {
                                        playerAnim.flip         = true;
                                        playerAnim.cycleCounter = 5;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        else if (stunned)
        {
            if (playerAnim.cycleCounter != 7)
            {
                playerAnim.flip         = true;
                playerAnim.cycleCounter = 7;
            }
        }

        if (wantedDirection != 0)
        {
            spriteRenderer.flipX = wantedDirection < 0;
            blankSR.flipX        = wantedDirection < 0;
        }
    }
コード例 #17
0
 public static void OnBoostX20StateChanged(BoostState oldState, BoostState newState)
 => X20BoostStateChanged?.Invoke(oldState, newState);
コード例 #18
0
ファイル: MainLogic.cs プロジェクト: jjcat/Air_Rush
    // Update is called once per frame
    void Update()
    {
        //Debug.Log("Velocity: " + GameConfig.Velocity);
        TestGameOver();
        if (_gameOver != true)
        {
            _time += Time.deltaTime;
            _tileNumRuns = _tileGenarator.GetTileGenNum();
            Debug.Log("Tile Num: "+ _tileNumRuns);
            //if (_tileNumRuns % 300 == 299)
            //{
            //    GameConfig.Velocity+=1.0f;
            //}
            ShowTime();
            ShowScore();
            ShowBoost();
        }

        if(_boostState == BoostState.BoostOff)
        {
            _power += Time.deltaTime*2;
            if(_power >100.0f)
            {
                _power = 100.0f;
            }
        }

        if(_boostState == BoostState.BoostOn)
        {
            AudioSource click = GameObject.Find("BoostBGM").GetComponent<AudioSource>();
            click.volume -= (click.volume/6.0f) * Time.deltaTime;
            _power -= Time.deltaTime*(100.0f/6.0f);
            _boostTime -= Time.deltaTime;
            if(_power<0)
            {
                _power = 0;
            }
            if(_boostTime<=0.0f)
            {
                _boostState = BoostState.BoostOff;
                OnBoostOff();
            }
        }

        // to stop falling
        if( transform.position.y < -100)
        {
            rigidbody.useGravity = false;
            rigidbody.Sleep();
        }

        if(transform.position.y < -30)
        {
            AudioSource bgmover = GameObject.Find("BGMOver").GetComponent<AudioSource>();
            if(!bgmover.isPlaying)
            {
                bgmover.Play();
            }

        }
    }
コード例 #19
0
 public SwimJoystickState(Tutorial context, ChainedState _back)
     : base(context)
 {
     back = _back;
     next = new BoostState(context, this);
     defaulControl = context.playerControl.controlType;
 }
コード例 #20
0
 private void OnBoostStateChanged(BoostState oldState, BoostState newState)
 {
     Debug.Log($"x20 state changed => {newState}".Colored(ConsoleTextColor.yellow));
     Setup();
     UpdateState();
 }
コード例 #21
0
 public SwimAccelerometerDownState(Tutorial context, ChainedState _back)
     : base(context)
 {
     back = _back;
     next = new BoostState(context, this);
     defaulControl = context.playerControl.controlType;
 }