Example #1
0
        public StateInterruptItem GetItem(EPlayerState playerState)
        {
            StateInterruptItem interruptItem;

            configs.TryGetValue(playerState, out interruptItem);
            return(interruptItem);
        }
    public void ChangeState(EPlayerState state)
    {
        currentState.Exit(animator);                        //前のステートの終了処理

        currentState = PlayerAnimeFactory.GetState(state);  //ステートを取得
        currentState.Execute(animator);                     //ステートを実行
    }
Example #3
0
        public PlayerStateInputData GetState(EPlayerState state)
        {
            PlayerStateInputData stateVal;

            playerStatesDict.TryGetValue(state, out stateVal);
            return(stateVal);
        }
Example #4
0
 private void TransitToWon()
 {
     rb.velocity = Vector3.zero;
     state       = EPlayerState.Won;
     animator.ResetTrigger("Run");
     animator.SetTrigger("Stop");
 }
Example #5
0
 private void UpdateJumping()
 {
     if (IsJumping && IsDescending)
     {
         m_PlayerState = EPlayerState.Falling;
     }
 }
Example #6
0
    private void Jump()
    {
        m_groundedRemember    -= Time.deltaTime;
        m_jumpPressedRemember -= Time.deltaTime;

        if (Input.GetButtonDown("Jump"))
        {
            m_jumpPressedRemember = jumpPressedRememberTime;
        }

        /* Jumping */
        if ((m_groundedRemember > 0) && (m_jumpPressedRemember > 0))
        {
            /* Jump Statistics */
            StatisticsCollector.instance.jumpCount++;

            m_jumpPressedRemember = 0;
            m_groundedRemember    = 0;
            m_velocity.y          = Mathf.Sqrt(2f * jumpHeight * -m_gravity);

            if (m_audioSource && jumpClip)
            {
                m_audioSource.PlayOneShot(jumpClip);
            }

            InstantiateDustParticle(dustParticles, transform.position + (Vector3.down / 2f));

            m_currentState = EPlayerState.Jumping;
            StartCoroutine(ChangeScaleRoutine(spriteChild.localScale * m_goingUpScaleMultiplier));
        }
    }
Example #7
0
 private void TransitToWalking(Vector3 newDestination)
 {
     destination = newDestination;
     state       = EPlayerState.Walking;
     animator.ResetTrigger("Stop");
     animator.SetTrigger("Run");
 }
Example #8
0
    protected void ChangeState(EPlayerState newState)
    {
        if (state == EPlayerState.STATE_DYING)
        {
            return;
        }
        switch (newState)
        {
        case EPlayerState.STATE_IDLE:
            sprite.Play("default");
            break;

        case EPlayerState.STATE_MOVING:
            if (state != EPlayerState.STATE_MOVING)
            {
                sprite.Play("default");
            }
            break;

        case EPlayerState.STATE_STUNNED:
            sprite.Play("default");
            break;

        case EPlayerState.STATE_DYING:
            break;

        default:
            sprite.Play("default");
            break;
        }
        state = newState;
    }
Example #9
0
    public void Reset()
    {
        handSize = 0;

        foreach (ECard c in mCardHand)
        {
            GameObject.Destroy(c.gameObject);
        }
        mCardHand.Clear();

        foreach (ECard c in mCardTrash)
        {
            GameObject.Destroy(c.gameObject);
        }
        mCardTrash.Clear();

        foreach (Meld m in mCardMelds)
        {
            foreach (ECard c in m.meld)
            {
                GameObject.Destroy(c.gameObject);
            }
        }
        mCardMelds.Clear();

        PlayerState = EPlayerState.waiting;
    }
