void OnTriggerEnter(Collider Collider)
    {
        // ON TOP OF DEATH TRIGGER
        if (Collider.gameObject.tag.Contains("DeathTrigger"))
        {
            PlayerScript.SetHealth(0);
        }
        // FULL TRIGGER CHECKPOINT
        else if (Collider.gameObject.name.Contains("Checkpoint"))
        {
            CheckpointBehavior CheckpointBehavior = Collider.gameObject.GetComponent <CheckpointBehavior>();
            CheckpointsHolder.ActivateCheckPointWithNumber(CheckpointBehavior.GetCheckpointNumber());
            HUD.Message.text = "Checkpoint " + CheckpointBehavior.GetCheckpointNumber() + " activated!";
        }

        PlayerActions PlayerActions = PlayerGO.GetComponent <PlayerActions>();
        PickUp        Potion;

        if (Collider.gameObject.name.Contains("ManaPotion"))
        {
            HUD.Message.text = "Picked Up Mana Potion";
            Potion           = GameObject.Find("ManaPotion").GetComponent <PickUp>();
            PlayerActions.PickUpMana(Potion);
        }
        else if (Collider.gameObject.name.Contains("HealthPotion"))
        {
            HUD.Message.text = "Picked Up Health Potion";
            Potion           = GameObject.Find("HealthPotion").GetComponent <PickUp>();
            PlayerActions.PickUpHealth(Potion);
        }
    }
Exemplo n.º 2
0
    void OnTriggerEnter(Collider col)
    {
        if (col.CompareTag("DeathZone"))
        {   // "kill" the player and respawn him to the last validated checkpoint
            // reset all variables
            moveDir                 = Vector3.zero;
            prevMoveDir             = Vector3.zero;
            previousAirControlDir   = Vector3.zero;
            previousWallWalltricked = null;
            playerState             = PlayerState.running;

            // teleport player
            GameObject restartCheckpoint = CheckpointBehavior.getRestartCheckpoint();
            if (restartCheckpoint == null)
            {   // if no checkpoint has been reached => respawn player to his start location
                transform.position = spawnTransformPosition;
                mouseLook.Init(transform, spawnCameraTransform);
            }
            else
            {   // else respawn him to his last validated checkpoint
                transform.position = restartCheckpoint.transform.position;
                mouseLook.Init(transform, restartCheckpoint.transform);
            }
        }
        else if (col.gameObject.CompareTag("Enemy"))
        {
            playerState = PlayerState.jumping;
            Destroy(col.gameObject);
        }
    }
Exemplo n.º 3
0
    public void printSectionTimeTable()
    {
        Debug.Log("game over");
        // freeze/slowDown the game
        Time.timeScale = 0.01f; // can't set timescale to 0 ... because Unity

        // claim back the cursor
        parkourFPSController pkScript = GameObject.Find("FPSController").GetComponent <parkourFPSController>();

        pkScript.mouseLook.lockCursor   = false;
        pkScript.mouseLook.XSensitivity = 0;
        pkScript.mouseLook.YSensitivity = 0;

        // clean the UI and print each time per section
        GameObject.Find("SpeedOMeter").SetActive(false);
        GameObject.Find("DebugZone").SetActive(false);
        GameObject.Find("Timer").SetActive(false);

        int sectionEntry = 0;

        foreach (float time in CheckpointBehavior.getCheckpointTimeTable())
        {
            string minutes   = ((int)time / 60).ToString();
            string seconds   = (time % 60).ToString("F2");
            string timeEntry = "Section" + sectionEntry + " : " + minutes + ":" + seconds + "\n";
            SectionTimeTableText.text += timeEntry;
            sectionEntry++;
        }

        SectionTimeTableText.text += "\n Press e to return to main menu";
    }
Exemplo n.º 4
0
    // Things to do when a level is loaded
    private void OnLevelWasLoaded(int level)
    {
        _currentLevel = level;

        if (level != 0)
        {
            _inGame    = true;
            _playeTime = 0.0f;

            if (SOSaveHandler.CheckpointID == 0)
            {
                GameObject player = SpawnPlayer();

                if (level == 1)
                {
                    player.GetComponentInChildren <WeaponSelect>().MGAvailable = true;
                    player.GetComponentInChildren <WeaponSelect>().SGAvailable = false;
                    _IM.StopInput();
                }
            }
            else
            {
                SpawnPlayer();
                GameObject[] checkpoints = GameObject.FindGameObjectsWithTag("Checkpoint");
                GameObject   camera      = GameObject.FindGameObjectWithTag("SmartCamera");

                foreach (GameObject ckpt in checkpoints)
                {
                    if (ckpt.GetComponent <CheckpointBehavior>().ID == SOSaveHandler.CheckpointID)
                    {
                        CheckpointBehavior ckptBehavior = ckpt.GetComponent <CheckpointBehavior>();

                        ckptBehavior.Activate();
                        camera.transform.position = ckptBehavior.cameraPos;

                        if (ckptBehavior.smartXEnabled)
                        {
                            camera.GetComponent <SmartCameraXPosition>().enabled = true;
                        }
                        else
                        {
                            camera.GetComponent <SmartCameraXPosition>().enabled = false;
                        }
                        if (ckptBehavior.smartYEnabled)
                        {
                            camera.GetComponent <SmartCameraYPosition>().enabled = true;
                        }
                        else
                        {
                            camera.GetComponent <SmartCameraYPosition>().enabled = false;
                        }
                    }
                }
            }
        }
        else if (level == 0)
        {
            _inGame = false;
        }
    }
Exemplo n.º 5
0
 public void ActivateCheckPointWithNumber(int CheckpointNumber) // Deactivates the rest
 {
     foreach (GameObject CP in Checkpoints)
     {
         CheckpointBehavior CheckpointBehavior = (CheckpointBehavior)CP.GetComponent <CheckpointBehavior>();
         if (CheckpointBehavior.GetCheckpointNumber() == CheckpointNumber)
         {
             CheckpointBehavior.ActivateCheckpoint();
             CP.renderer.material.color = Color.red;
         }
         else
         {
             CheckpointBehavior.DeactivateCheckpoint();
             CP.renderer.material.color = Color.white;
         }
     }
 }
Exemplo n.º 6
0
    public Vector3 SpawnPlayerAtActiveCheckpoint()
    {
        Vector3 CheckpointToSpawnAt = Vector3.zero;

        foreach (GameObject CP in Checkpoints)
        {
            CheckpointBehavior CheckpointBehavior = (CheckpointBehavior)CP.GetComponent <CheckpointBehavior>();
            if (CheckpointBehavior.IsCheckpointActive())
            {
                CheckpointToSpawnAt   = CP.transform.position;
                CheckpointToSpawnAt.x = CheckpointToSpawnAt.x + 2;
            }
        }
        // Make player go back to full life
        Player.SetHealth(50);
        return(CheckpointToSpawnAt);
    }