예제 #1
0
        /// <summary>
        /// Awake this instance.
        /// </summary>
        private void Awake( )
        {
            // デフォルトスピード.
            SpeedRight    = PlayerConfig.DefaultSpeedRight;
            AddSpeedRight = 0.0f;

            // Setting up references.
            objGameManager   = GameObject.Find("/_GameManager");
            gameManager      = objGameManager.GetComponent <GameManager>();
            dustStorm        = transform.FindChild("Dust Storm").gameObject;
            barrier          = transform.FindChild("Barrier").gameObject;
            transformBarrier = barrier.transform;

            defaultPlayerLocalScale = transform.localScale;

            BoneAnimation = transform.FindChild("BoneAnimation").gameObject;
            anim          = BoneAnimation.GetComponent <Animation>();

            objHeadLeaf = transform.FindChild("BoneAnimation/Root/Total/Body/Head/Leaf").gameObject;

            boxCollider2D = this.GetComponent <BoxCollider2D>();

            // animation 初期値.
            animStatus = PlayerConfig.AnimationStatusList.Run;

            moveObjectHandler = this.GetComponent <MoveObject>();

            groundCheckDistance = PlayerConfig.DefaultGroundCheck;

            rigidBody2D = this.GetComponent <Rigidbody2D>();
        }
예제 #2
0
        /// <summary>
        /// Jump the specified jumpforce and seName.
        /// </summary>
        /// <param name="jumpforce">Jumpforce.</param>
        /// <param name="seName">Se name.</param>
        private void Jump(float jumpforce, string seName)
        {
            // アニメーション - ジャンプ.
            animStatus = PlayerConfig.AnimationStatusList.JumpUp;

            this.rigidbody2D.velocity = Vector3.up * jumpforce;

            //  ジャンプSE再生.
            AudioManager.Instance.PlaySE(seName);
            // アニメーション設定.
            SetAnimation(animStatus);
        }
예제 #3
0
        /// <summary>
        /// プレイヤージャンプ処理.
        /// </summary>
        private void Jump(float jumpforce)
        {
            // アニメーション - ジャンプ.
            animStatus = PlayerConfig.AnimationStatusList.JumpUp;

            // 空中ジャンプ中演出.
            if (isDoubleJump)
            {
                // アニメーション - 回転ジャンプ.
                animStatus = PlayerConfig.AnimationStatusList.JumpRotate;

                PrefabPoolManager.Instance.instantiatePrefab(EffectConfig.PlayerJumpEffect, transform.localPosition, Quaternion.identity);
            }
            this.rigidbody2D.velocity = Vector3.up * jumpforce;

            //  ジャンプSE再生.
            AudioManager.Instance.PlaySE(AudioConfig.SePlayerJump);
            // アニメーション設定.
            SetAnimation(animStatus);
        }
예제 #4
0
        /// <summary>
        /// Update this instance.
        /// </summary>
        private void Update()
        {
            // 操作可能.
            if ( IsController ) {

                // 水中.
                if ( IsInWater ) {
                    if ( animStatus != PlayerConfig.AnimationStatusList.Swim ) {
                        animStatus	= PlayerConfig.AnimationStatusList.Swim;
                        SetAnimation( animStatus );
                    }

                    if ( TouchManager.IsTouchBegan() ) {
                        Swim( PlayerConfig.SwimVerticalForce, AudioConfig.SePlayerSwim );
                    }

                    return;
                }

                // 地上にいるか判定.
                isGrounded = Physics2D.Linecast( transform.position, transform.position - transform.up * groundCheckDistance, 1 << LayerMask.NameToLayer("Ground") );

                if ( isGrounded ) {
                    // 地上にいる場合のみ、砂埃を出す.
                    if ( !dustStorm.activeSelf ) {
                        dustStorm.SetActive( true );
                    }

                    if ( jumpEnableCount < JumpEnableCountMax ) {
                        jumpEnableCount	= JumpEnableCountMax;
                    }

                    // アニメーションがRunステータスでない場合、Runに設定.
                    if ( PlayerConfig.AnimationStatusList.Run != animStatus && this.rigidbody2D.velocity.y == 0  ) {
                        animStatus	= PlayerConfig.AnimationStatusList.Run;
                        SetAnimation( animStatus );
                    }
                }
                // 空中にいる場合は砂埃を出さない.
                else {
                    dustStorm.SetActive( false );
                }

                IsJumpEnabaled	= false;
                isDoubleJump	= false;

                // スクリーンタッチ時.
                if ( TouchManager.IsTouchBegan() ) {
                    // 地上にいる場合.
                    if ( isGrounded ) {
                        // ジャンプ可能.
                        IsJumpEnabaled	= true;
                    }
                    // 空中にいる、且つ、残りジャンプ回数が0より大きい場合.
                    else if( !isGrounded && 0 < jumpEnableCount ) {
                        IsJumpEnabaled	= true;
                        isDoubleJump	= true;
                        jumpEnableCount--;
                    }
                }

                if ( IsJumpEnabaled && 0 < jumpEnableCount ) {
                    ExecuteJump();
                }
            }
            //  操作不可能状態の場合.
            else {
                dustStorm.SetActive( false );
            }
        }
