Esempio n. 1
0
        private void FixedUpdate()
        {
            if (!isEating)
            {
                return;
            }

            float t    = (Time.time - eatStartTime);
            float dist = Vector3.Distance(Graviy.MouthPosition, transform.position);

            if ((t >= eatTime) ||
                ((t >= eatMinTime) &&
                 (dist <= EatDistance)))
            {
                // 食べる
                Graviy.instance.EatDone(this);
                GameParams.AddScore(point);
                GameParams.AddLife(heal);
                Destroy(gameObject);
                return;
            }

            t = Mathf.Clamp01(t / eatTime);

            Vector3 next = Vector3.Lerp(transform.position, Graviy.MouthPosition, t);
            Vector3 move = (next - transform.position) / Time.fixedDeltaTime;

            rb.velocity = move;
        }
Esempio n. 2
0
        static IEnumerator TimeBonus()
        {
            int bonus = 0;

            GameManager.instance.TimeBonusText($"{TimeBonusPrefix}{bonus,5}</mspace>");
            int leftTime = Mathf.FloorToInt(GameParams.playTime * GameParams.TimeBonus);

            yield return(WaitForSecondsOrClick(WaitNextSeconds));

            int keta = 1;
            int waru = 10;

            while (leftTime > 0)
            {
                int count = (leftTime % waru) / keta;
                for (int i = 0; i < count; i++)
                {
                    bonus += keta;
                    GameParams.AddScore(keta);
                    SoundController.Play(SoundController.SeType.Click);
                    leftTime -= keta;

                    GameManager.instance.TimeBonusText($"{TimeBonusPrefix}{bonus,5}</mspace>");
                    GameParams.playTime = ((float)leftTime / GameParams.TimeBonus) + (0.1f / GameParams.TimeBonus);
                    yield return(waitFixed);
                }

                keta *= 10;
                waru *= 10;
            }
        }
Esempio n. 3
0
        static IEnumerator ClearCoroutine(ClearObject clearObject)
        {
            // ブラックホールに吸い込まれる
            yield return(clearObject.ToBlackhole());

            Blackhole.instance.ClearDone();
            Graviy.instance.StartEat();

            // 落下
            yield return(clearObject.Fall());

            // 口を閉じてクリア表示
            Graviy.AddEnergy(Graviy.EnergyMax);
            Graviy.instance.CloseMouth();
            GameManager.ShowClear();

            yield return(WaitForSecondsOrClick(WaitNextSeconds));

            // タイムボーナス
            yield return(TimeBonus());

            yield return(WaitForSecondsOrClick(WaitNextSeconds));

            // ライフボーナス
            yield return(LifeBonus());

            yield return(WaitForSecondsOrClick(WaitNextSeconds));

            // アイテムパーフェクトボーナス
            if (GameManager.GetItem >= GameManager.ItemCount)
            {
                GameManager.instance.PerfectBonusText(PerfectBonusMessage);
                GameParams.AddScore(PerfectPoint);
                SoundController.Play(SoundController.SeType.Start);
            }
            else
            {
                GameManager.instance.PerfectBonusText($"{GameManager.ItemCount}{Kosu}コ</size>中{GameManager.GetItem}{Kosu}コ</size>ゲット。{GameManager.ItemCount - GameManager.GetItem}{Kosu}コ</size>とりのがし...");
            }

            yield return(WaitForSecondsOrClick(WaitNextSeconds));

            GameManager.ShowClick();
            CanNext = true;
        }
Esempio n. 4
0
        static IEnumerator LifeBonus()
        {
            int bonus = 0;

            GameManager.instance.LifeBonusText($"{LifeBonusPrefix}{bonus,5}</mspace>");

            yield return(WaitForSecondsOrClick(WaitNextSeconds));

            while (GameParams.Life > 0)
            {
                yield return(WaitForSecondsOrClick(WaitLifeSeconds));

                bonus += LifeBonusPoint;
                GameParams.AddScore(LifeBonusPoint);
                SoundController.Play(SoundController.SeType.Click);
                GameParams.LifeDecrement();
                GameManager.instance.LifeBonusText($"{LifeBonusPrefix}{bonus,5}</mspace>");
            }
        }
Esempio n. 5
0
        private void FixedUpdate()
        {
            if (!CanMove)
            {
                rb.velocity = Vector2.zero;
                return;
            }

            bool isSucked = suiyose.Suck();

            switch (state)
            {
            case StateType.Move:
                // 縮小チェック
                EnemyInBlackhole.StateType instate = enemyInBlackhole.FixedUpdateState();
                if (instate == EnemyInBlackhole.StateType.In)
                {
                    anim.SetInteger("State", (int)AnimType.Blackhole);
                    anim.SetFloat("Speed", 1);
                    state = StateType.Blackhole;

                    lastSucked = true;
                    break;
                }
                // 吸い寄せされていたら、歩きはキャンセルして、吸い寄せ
                if (isSucked)
                {
                    lastSucked = true;
                    anim.SetInteger("State", (int)AnimType.Sucked);
                    break;
                }

                if (lastSucked)
                {
                    // 吸い寄せられていたら、歩き速度未満になるまでは歩きに復帰しない
                    float spd = rb.velocity.magnitude;
                    if (spd >= walkSpeed)
                    {
                        break;
                    }
                }
                lastSucked = false;
                UpdateMove();
                break;

            case StateType.Blackhole:
                lastSucked = true;

                // 吸い込まれのチェック
                EnemyInBlackhole.StateType st = enemyInBlackhole.FixedUpdateState();
                if (st == EnemyInBlackhole.StateType.InDone)
                {
                    // 吸い込まれが完了した
                    ToSweets();
                    GameParams.AddScore(point);
                    Destroy(gameObject);
                }
                else if (st == EnemyInBlackhole.StateType.None)
                {
                    // 戻った
                    state = StateType.Move;
                    UpdateMove();
                }

                break;
            }
        }