Example #10
0
        public StateTransitionConfigItem GetConditionByState(EPlayerState state)
        {
            StateTransitionConfigItem inputs;

            _configs.TryGetValue(state, out inputs);
            return(inputs);
        }
    public void Init(string ctrlName, string skinName, float X, float Y, BoardManager board, int playerNb)
    {
        controllerName        = ctrlName;
        playersSkinName       = skinName;
        curentState           = EPlayerState.state_idle;
        curentOrientation     = EOrientation.up_left;
        currentLife           = maxLife;
        currentStamina        = maxStamina;
        hitAnimation          = false;
        deltaTimeHitAnimation = 0.0f;
        deltaBlinkAnimation   = 0.0f;

        boardMG = board;
        //
        // Put in start position
        posX         = X;
        posY         = Y;
        playerNumber = playerNb;
        boardMG.playerPos[playerNumber]          = new Vector2(X, Y);
        boardMG.playerPosCollision[playerNumber] = new Vector2(X, Y);
        offsetedCasePos = boardMG.map[(int)X, (int)Y].position;

        Vector2 screenPos = boardMG.gameMG.computeScreenPosFromBoard(offsetedCasePos.x, offsetedCasePos.y);

        Vector3 pos = transform.position;

        pos.x = screenPos.x;
        pos.y = screenPos.y + magicOffset;
        transform.position = pos;

        switchAnim();

        currentGameUI.SetActive(true);
        currentGameUI.GetComponent <playerUIScript>().Init();
    }
Example #12
0
 public void ChangeState(EPlayerState state)
 {
     foreach (var plr in Values)
     {
         plr.State = state;
     }
 }
Example #13
0
    public void StopPlay()
    {
        ResetGame();

        AllDestroy("barrier");
        e_PlayerState = EPlayerState.e_Stop;
        m_Creator.StopPlayDrawEffect();
    }
Example #14
0
 private void Awake()
 {
     e_PlayerState = EPlayerState.e_Stop;
     m_Creator     = FindObjectOfType <UFOCreator>();
     m_GameManager = FindObjectOfType <CUFOGameManager>();
     c_ADS         = FindObjectOfType <CADS>();
     m_Ach         = FindObjectOfType <CAchievements>();
 }
Example #15
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.tag == "FinishTrigger")
     {
         mState = EPlayerState.ePlayerWinner;
         _gameController.LevelPassed();
     }
 }
Example #16
0
 public void AddCondition(EPlayerState state, EPlayerInput input)
 {
     if (!_conditions.ContainsKey(state))
     {
         _conditions[state] = new HashSet <EPlayerInput>(CommonIntEnumEqualityComparer <EPlayerInput> .Instance);
     }
     _conditions[state].Add(input);
 }
Example #17
0
 public IGameState GetState(EPlayerState state)
 {
     if (!_gameStateDic.ContainsKey(state) && state != EPlayerState.None)
     {
         Logger.ErrorFormat("state {0} doesn't exist in game state dic ", state);
         return(null);
     }
     return(_gameStateDic[state]);
 }
    private void JumpingFromWallState()
    {
        // jumping from wall specifics...

        if (isGrounded)
        {
            m_currentPlayerState = EPlayerState.Grounded;
        }
    }
Example #19
0
	public void MoveRight()
	{
		if(CurrentState == EPlayerState.Idle || CurrentState == EPlayerState.WalkingLeft)
		{
			CurrentState = EPlayerState.WalkingRight;
            TurnRight();
            playerAnimations.AnimationMove();
        }
	}
    // Functions for each state
    // each state handles its own specific things and transitioning to other states
    private void GroundedState()
    {
        // grounded specifics...

        if (playerJump)
        {
            m_currentPlayerState = EPlayerState.Jumping;
        }
    }
