Пример #1
0
        public override void UpdateAction()
        {
            // つた掴みチェック
            if (StellaMove.CheckIvyHold())
            {
                return;
            }

            // 行動ボタンチェック。着地時は何もしない
            if (Input.GetButton("Action") && !isLanding)
            {
                Actable act = StellaMove.ActionBoxInstance.GetActableInstance();
                if (act != null)
                {
                    if (act.Action())
                    {
                        return;
                    }
                }
            }

            StellaMove.instance.Gravity();
            StellaMove.instance.Move();

            if (!isLanding && StellaMove.chrController.isGrounded && StellaMove.myVelocity.y < 0f)
            {
                SoundController.Play(SoundController.SeType.Landing);

                StellaMove.myVelocity.x = 0;
                StellaMove.RegisterAnimEvent(Grounded);
                isLanding = true;
                StellaMove.CheckStepOn();
            }
        }
Пример #2
0
        public override void UpdateAction()
        {
            // つた掴みチェック
            if (StellaMove.CheckIvyHold())
            {
                return;
            }

            // 行動ボタンチェック。着地時は何もしない
            if (Input.GetButton("Action") && !isLanding)
            {
                Actable act = StellaMove.ActionBoxInstance.GetActableInstance();
                if (act != null)
                {
                    if (act.Action())
                    {
                        return;
                    }
                }
            }

            StellaMove.instance.Gravity();
            StellaMove.instance.Move();

            // 着地チェック
            bool isGrounded = StellaMove.ChrController.isGrounded;

            if (!isGrounded && (StellaMove.myVelocity.y < 0))
            {
                int hitCount = PhysicsCaster.CharacterControllerCast(
                    StellaMove.ChrController,
                    Vector3.down,
                    StellaMove.CollisionMargin,
                    PhysicsCaster.MapCollisionPlayerOnlyLayer);
                for (int i = 0; i < hitCount; i++)
                {
                    if (!PhysicsCaster.hits[i].collider.isTrigger)
                    {
                        isGrounded = true;
                    }
                }
            }

            // 着地チェック
            if (!isLanding && isGrounded && StellaMove.myVelocity.y < 0f)
            {
                SoundController.Play(SoundController.SeType.Landing);

                StellaMove.myVelocity.x = 0;
                StellaMove.RegisterAnimEvent(Grounded);
                isLanding = true;
                StellaMove.CheckStepOn();

                StageManager.SetFollowCameraTarget(StellaMove.instance.transform);
            }
            // 頭ぶつけチェック
            else if ((StellaMove.myVelocity.y > 0f) && StellaMove.IsHitHead)
            {
                SoundController.Play(SoundController.SeType.HitHead);
                StellaMove.myVelocity.y = 0f;
            }
        }
Пример #3
0
        /// <summary>
        /// 最寄りのアクション可能なオブジェクトのインスタンスを返します。
        /// </summary>
        /// <returns>有効なオブジェクトがあればnull以外のインスタンスを返します。</returns>
        public Actable GetActableInstance()
        {
            Vector3 ofs = colliderCenter;

            ofs.x *= StellaMove.forwardVector.x;
            Vector3 center = StellaMove.instance.transform.position + ofs;

            int hitCount = (Physics.BoxCastNonAlloc(center, halfExtents, StellaMove.forwardVector, hits, Quaternion.identity, 0f, layerMask));

            int lastActableCount = actableCount;

            for (int i = 0; i < lastActableCount; i++)
            {
                lastActables[i] = actables[i];
            }

            // 列挙するものがなければこの場でnullを返す
            if (hitCount == 0)
            {
                if (SelectedActable != null)
                {
                    SelectedActable.Deselect();
                }
                SelectedActable = null;
                return(null);
            }

            // 今回のものを列挙
            float   min        = float.PositiveInfinity;
            Actable nextSelect = null;

            for (int i = 0; i < hitCount; i++)
            {
                Actable[] hitActs = hits[i].collider.GetComponents <Actable>();

                for (int j = 0; j < hitActs.Length; j++)
                {
                    if (hitActs[j] == null || !hitActs[j].CanAction)
                    {
                        continue;
                    }

                    // 距離の更新確認
                    float dist = Mathf.Abs(transform.position.x - hits[i].transform.position.x);

                    if (hitActs[j] is NaeActable)
                    {
                        NaeActable naeAct = hitActs[j] as NaeActable;
                        float      tx     = hitActs[j].transform.position.x - (StellaMove.NaePutDownOffsetX + naeAct.NaeOffsetX) * StellaMove.forwardVector.x;

                        dist = Mathf.Abs(transform.position.x - tx);
                    }

                    if (dist < min)
                    {
                        min        = dist;
                        nextSelect = hitActs[j];
                    }
                }
            }

            if (SelectedActable != nextSelect)
            {
                if (SelectedActable != null)
                {
                    SelectedActable.Deselect();
                }
                if (nextSelect != null)
                {
                    nextSelect.Select();
                }
            }
            SelectedActable = nextSelect;

            return(SelectedActable);
        }
Пример #4
0
        public override void UpdateAction()
        {
            // ターン中処理
            if (state == StateType.Turn)
            {
                if (StellaMove.instance.Turn())
                {
                    state = StateType.Walk;
                }
                return;
            }

            // 水まきチェック
            if (Input.GetButton("Water"))
            {
                StellaMove.instance.ChangeAction(StellaMove.ActionType.Water);
                return;
            }
            else if (StellaMove.CheckIvyHold())
            {
                return;
            }
            else
            {
                // 行動ボタンチェック
                if (Input.GetButton("Action"))
                {
                    Actable act = StellaMove.ActionBoxInstance.GetActableInstance();
                    if (act != null)
                    {
                        if (act.Action())
                        {
                            return;
                        }
                    }
                }

                Walk();
            }

            bool isBack = PushCheck();

            StellaMove.instance.Gravity();
            StellaMove.instance.Move();
            StellaMove.ChrController.stepOffset = StellaMove.DefaultStepOffset;

            if (!StellaMove.ChrController.isGrounded)
            {
                StellaMove.instance.ChangeAction(StellaMove.ActionType.Air);
                FallNextBlock();
            }
            else
            {
                // 乗っかりチェック
                StellaMove.CheckStepOn();

                // 移動しているなら、ジャンプチェック
                if (!isBack && !Mathf.Approximately(StellaMove.myVelocity.x, 0))
                {
                    StellaMove.instance.CheckMiniJump();
                }
            }
        }