//Awake
 private void Awake()
 {
     //取得
     _rigid             = GetComponent <Rigidbody2D>();
     _anim              = GetComponent <Animator>();
     _transition        = GetComponent <PlayerTransition>();
     _transition_Beetle = GetComponent <PlayerTransitionRidingBeetle>();
     _jump              = GetComponent <PlayerJump>();
     _attack            = GetComponent <PlayerAttack>();
     _shoot             = GetComponent <PlayerShoot>();
     _getting_On_Beetle = GetComponent <PlayerGettingOnBeetle>();
     input              = InputManager.Instance;
 }
예제 #2
0
 private void Start()
 {
     _playerInventory = GetComponent <PlayerInventory>();
     _animation       = GetComponent <PlayerTransition>();
     if (spawnPoint.TileData.TileType != ETileType.Spawn || spawnPoint == null)
     {
         throw new ArgumentException("SpawnPoint has to be Spawn type, be non null and should have the same side as player");
     }
     spawnPoint.tileSide = side;
     attachedTile        = spawnPoint;
     attachedTile.PlacePlayer(this);
     PointsLeftForTheTurn = PointsAtTheBeginningOfTheTurn;
 }
 //Awake
 private void Awake()
 {
     //取得
     _rigid             = GetComponent <Rigidbody2D>();
     _anim              = GetComponent <Animator>();
     _transition        = GetComponent <PlayerTransition>();
     _transition_Beetle = GetComponent <PlayerTransitionRidingBeetle>();
     _jump              = GetComponent <PlayerJump>();
     _attack            = GetComponent <PlayerAttack>();
     _kick              = GetComponent <PlayerKick>();
     _squat             = GetComponent <PlayerSquat>();
     _shoot             = GetComponent <PlayerShoot>();
     _getting_On_Beetle = GetComponent <PlayerGettingOnBeetle>();
     input              = InputManager.Instance;
     collection_Manager = CollectionManager.Instance;
     default_Gravity    = _rigid.gravityScale;
 }
        /// <summary>
        /// triggers a transition.
        /// if a trigger is submitted, perform the OnExit and OnEnter methods in the handler
        /// optional: pass a payload for further processing
        /// </summary>
        /// <param name="triggerType"></param>
        /// <param name="payload"></param>
        /// <returns></returns>
        /// <exception cref="ArgumentOutOfRangeException"></exception>
        public bool Trigger(PlayerTransition triggerType, Dictionary <string, object> payload = null)
        {
            switch (triggerType)
            {
            case PlayerTransition.IsWalking:
                if (currentState == PlayerState.Idle)
                {
                    TransitionTo(PlayerState.Walk, payload);
                    return(true);
                }

                return(false);

            case PlayerTransition.IsIdle:
                if (currentState == PlayerState.Idle || currentState == PlayerState.Walk)
                {
                    TransitionTo(PlayerState.Idle, payload);
                    return(true);
                }

                return(false);

            case PlayerTransition.IsJumping:
                if (currentState == PlayerState.Idle || currentState == PlayerState.Walk)
                {
                    TransitionTo(PlayerState.Jump, payload);
                    return(true);
                }

                return(false);

            case PlayerTransition.IsFallingDown:
                if (currentState == PlayerState.Jump)
                {
                    TransitionTo(PlayerState.Idle, payload);
                    // StartCoroutine(DelayTransitionState(PlayerState.Idle, payload, 1f));
                    return(true);
                }

                return(false);

            default:
                throw new ArgumentOutOfRangeException(nameof(triggerType), triggerType, null);
            }
        }
예제 #5
0
    // Use this for initialization
    void Start()
    {
        //取得
        GameObject player = GameObject.FindWithTag("PlayerTag");

        if (player == null)
        {
            Debug.Log("Player is not found");
            gameObject.SetActive(false);
            return;
        }
        player_Controller    = player.GetComponent <PlayerController>();
        player_Transition    = player.GetComponent <PlayerTransition>();
        player_Rigid         = player.GetComponent <Rigidbody2D>();
        _renderer            = GetComponent <Renderer>();
        player_Default_Speed = player_Transition.Get_Max_Speed();

        StartCoroutine("Drop_Rock_Cor");
    }