Example #21
0
    void Awake()
    {
        Cursor.lockState = CursorLockMode.Locked;

        m_currentState = EPlayerState.Freehanded;
        m_rigid        = GetComponent <Rigidbody>();
        m_Animator     = GetComponent <Animator>();
        m_aniMovID     = Animator.StringToHash("MoveSpeed");
    }
    // Update is called once per frame
    void Update()
    {
        m_pressedJumpTime -= Time.deltaTime;
        m_wasGroundedTime -= Time.deltaTime;

        inputHorizontalSpeed = Input.GetAxisRaw("Horizontal");

        if (Input.GetButtonDown("Jump"))
        {
            m_pressedJumpTime = m_pressedToJumpRememberTime;
        }

        if (m_actorReference.isGrounded)
        {
            m_wasGroundedTime  = m_playerGroundedRememberTime;
            m_playerVelocity.y = 0;
        }

        switch (m_currentPlayerState)
        {
        case EPlayerState.Grounded:
            ProcessGroundedState();
            break;

        case EPlayerState.Jumping:
            ProcessJumpingState();
            break;
        }

        ProcessSpriteScale();
        ProcessAnimation();

        if (m_playerVelocity.y < 0)
        {
            m_gravity            = m_goingDownGravity;
            m_currentPlayerState = EPlayerState.Jumping;
        }

        float smoothedMovementFactor = m_actorReference.isGrounded ? groundDamping : airDamping;
        float xVelocityLerp          = Mathf.Clamp01(Time.deltaTime * smoothedMovementFactor);

        // force removing any momentum when there is no input
        if (inputHorizontalSpeed == 0)
        {
            xVelocityLerp *= 3.5f;
        }


        m_playerVelocity.x  = Mathf.Lerp(m_playerVelocity.x, inputHorizontalSpeed * footSpeed, xVelocityLerp);
        m_playerVelocity.y += m_gravity * Time.deltaTime;

        Vector3 eulerDeltaMovement          = m_playerVelocity * Time.deltaTime;
        Vector3 velocityVerletDeltaMovement = new Vector3(eulerDeltaMovement.x, eulerDeltaMovement.y + (0.5f * m_gravity * Time.deltaTime * Time.deltaTime), 0f);

        m_playerVelocity = m_actorReference.Move(eulerDeltaMovement);
    }
Example #23
0
 public void Stop()
 {
     if (null == _currentConfig)
     {
         return;
     }
     _state = EPlayerState.Stop;
     _currentConfig.AudioSourceA.Stop();
     _pos = 0f;
 }
Example #24
0
 //stateが変更されたときにChangeStateを呼ぶ
 void CheckState()
 {
     if (state == stateStorage)
     {
         return;
     }
     GetComponent <PlayerAnime>().ChangeState(state);
     stateStorage = state;
     //Debug.Log(state);
 }
Example #25
0
        void Die()
        {
            CAudioManager.Instance.PlaySFX(ESoundsFx.EnemyDie);
            animator.SetInteger("MovingParam", 2);

            mState = EPlayerState.ePlayerLost;
            _gameController.IsGameFinished();

            //Destroy(gameObject);
        }
Example #26
0
    private void UnStickToWall()
    {
        float horizontalMovementValue = Input.GetAxis("Horizontal");

        if (horizontalMovementValue == 0)
        {
            m_gravity      = gravity;
            m_currentState = EPlayerState.Jumping;
        }
    }
Example #27
0
    // the Update loop contains a very simple example of moving the character around and controlling the animation
    void Update()
    {
        if (m_controller.isGrounded)
        {
            m_groundedRemember = groundedRememberTime;
            m_velocity.y       = 0;
            m_currentState     = EPlayerState.Idle;
            m_gravity          = gravity;

            if (!m_controller.collisionState.wasGroundedLastFrame)
            {
                if (m_audioSource && jumpClip)
                {
                    m_audioSource.PlayOneShot(groundedClip);
                }
                StartCoroutine(ChangeScaleRoutine(spriteChild.localScale * m_groundingScaleMultiplier));

                /* Instantiate Dust Particles */
                InstantiateDustParticle(dustParticles, transform.position + (Vector3.down / 2f));
            }
        }

        ProcessState(m_currentState);
        AnimationHandling();

        // apply horizontal speed smoothing it. dont really do this with Lerp. Use SmoothDamp or something that provides more control
        var smoothedMovementFactor = m_controller.isGrounded ? groundDamping : inAirDamping;

        switch (m_currentState)
        {
        case EPlayerState.Idle:
        case EPlayerState.Moving:
            smoothedMovementFactor = groundDamping;
            break;

        case EPlayerState.Jumping:
            smoothedMovementFactor = inAirDamping;
            break;

        case EPlayerState.Dashing:
            smoothedMovementFactor = 0;
            break;
        }

        m_velocity.x = Mathf.Lerp(m_velocity.x, m_normalizedHorizontalSpeed * runSpeed, Time.deltaTime * smoothedMovementFactor);

        // apply gravity before moving
        m_velocity.y += m_gravity * Time.deltaTime;

        /* limiting gravity */
        // m_velocity.y = Mathf.Max(m_gravity, m_velocity.y + (m_gravity * Time.deltaTime + (.5f * m_gravity * (Time.deltaTime * Time.deltaTime))));

        m_controller.move(m_velocity * Time.deltaTime);
        m_velocity = m_controller.velocity;
    }
