private void OnStateEndedHandler(StateManager.State state)
 {
     if (state == StateManager.State.STUNNED)
     {
         _characterDriver.IsStunned = false;
     }
 }
 public void OpenPopup()
 {
     beforeState        = StateManager.state;
     StateManager.state = StateManager.State.EVENT;
     SetStatusText();
     popup.SetActive(true);
 }
Example #3
0
 public override void StateChanged(StateManager.State newState)
 {
     if (newState == StateManager.State.calibrated)
     {
         Calibrate();
     }
 }
Example #4
0
    private void InvokeStateToGame(StateManager.State gameState)
    {
        if (gameState != StateManager.State.Game)
        {
            return;
        }

        LoadLevel();
    }
Example #5
0
    private void InvokeStateChanged(StateManager.State state)
    {
        if (state != StateManager.State.Main)
        {
            return;
        }

        Toggle(true);
    }
Example #6
0
    public override void StateChanged(StateManager.State newState)
    {
        switch (newState)
        {
        case StateManager.State.init:
            break;

        case StateManager.State.positioned:
            InfoText.text = "Great!\nNow look straight forward and press your right grip button to calibrate your height.";
            RightGripMarker.SetActive(true);
            break;

        case StateManager.State.calibrated:
            InfoText.text    = "Place your hands inside the marked areas and press your left grip button to Arm / Disarm. When disarmed, move the Nao with the left Touchpad as shown above.";
            StatusText.text  = "Calibrated";
            StatusText.color = Color.green;

            ChangeLayerRecursive(Nao, 0);
            LeftModel.SetMeshRendererState(false);
            RightModel.SetMeshRendererState(false);

            ImageCanvas.SetActive(true);
            RightGripMarker.SetActive(false);
            //LeftGripMarker.SetActive(true);
            RightHandMarker.SetActive(true);
            LeftHandMarker.SetActive(true);
            FloorMarker.SetActive(false);
            break;

        case StateManager.State.disarmed:
            StatusText.text     = "Disarmed";
            StatusText.color    = new Color(1, 0.5f, 0.2f);
            publisher.DoPublish = false;

            RightGripMarker.SetActive(false);
            //LeftGripMarker.SetActive(true);
            RightHandMarker.SetActive(true);
            LeftHandMarker.SetActive(true);
            break;

        case StateManager.State.armed:
            InfoCanvas.SetActive(false);
            StatusText.text     = "Armed";
            StatusText.color    = Color.red;
            publisher.DoPublish = true;

            ImageCanvas.SetActive(false);
            ChangeLayerRecursive(NaoMirror, 0);
            LeftDisplay.SetActive(true);
            RightDisplay.SetActive(true);
            LeftGripMarker.SetActive(false);
            RightHandMarker.SetActive(false);
            LeftHandMarker.SetActive(false);
            break;
        }
    }
Example #7
0
 public StateMenu(LeGame g)
     : base(g)
 {
     Log("Creating state");
     background = new ScrollBackground(game, "menu/background");
     mouse = new MouseEntity(game);
     singleColor = multiColor = optionsColor = exitColor = TEXT_COLOR;
     isTransitioning = true;
     doChangeState = false;
     transitionCount = 0;
     targetState = StateManager.State.Single;
     currentTransition = TransitionType.FadeIn;
 }
Example #8
0
        public static Action addAction(StateManager.State actionForState, string actionDescription)
        {
            Action action = new Action(actionDescription);

            action.forState = actionForState;

            Dbg.assert(!actions.ContainsKey(actionForState), "Action already registered: " + actionForState.ToString());

            // Save action
            actions[actionForState] = action;

            return(action);
        }
Example #9
0
    private void InvokeStateToGame(StateManager.State gameState)
    {
        if (gameState != StateManager.State.Game)
        {
            return;
        }

        Toggle(true);
        int time = _baseTime + ((int)(LevelManager.level / 4f) * _levelTimerMultiplier);

        SetTimerText(time);
        Stop();
        StartTimer(time);
    }
Example #10
0
    IEnumerator EventStream()
    {
        StateManager.State oldState = StateManager.state;
        StateManager.state = StateManager.State.EVENT;
        yield return(StartCoroutine(FadeInOut("eventBGM", FadeState.BEGIN)));

        fade.raycastTarget = false;
        yield return(StartCoroutine(InputWait()));

        yield return(StartCoroutine(FadeInOut("mainBGM", FadeState.END)));

        StateManager.state = oldState;
        Destroy(gameObject);
    }
Example #11
0
    // Prevent the player from hitting a enemy that's underneart the Start Game button
    private void InvokeStateToGame(StateManager.State gameState)
    {
        if (gameState != StateManager.State.Game)
        {
            return;
        }

        if (_delayAllowInputCoroutine != null)
        {
            StopCoroutine(_delayAllowInputCoroutine);
        }

        _delayAllowInputCoroutine = DelayAllowInputCoroutine();
        StartCoroutine(_delayAllowInputCoroutine);
    }
