Beispiel #1
0
        private void Update()
        {
            if (isFreezed)
            {
                return;
            }

            ObserveCamera camera = Globals.instance.observeCamera;

            transform.rotation = Quaternion.LookRotation(parent.faceNormal, camera.transform.position - parent.faceCenter);

            if (isCrazy)
            {
                crazyTimer -= Time.deltaTime;
                if (crazyTimer < -FLASH_DURATION)
                {
                    crazyTimer = Random.Range(FLASH_PERIOD_MIN, FLASH_PERIOD_MAX);
                    SetFlagType(FlagType.Normal);
                }
                else if (crazyTimer < 0)
                {
                    SetFlagType(FlagType.Hightlighted);
                }
            }
        }
        private void Update()
        {
            if (isFreezed)
            {
                return;
            }

            if (!isCrazy)
            {
                ObserveCamera camera      = Globals.instance.observeCamera;
                Vector3       cameraRight = Vector3.Cross(camera.transform.up, parent.faceCenter - camera.transform.position);
                transform.rotation      = Quaternion.LookRotation(-parent.faceNormal, Vector3.Cross(cameraRight, parent.faceNormal));
                transform.localPosition = originalPosition;
                spinningSpeed           = 0;
                waveFactor = 0;
            }
            else
            {
                spinningSpeed          += (Random.Range(0f, 1f) - spinningSpeed / MAX_SPINNING_SPEED) * MAX_SPINNING_ACCELERATION * Time.deltaTime;
                waveFactor             += spinningSpeed * Time.deltaTime;
                transform.rotation      = Quaternion.AngleAxis(spinningSpeed * Time.deltaTime, parent.faceNormal) * transform.rotation;
                transform.localPosition = (FLOATING_DISTANCE + WAVE_HEIGHT * (-Mathf.Cos(waveFactor / WAVE_PERIOD * Mathf.PI * 2) + 1)) * parent.faceNormal;
            }
        }