Example #28
0
    // Update is called once per frame
    void Update( )
    {
        if (!parent.rhythmTimer.IsInputTime && state == EPlayerState.IDLE)
        {
            state = EPlayerState.WALK;
        }
        else if (parent.rhythmTimer.IsInputTime)
        {
            state = EPlayerState.IDLE;
        }
        switch (state)
        {
        case EPlayerState.IDLE:
            bGetInput = false;
            break;

        case EPlayerState.WALK:
            if (!bGetInput)
            {
                tmpPlayerPos = playerPos;
                bGetInput    = true;
                InputResults.Clear( );
                bFcolorFin = false;
                bScolorFin = false;
                InputResults.AddRange(parent.InputResults);
                //InputResults.AddRange (testInputResults);
                steps.Clear( );
            }
            else if (!bFcolorFin)
            {
                bFcolorFin = !Walk(InputResults [0].color);
            }
            else if (bFcolorFin && !bScolorFin)
            {
                bScolorFin = !Walk(InputResults [1].color);
            }
            if (bFcolorFin && bScolorFin)
            {
                state              = EPlayerState.ANIM;
                destination        = CountDestination( );
                playerWorldPos     = new Vector2(playerPos.x * BASIC_CELL_SIZE, -playerPos.y * BASIC_CELL_SIZE);
                destinationPos     = new Vector2(destination.x * BASIC_CELL_SIZE, -destination.y * BASIC_CELL_SIZE);
                transform.position = playerWorldPos;
                timer              = .0f;
                playerPos          = destination;
            }

            break;

        case EPlayerState.ANIM:
            transform.position = Vector2.Lerp(transform.position, destinationPos, timer);
            timer += Time.deltaTime * 0.5f;
            break;
        }
    }
Example #29
0
 public void SetPause(bool f)
 {
     if (f)
     {
         e_PlayerState = EPlayerState.e_Pause;
     }
     else
     {
         e_PlayerState = EPlayerState.e_Play;
     }
 }
Example #30
0
    // Update is called once per frame
    void Update()
    {
        Movement();

        if (Input.GetMouseButtonDown(0))                   //Call Companion
        {
            if (m_currentState == EPlayerState.Freehanded) //Follow
            {
                if (Vector3.Distance(ScoreKeeper.Get.Companion.transform.position, transform.position) <= m_DistanceDragBack)
                {
                    ScoreKeeper.Get.Companion.Call_FollowMe();
                    m_currentState = EPlayerState.HoldingHand;
                    m_FriendlySpotLight.enabled = true;
                }
                else
                {
                    //ToDo: Too far away!
                }
            }
            else if (m_currentState == EPlayerState.HoldingHand) //Wait
            {
                ScoreKeeper.Get.Companion.Call_WaitHere();
                m_currentState = EPlayerState.Freehanded;
                m_FriendlySpotLight.enabled = false;
            }
        }
        else if (Input.GetMouseButtonUp(0))
        {
        }

        if (Input.GetKeyDown(KeyCode.G))
        {
            if (m_currentItem != null)//Drop
            {
                m_currentItem.Drop();
                m_currentItem.transform.parent = transform.parent;
                m_currentItem  = null;
                m_currentState = EPlayerState.Freehanded;
            }
            else if (CurrentState == EPlayerState.Freehanded)
            {
                m_currentItem = TryPickUp();
                if (m_currentItem != null)
                {
                    m_currentState = EPlayerState.HoldingIten;
                    m_currentItem.PickUp();

                    m_currentItem.transform.parent        = m_HoldingBone;
                    m_currentItem.transform.localPosition = m_currentItem.m_holdingPosOffset();
                    m_currentItem.transform.localRotation = Quaternion.Euler(m_currentItem.m_holdingRotOffset());
                }
            }
        }
    }