Example #12
0
    internal void EvolveToState(StateManager.State desiredState, bool evolveInCurrentThread = false)
    {
        if (targetState == desiredState && !evolveInCurrentThread)
        {
            return;
        }
        targetState = desiredState;

        if (!evolveInCurrentThread)
        {
            ChunkManager.Instance.chunkEvolver.AddChunkToEvolve(this);
        }
        else
        {
            Evolve(evolveInCurrentThread);
        }
    }
 // Update is called once per frame
 void Update()
 {
     if (prevState == StateManager.State.CORRIDOR && gameState.GetComponent <StateManager>().state == StateManager.State.CORRIDOR_OPEN)
     {
         ShiftCurtain shiftCurtain1 = curtain1.GetComponent <ShiftCurtain>();
         shiftCurtain1.open();
         ShiftCurtain shiftCurtain2 = curtain2.GetComponent <ShiftCurtain>();
         shiftCurtain2.open();
     }
     //Debug.Log("Player Z Position ====>>" + player.transform.position.z);
     if (player.transform.position.z <= 12.5f && corridorOver == false)
     {
         corridorOver = true;
         gameState.GetComponent <StateManager>().state = StateManager.State.MAIN_ROOM_TUTORIAL;
         ShiftCurtain shiftCurtain1 = curtain1.GetComponent <ShiftCurtain>();
         shiftCurtain1.close();
         ShiftCurtain shiftCurtain2 = curtain2.GetComponent <ShiftCurtain>();
         shiftCurtain2.close();
     }
     prevState = gameState.GetComponent <StateManager>().state;
 }
 void Start()
 {
     prevState = gameState.GetComponent <StateManager>().state;
 }
Example #15
0
    void FixedUpdate()
    {
        switch (State)
        {
        case StateManager.State.Stand:
            physManager.hud.gameObject.GetComponent <HudHandler>().IsVisible = false;
            physManager.speed.x = 0;
            if (physManager.CheckEnemyAround())
            {
                physManager.hud.gameObject.GetComponent <HudHandler>().IsVisible = true;
                timerOutOfAlert = 0;
                State           = StateManager.State.Alert;
            }
            else if (physManager.CheckNearWall())
            {
                State = StateManager.State.Turn;
            }
            break;

        case StateManager.State.Walk:
            if (physManager.Health < PrevHealth)
            {
                timerOutOfAlert       = 0;
                physManager.Direction = !physManager.Direction;
                State = StateManager.State.AlertBack;
            }
            if (!fix)
            {
                Richard.visto = false;
                fix           = true;
            }
            if (physManager.CheckEnemyAround())
            {
                timerOutOfAlert = 0;
                State           = StateManager.State.Alert;
            }
            if (physManager.CheckEnemyBack())
            {
                timerOutOfAlert       = 0;
                physManager.Direction = !physManager.Direction;
                State = StateManager.State.AlertBack;
            }
            else if (physManager.CheckNearWall())
            {
                State = StateManager.State.Turn;
            }
            break;

        case StateManager.State.Turn:
            physManager.Direction = !physManager.Direction;
            physManager.State     = StateManager.State.Walk;
            break;

        case StateManager.State.Alert:
            Richard.visto       = true;
            fix                 = false;
            physManager.speed.x = (physManager.Direction ? physManager.WalkSpeed : -physManager.WalkSpeed) / 2.0f;
            if (physManager.CheckEnemyNear())
            {
                timerBeforeAttack = 0;
                State             = StateManager.State.PrepareAttack;
            }
            else if (physManager.CheckEnemyAround())
            {
                timerOutOfAlert = 0;
            }
            else
            {
                timerOutOfAlert += Time.deltaTime;
                if (timerOutOfAlert >= TimeOutOfAlert)
                {
                    State = StateManager.State.Walk;
                }
            }
            break;

        case StateManager.State.AlertBack:
            physManager.speed.x = (physManager.Direction ? physManager.WalkSpeed : -physManager.WalkSpeed) / 2.0f;
            if (physManager.CheckEnemyAround())
            {
                physManager.speed.x *= -1;
            }
            timerAlertBack += Time.deltaTime;
            if (timerAlertBack >= TimeAlertBack)
            {
                timerOutOfAlert = 0;
                State           = StateManager.State.Alert;
            }
            break;

        case StateManager.State.PrepareAttack:
            physManager.speed.x = 0;
            timerBeforeAttack  += Time.deltaTime;
            if (timerBeforeAttack >= TimeBeforeAttack)
            {
                strength = AttackStrength;
                State    = StateManager.State.Attack;
            }
            break;

        case StateManager.State.Attack:
            strength -= Inertia * Time.deltaTime;
            if (strength < 0)
            {
                timerAlertBack      = 0;
                physManager.speed.x = 0;
                State = StateManager.State.AlertBack;
            }
            else
            {
                physManager.speed.x = physManager.Direction ? strength : -strength;
            }
            break;

        case StateManager.State.Died:
            physManager.speed.x = 0;
            timerFade1         += TimerFade * Time.deltaTime * 2.0f;
            if (timerFade1 >= 1.0f)
            {
                timerFade1 = 1.0f;
            }
            Richard.visto = false;
            GetComponent <SpriteRenderer>().color = new Color(1.0f, Mathf.Abs(timerFade1 - 1.0f),
                                                              Mathf.Abs(timerFade1 - 1.0f));
            if (timerFade1 >= TimerFade)
            {
                timerFade2 += TimerFade * Time.deltaTime * 2.0f;
                if (timerFade2 >= 1.0f)
                {
                    timerFade2         = 1.0f;
                    transform.position = new Vector3(0, -9999.0f, 0);
                    Destroy(this);
                }
                GetComponent <SpriteRenderer>().color = new Color(1.0f, 0.0f, 0.0f, Mathf.Abs(timerFade2 - 1.0f));
            }
            SpriteRenderer[] _sr  = GetComponentsInChildren <SpriteRenderer>();
            BoxCollider2D[]  _box = GetComponentsInChildren <BoxCollider2D>();
            foreach (SpriteRenderer sr in _sr)
            {
                if (sr != null)
                {
                    sr.color = GetComponent <SpriteRenderer>().color;
                }
            }
            foreach (BoxCollider2D box in _box)
            {
                if (box != null)
                {
                    box.enabled = false;
                }
            }
            break;
        }
        if (physManager.Health <= 0)
        {
            State = StateManager.State.Died;
        }
        PrevHealth = physManager.Health;
    }
