Example #1
0
    private void Update()
    {
        if (dying)
        {
            timeSinceDeath += Time.deltaTime;

            if (timeSinceDeath > deathDelay)
            {
                dying = false;
                respawn.RespawnAtCheckpoint();
            }
        }
    }
Example #2
0
    void OnCollisionEnter(Collision collision)
    {
        GameObject gameObject = collision.collider.gameObject;

        // Enemy has hit the Player with a sword
        if (gameObject.name == "EnemySword" && tag == "Player")
        {
            enemyKills++;
            sfx.playSwordClash1();
            Handheld.Vibrate();
            //logger.LogPlayerDeath(transform.position, "Enemy", enemyKills, GameObject.Find("Game").GetComponent<AssignController>().controllerNum);

            foreach (ContactPoint contact in collision.contacts)
            {
                Instantiate(sparks, contact.point, sparks.transform.rotation);
            }

            GameObject enemy = GameObject.Find("Enemy");
            enemy.GetComponent <EnemyScript>().backOff = true;
            respawn.RespawnAtCheckpoint(collision.collider);
        }

        // Player has hit the Enemy with a sword
        if (gameObject.name == "PlayerSword" && tag == "Enemy")
        {
            GameObject player = GameObject.Find("Player");

            if (player.GetComponent <Movement>().attack)
            {
                playerKills++;
                sfx.playSwordClash2();
                logger.LogPlayerKill(player.transform.position, GameObject.Find("Game").GetComponent <AssignController>().controllerNum);

                foreach (ContactPoint contact in collision.contacts)
                {
                    Instantiate(sparks, contact.point, sparks.transform.rotation);
                }

                GameObject enemy = GameObject.Find("Enemy");
                Destroy(enemy);
            }
        }
    }
Example #3
0
    void OnTriggerEnter(Collider collider)
    {
        if (collider.gameObject.CompareTag("Trap") && !respawn.respawnRequest)
        {
            deathCount++;

            //Debug.Log("IsGrounded - OnTriggerEnter() TRAP!: " + collider.gameObject.name);
            respawn.RespawnAtCheckpoint(collider);
        }

        if (collider.gameObject.CompareTag("Ground"))
        {
            //Debug.Log("IsGrounded - OnTriggerEnter(): " + collider.gameObject.name);
            isGrounded.increaseGroundCollisions();
        }

        if (collider.gameObject.CompareTag("Key"))
        {
            hud.GetComponent <TextMeshProUGUI>().text = "Keys: " + (++keys).ToString() + " / 3";
            //Debug.Log("IsGrounded - OnTriggerEnter() KEY!: " + collider.gameObject.name);

            GameObject.Find("FireI" + (progress.playthrough).ToString()).GetComponent <ParticleSystem>().Play();

            Destroy(collider.gameObject);
            logger.LogPlayerGK(player.transform.position, GameObject.Find("Game").GetComponent <AssignController>().controllerNum);

            sfx.playKeySound();

            if (progress.playthrough < 3)
            {
                respawn.RespawnAtBeginning();
            }

            if (respawn.newPlaythrough && progress.playthrough < 3)
            {
                progress.PlayerGotKey();
            }
        }
    }