Example #31
0
 public void Play()
 {
     if (null == _currentConfig)
     {
         return;
     }
     _state = EPlayerState.Play;
     _currentConfig.AudioSourceA.volume = 0f;
     _currentConfig.AudioSourceA.Play();
     _pos = 0;
 }
Example #32
0
	// Update is called once per frame
	void Update () 
	{
		switch(CurrentState)
		{
			case EPlayerState.WalkingLeft:
                
				SetNewXPosition(this.transform.localPosition.x - 
			                (IsCarryingVillager ? Globals.PLAYER_CARRY_SPEED * Time.deltaTime : Globals.PLAYER_WALK_SPEED * Time.deltaTime));
				break;
			case EPlayerState.WalkingRight:
                
                SetNewXPosition(this.transform.localPosition.x + 
			                (IsCarryingVillager ? Globals.PLAYER_CARRY_SPEED * Time.deltaTime : Globals.PLAYER_WALK_SPEED * Time.deltaTime));
				break;
            case EPlayerState.Idle:
                
                break;
        }
		// TODO; animations

		previousState = CurrentState;
	}
        public void SetPlayerState(EPlayerState a_state)
        {
            // Reset the suicide cooldown when going from the dying state to the control state
            if (m_currentPlayerState == EPlayerState.Dying && a_state == EPlayerState.Control)
            {
                m_suicideScript.ResetTimer();
            }

            m_currentPlayerState = a_state;
            switch (a_state)
            {
                case EPlayerState.Pregame:
                    {
                        ChangeToPregame();
                        break;
                    }
                /*case EPlayerState.Roulette:
                    {
                        //ChangeToRoulette();
                        //break;
                    }*/
                case EPlayerState.Control:
                    {
                        ChangeToControl();
                        break;
                    }
                case EPlayerState.Dying:
                    {
                        ChangeToDying();
                        break;
                    }
                case EPlayerState.Stalling:
                    {
                        ChangeToStalling();
                        break;
                    }
                case EPlayerState.Suicide:
                    {
                        ChangeToSuicide();
                        break;
                    }
                default:
                    {
                        Debug.LogWarning("Changing to unknown state!");
                        break;
                    }
            }
        }
Example #34
0
	public void HandleSpaceAction()
	{
		if(CurrentState == EPlayerState.Dropping || CurrentState == EPlayerState.Dying || CurrentState == EPlayerState.PickingUp)
			return;

		if(IsCarryingVillager)
		{
			CurrentState = EPlayerState.Dropping;
            if(IsOnAltar)
            {
				DropVillagerAsSacrifice();
            }
            else if(IsOnPrayerSpot && !currentPrayerSpot.IsActiveSpot)
            {
				DropVillagerAsCultist();
            }
            else
            {
				DropVillager();
            }
        }
		else
		{
			if(collidingVillagers.Count > 0)
			{
				IsCarryingVillager = true;
                playerAnimations.AnimationTake();
				CurrentState = EPlayerState.PickingUp;
				CarriedVillager = collidingVillagers[0];
				CarriedVillager.HandleBeingPickedUp();

				GetComponent<AudioSource>().Play();
			}
		}
	}
Example #35
0
	public void StopMoving()
	{
		if(CurrentState == EPlayerState.WalkingLeft || CurrentState == EPlayerState.WalkingRight)
		{
			CurrentState = EPlayerState.Idle;
            playerAnimations.AnimationIdle();
        }
	}
Example #36
0
	public void HandlePutAnimationFinished()
	{
		CurrentState = EPlayerState.Idle;
        playerAnimations.AnimationIdle();
    }
Example #37
0
	void Die()
	{
		CurrentState = EPlayerState.Dying;
		playerAnimations.AnimationDie();
		DropVillager(false);
	}