Example #16
0
 void Update()
 {
     StateManagerState = StateManager.Instance.state;
 }
Example #17
0
    void FixedUpdate()
    {
        if (IsPlayableCharacter)
        {
            if (CheckEnemyHitted())
            {
                GetComponent <Animator>().SetBool("Colpito", true);
            }
        }
        if (CheckGround() || CheckMovingPlatform())
        {
            if (colpito == true && speed.y < 0)
            {
                colpito    = false;
                IsOnGround = true;
                State      = StateManager.State.Stand;
                GetComponent <Animator>().SetBool("Colpito", false);
            }
            else if (colpito == false)
            {
                IsOnGround = true;
                Jumping    = false;
                if (!CheckMovingPlatform())
                {
                    speed.y = 0;
                }
                else if (State != StateManager.State.Jumping)
                {
                    speed.y = -40;
                }
                if (State == StateManager.State.Unpressed ||
                    PrevState == StateManager.State.Falling)
                {
                    State = StateManager.State.Stand;
                }
            }
        }
        else if (!GravityDisabled)
        {
            IsOnGround = false;
            if (speed.y < Gravity)
            {
                State = StateManager.State.Falling;
            }
        }

        if (colpito == false)
        {
            Stamina += RecuperoStamina * Time.deltaTime;

            switch (State)
            {
            case StateManager.State.Stand:
                if (IsOnGround == true)
                {
                    speed.x = 0.0f;
                }
                else
                {
                    if (speed.y >= JumpStrengthMinimum)
                    {
                        speed.y = JumpStrengthMinimum;
                    }
                }
                break;

            case StateManager.State.Walk:
                speed.x = Direction ? +WalkSpeed : -WalkSpeed;
                break;

            case StateManager.State.Run:
                speed.x  = Direction ? +RunSpeed : -RunSpeed;
                Stamina -= ConsumoStaminaCorsa * Time.deltaTime;
                if (Stamina <= 0)
                {
                    State = StateManager.State.Walk;
                }
                break;

            case StateManager.State.Jumping:
                if (IsOnGround == true && Stamina >= ConsumoStaminaSalto)
                {
                    IsOnGround = false;
                    Jumping    = true;
                    speed.y    = JumpStrengthMaximum;
                    Stamina   -= ConsumoStaminaSalto;
                }

                break;

            case StateManager.State.Falling:
                if (IsOnGround)
                {
                    State = StateManager.State.Stand;
                }
                break;

            case StateManager.State.PreScivolata:
                speed.x = Direction ? +ScivolataForza : -ScivolataForza;
                State   = StateManager.State.Scivolata;
                break;

            case StateManager.State.Scivolata:
                speed.x += (Direction ? -ScivolataInerzia : +ScivolataInerzia);
                if (Direction ? speed.x <= 0 : speed.x >= 0)
                {
                    speed.x = 0;
                    State   = StateManager.State.Crouch;
                }
                break;

            case StateManager.State.Attack:
                //Attacco logica
                if (Stamina > ConsumoStaminaAttacco)
                {
                    Stamina -= ConsumoStaminaAttacco;
                }
                break;

            case StateManager.State.Attack2:
                //Attacco2 logica
                if (Stamina > ConsumoStaminaAttacco)
                {
                    Stamina -= ConsumoStaminaAttacco;
                }
                break;

            case StateManager.State.Defense:
                //Difesa logica
                if (Stamina >= 0)
                {
                    Stamina -= ConsumoStaminaDifesa * Time.deltaTime;
                }
                if (Stamina <= ConsumoStaminaDifesa)
                {
                    State = StateManager.State.Stand;
                }
                break;

            case StateManager.State.Died:
                break;
            }
        }
        if (!IsOnGround && !GravityDisabled)
        {
            speed.y -= Gravity;
        }
        PrevState            = State;
        rigidbody2D.velocity = new Vector3(speed.x * Time.deltaTime, speed.y * Time.deltaTime, 0.0f);

        if (CheckCeiling() && IsOnGround)
        {
            Health = 0;
        }
        if (CheckMovingPlatform2() && IsOnGround && !CheckMovingPlatform() && this.transform.position.y > 6.5f)
        {
            Health = 0;
        }
    }
