Beispiel #1
0
    void Update()
    {
        if (forceCount >= SUPER_FORCE_COUNT)
        {
            AddForceItem(-SUPER_FORCE_COUNT);
            state = ForceState.SUPER;
            playerControl.OnStartSuperForce();
        }

        if (SuperForceTimer < 0)
        {
            state           = ForceState.ATTRACT;
            SuperForceTimer = MAX_SUPER_TIME;
            playerControl.OnFinishSuperForce();
            forceEffect.Stop();
        }

        int sign = 1;

        switch (state)
        {
        case ForceState.ATTRACT:
        {
            sign = 1;
        }
        break;

        case ForceState.PUSHOUT:
        {
            sign = -1;
        }
        break;

        case ForceState.SUPER:
        {
            sign             = 1;
            SuperForceTimer -= Time.deltaTime;
            gameRoot.ResetTime();

            if (!forceEffect.isPlaying)
            {
                forceEffect.Play();
            }
        }
        break;

        default:
        {
            sign = 0;
        }
        break;
        }

        foreach (var obj in forceObjects)
        {
            if (state == ForceState.SUPER)
            {
                if (obj.tag != null)
                {
                    bool value = false;
                    if (tagSignMap.TryGetValue(obj.tag, out value))
                    {
                        if (value)
                        {
                            sign = 1;
                        }
                        else
                        {
                            sign = -1;
                        }
                    }
                }
            }

            Vector3 dir = (gameObject.transform.position - obj.transform.position).normalized * sign;
            obj.Move(dir);
        }
    }