示例#1
0
    void Update()
    {
        int enemies = NumEnemies();

        if (enemyCountText != null)
        {
            enemyCountText.text = enemies + "";
        }

        if (timekeeper.getTime() > nextSpawnTime)
        {
            waveStartTime = nextSpawnTime + 0.5f;
            nextSpawnTime = 99999999999999;
            spawnSystem.Spawn(wave++);
        }
        else if ((enemies > 0) || (timekeeper.getTime() < waveStartTime))
        {
            return;
        }
        else
        {
            nextSpawnTime = Mathf.Min(nextSpawnTime,
                                      timekeeper.getTime() + secondsBetweenWaves);
        }
    }
示例#2
0
 void Update()
 {
     if (hasEntered == true)
     {
         if ((timekeeper.getTime() - startTime) > 0.90 * minimumLoadingTime && menuLoad == null)
         {
             Debug.Log("canLoad");
             menuLoad = SceneManager.LoadSceneAsync(transitionScene);
         }
         float progress = (Mathf.Min((timekeeper.getTime() - startTime) / minimumLoadingTime, 0.9f) +
                           (0.1f * (menuLoad == null ? 0 : menuLoad.progress))) * 100;
         loadingText.text = "Loading " + Mathf.RoundToInt(progress) + "%";
     }
 }
示例#3
0
    void OnTriggerEnter2D(Collider2D other)
    {
        // Check the provided Collider2D parameter other to see if it is tagged
        // "PickUp", if it is...

        if (other.gameObject.CompareTag("Player"))
        {
            timekeeper = Timekeeper.getInstance();
            startTime  = timekeeper.getTime();
            hasEntered = true;
        }
    }
示例#4
0
    // Update is called once per frame
    void Update()
    {
        if (controllerSystem.state != PlayerControllerSystem.State.traveling)
        {
            return;
        }

        if (timekeeper.getTime() <= waveController.waveStartTime)
        {
            // Done rewinding
            controllerSystem.underControl = true;
            controllerSystem.willStartWalking();
            return;
        }

        controllerSystem.underControl = false;

        // rewinds at the speed of rewindingSpeed;
        timekeeper.immediateOffset(Time.deltaTime * rewindingSpeed * -1);
    }
    // FixedUpdate is called at a fixed interval and is independent of frame rate.
    // Put physics code here.
    void FixedUpdate()
    {
        if (timekeeper == null)
        {
            timekeeper = Timekeeper.getInstance();
        }

        if (!underControl)
        {
            return;
        }


        bool travel = Input.GetKeyUp("space");

        switch (state)
        {
        case State.walking:

            if (travel && (chargeComponent.chargesLeft >= 1))
            {
                lastPressTime = timekeeper.getTime();
                willStartTraveling();
            }

            // only accept input after a cooldown
            if ((timekeeper.getTime() - lastPressTime) < cooldown)
            {
                // walking.progress
                memComponent.advance(Time.deltaTime / cooldown);
                return;
            }
            memComponent.position = memComponent.destPosition;
            memComponent.progress = 0;

            // Store the current horizontal input in the float moveHorizontal.
            float horizontalAxis = Input.GetAxis("Horizontal");

            // Store the current vertical input in the float moveVertical.
            float verticalAxis = Input.GetAxis("Vertical");

            if (horizontalAxis != 0)
            {
                int moveHorizontal = (horizontalAxis > 0) ? 1 : -1;
                memComponent.turnTowards(1 - moveHorizontal);

                if ((horizontalAxis >= 1.0f) || (horizontalAxis <= -1.0f))
                {
                    lastPressTime = timekeeper.getTime();

                    // direction = 1 if right (moveHorizontal  =1)
                    // direction = 3 if left (moveHorizontal = -1)
                    memComponent.deltaPosition(0, moveHorizontal, 1 - moveHorizontal);
                }
            }
            else if (verticalAxis != 0)
            {
                int moveVertical = (verticalAxis > 0) ? 1 : -1;
                memComponent.turnTowards(2 - moveVertical);

                if ((verticalAxis >= 1.0f) || (verticalAxis <= -1.0f))
                {
                    // direction = 2 if up (moveVertical  =1)
                    // direction = 4 if down (moveVertical = -1)
                    lastPressTime = timekeeper.getTime();
                    memComponent.deltaPosition(moveVertical, 0, 2 - moveVertical);
                }
            }
            break;

        // Handle transitions
        case State.transitioning:
            memComponent.progress += Time.deltaTime / transitionTime;

            if (memComponent.progress < 1)
            {
                return;
            }

            // Finished transition
            if (memComponent.state == Memory.MemoryEvent.appearing)
            {
                startWalking();
                return;
            }
            else if (memComponent.state == Memory.MemoryEvent.disappearing)
            {
                startTraveling();
                return;
            }
            else
            {
                Debug.Log("Invalid state in PlayerControllerSystem");
            }
            break;
        }
    }