Example #18
0
    /// <summary>
    /// Chiamato ad ogni frame
    /// </summary>
    void FixedUpdate()
    {
        // Mi memorizzo lo stato precedente per fare delle comparazioni
        StateManager.State state = PreviousState;
        switch (state)
        {
        case StateManager.State.Jumping:
        case StateManager.State.Falling:
        case StateManager.State.Scivolata:
            // Se in scivolata, disabilita ogni altro cambio di stato:
            // il motore della fisica funziona che, una volta che il
            // personaggio è in scivolata, ci resta finché l'inerzia
            // fa fermare la forza inizialmente assegnata dalla scivolata:
            // di conseguenza disabilita ogni altro tasto di input. Questo
            // per offrire un realismo maggiore.
            break;

        default:
            // Ottiene lo stato a partire dai tasti premuti
            state = getStateFromInput();

            // Controllo che evita di far saltare il personaggio mentre è abbassato
            if (state == StateManager.State.Hide && canHide)
            {
                colorHide -= Time.deltaTime * 2;
                if (colorHide <= 0.25f)
                {
                    colorHide = 0.25f;
                }
                if (!visto)
                {
                    Hide = true;
                }
            }
            else if (state == StateManager.State.Hide)
            {
                state = PreviousState;
                Hide  = false;
            }
            else if (state == StateManager.State.Attack)
            {
                WeaponVisible = true;
            }
            else
            {
                WeaponVisible = false;
                colorHide    += Time.deltaTime * 2;
                if (colorHide >= 1.0f)
                {
                    colorHide = 1.0f;
                }
            }
            GetComponent <SpriteRenderer>().color = new Color(colorHide, colorHide, colorHide);

            if (PreviousState == StateManager.State.Crouch && state == StateManager.State.Jumping)
            {
                state = PreviousState;
            }
            // Controllo che permette di fare la scivolata
            if (PreviousState == StateManager.State.Crouch && (We.Input.MoveLeft || We.Input.MoveRight) && !keyScivolata)
            {
                state = StateManager.State.PreScivolata;
                if (We.Input.MoveLeft)
                {
                    physManager.Direction = false;
                }
                else
                {
                    physManager.Direction = true;
                }
                keyScivolata = true;
            }
            break;
        }

        // controllo se il tasto della scivolata è stato rilasciato
        if (!We.Input.MoveLeft && !We.Input.MoveRight)
        {
            keyScivolata = false;
        }

        if (physManager.Health <= 0)
        {
            if (died == false)
            {
                GetComponent <AudioSource>().clip = physManager.SFX[0];
                GetComponent <AudioSource>().Play();
                died = true;
                physManager.speed.y /= 1.5f;
                physManager.speed.x /= 2;
                state = StateManager.State.Died;
            }
            diedTimer += Time.deltaTime;
            if (diedTimer >= DiedTimer)
            {
                Application.LoadLevel(3);
            }
        }
        physManager.State = state;
        _Transform        = transform;
    }
Example #19
0
 private void InvokeStateChange(StateManager.State state)
 {
     Toggle(state == StateManager.State.Game);
 }
Example #20
0
 public void TransitionToState(StateManager.State s)
 {
     targetState = s;
     isTransitioning = true;
     doChangeState = true;
     currentTransition = TransitionType.FadeOut;
 }