示例#1
0
    void Update()
    {
        if (_spawnAnimation)
        {
            _animT += Time.deltaTime / translationAnimDuration;
            currentPod.rigidbody.position = Vector3.LerpUnclamped(transform.position, targetPodPos, podTranslationCurve.Evaluate(_animT));
            if (_animT >= 1f)
            {
                currentPod.BeginIdleAnimation();
                _spawnAnimation = false;
            }
        }

        if (podDeployAnimActive)
        {
            if (_podParentAnim <= 1f)
            {
                _podParentAnim += Time.deltaTime / podParentDeployDuration;
                podParent.transform.position = new Vector3 {
                    z = Mathf.Lerp(podParentStartZ, podParentTargetZ, podParentDeployCurve.Evaluate(_podParentAnim))
                };
                if (_podParentAnim >= 1f)
                {
                    currentPod.transform.SetParent(null, worldPositionStays: true);
                    currentPod.rigidbody.constraints = RigidbodyConstraints2D.None;
                    exitingPods.Add(currentPod);
                    currentPod = null;
                    GameManager.instance.GoToWaitState();
                    podDeployAnimActive = false;
                }
            }
        }

        for (int i = 0; i < exitingPods.count; i++)
        {
            var pod = exitingPods[i];
            pod.FireParts();
            pod.rigidbody.AddTorque(Mathf.Sin(Time.time) * 500f * Time.fixedDeltaTime);
            var podXY    = (Vector2)pod.transform.localPosition;
            var anchorXY = (Vector2)targetPodPos;
            var dist     = (anchorXY - podXY).magnitude;
            if (dist > podKillDist)
            {
                pod.SetLayer(podDefaultLayer);
                pod.Kill();
                podDeployAnimActive = false;
                exitingPods.RemoveFast(i);
            }
        }
    }
示例#2
0
    public void NewGame()
    {
        timer.ResetTime();
        podSpawner.SpawnPod();
        activePod                 = podSpawner.currentPod;
        timer.enabled             = true;
        partPickerManager.enabled = true;
        waitingForGameStart       = false;
        titleParent.SetActive(false);
        timerParent.SetActive(true);
        highlightRenderer.enabled = true;


        musicManager.PlayGameStinger();
        musicManager.StopMainMenuMusic();
        musicManager.PlayGameplayMusic();
    }