예제 #5
0
        /// <summary>
        /// Jump the specified jumpforce and seName.
        /// </summary>
        /// <param name="jumpforce">Jumpforce.</param>
        /// <param name="seName">Se name.</param>
        private void Jump( float jumpforce, string seName )
        {
            // アニメーション - ジャンプ.
            animStatus	= PlayerConfig.AnimationStatusList.JumpUp;

            this.rigidbody2D.velocity = Vector3.up * jumpforce;

            //  ジャンプSE再生.
            AudioManager.Instance.PlaySE( seName );
            // アニメーション設定.
            SetAnimation( animStatus );
        }
예제 #6
0
        /// <summary>
        /// プレイヤージャンプ処理.
        /// </summary>
        private void Jump( float jumpforce )
        {
            // アニメーション - ジャンプ.
            animStatus	= PlayerConfig.AnimationStatusList.JumpUp;

            // 空中ジャンプ中演出.
            if ( isDoubleJump ) {
                // アニメーション - 回転ジャンプ.
                animStatus	= PlayerConfig.AnimationStatusList.JumpRotate;

                PrefabPoolManager.Instance.instantiatePrefab( EffectConfig.PlayerJumpEffect, transform.localPosition, Quaternion.identity );
            }
            this.rigidbody2D.velocity = Vector3.up * jumpforce;

            //  ジャンプSE再生.
            AudioManager.Instance.PlaySE( AudioConfig.SePlayerJump );
            // アニメーション設定.
            SetAnimation( animStatus );
        }
예제 #7
0
        /// <summary>
        /// Awake this instance.
        /// </summary>
        private void Awake( )
        {
            // デフォルトスピード.
            SpeedRight	= PlayerConfig.DefaultSpeedRight;
            AddSpeedRight	= 0.0f;

            // Setting up references.
            objGameManager	= GameObject.Find ( "/_GameManager" );
            gameManager		= objGameManager.GetComponent<GameManager>();
            dustStorm	= transform.FindChild( "Dust Storm" ).gameObject;
            barrier		= transform.FindChild( "Barrier" ).gameObject;
            transformBarrier	= barrier.transform;

            defaultPlayerLocalScale	= transform.localScale;

            BoneAnimation	= transform.FindChild( "BoneAnimation" ).gameObject;
            anim			= BoneAnimation.GetComponent<Animation>();

            objHeadLeaf		= transform.FindChild( "BoneAnimation/Root/Total/Body/Head/Leaf" ).gameObject;

            boxCollider2D	= this.GetComponent<BoxCollider2D>();

            // animation 初期値.
            animStatus	= PlayerConfig.AnimationStatusList.Run;

            moveObjectHandler	= this.GetComponent<MoveObject>();

            groundCheckDistance	= PlayerConfig.DefaultGroundCheck;

            rigidBody2D	= this.GetComponent<Rigidbody2D>();
        }
예제 #8
0
 /// <summary>
 /// Animation設定.
 /// </summary>
 /// <param name="status">Status.</param>
 private void SetAnimation(PlayerConfig.AnimationStatusList status)
 {
     anim.Play(System.Convert.ToString(status));
 }
예제 #9
0
        /// <summary>
        /// Update this instance.
        /// </summary>
        private void Update()
        {
            // 操作可能.
            if (IsController)
            {
                // 水中.
                if (IsInWater)
                {
                    if (animStatus != PlayerConfig.AnimationStatusList.Swim)
                    {
                        animStatus = PlayerConfig.AnimationStatusList.Swim;
                        SetAnimation(animStatus);
                    }

                    if (TouchManager.IsTouchBegan())
                    {
                        Swim(PlayerConfig.SwimVerticalForce, AudioConfig.SePlayerSwim);
                    }

                    return;
                }


                // 地上にいるか判定.
                isGrounded = Physics2D.Linecast(transform.position, transform.position - transform.up * groundCheckDistance, 1 << LayerMask.NameToLayer("Ground"));

                if (isGrounded)
                {
                    // 地上にいる場合のみ、砂埃を出す.
                    if (!dustStorm.activeSelf)
                    {
                        dustStorm.SetActive(true);
                    }

                    if (jumpEnableCount < JumpEnableCountMax)
                    {
                        jumpEnableCount = JumpEnableCountMax;
                    }

                    // アニメーションがRunステータスでない場合、Runに設定.
                    if (PlayerConfig.AnimationStatusList.Run != animStatus && this.rigidbody2D.velocity.y == 0)
                    {
                        animStatus = PlayerConfig.AnimationStatusList.Run;
                        SetAnimation(animStatus);
                    }
                }
                // 空中にいる場合は砂埃を出さない.
                else
                {
                    dustStorm.SetActive(false);
                }

                IsJumpEnabaled = false;
                isDoubleJump   = false;

                // スクリーンタッチ時.
                if (TouchManager.IsTouchBegan())
                {
                    // 地上にいる場合.
                    if (isGrounded)
                    {
                        // ジャンプ可能.
                        IsJumpEnabaled = true;
                    }
                    // 空中にいる、且つ、残りジャンプ回数が0より大きい場合.
                    else if (!isGrounded && 0 < jumpEnableCount)
                    {
                        IsJumpEnabaled = true;
                        isDoubleJump   = true;
                        jumpEnableCount--;
                    }
                }

                if (IsJumpEnabaled && 0 < jumpEnableCount)
                {
                    ExecuteJump();
                }
            }
            //  操作不可能状態の場合.
            else
            {
                dustStorm.SetActive(false);
            }
        }