Ejemplo n.º 1
0
    private void OnTriggerEnter(Collider target)
    {
        if (target.gameObject.tag == "Enemy")
        {
            Destroy(target.gameObject);

            GameController_Script.IncreaseScore(1);
            Debug.Log(GameController_Script.GetScore());
        }
    }
Ejemplo n.º 2
0
    private void OnTriggerEnter(Collider target)
    {
        if (target.gameObject.tag.Contains("Enemy"))
        {
            target.GetComponent <slime_mover>().life--;
            if (target.GetComponent <slime_mover>().life <= 0)
            {
                if (target.gameObject.tag == "Enemy S")
                {
                    GameController_Script.IncreaseScore(1);
                }
                else if (target.gameObject.tag == "Enemy M")
                {
                    GameController_Script.IncreaseScore(2);
                    GameObject slime = Instantiate(smallSlime, transform.position, transform.rotation);
                    slime.GetComponent <slime_mover>().canMerge = false;
                }
                else if (target.gameObject.tag == "Enemy L")
                {
                    GameController_Script.IncreaseScore(3);
                    GameObject slime = Instantiate(mediumSlime, transform.position, transform.rotation);
                    slime.GetComponent <slime_mover>().canMerge = false;
                }

                Debug.Log(GameController_Script.GetScore());

                Destroy(target.gameObject);
            }
            Instantiate(explosion, transform.position, transform.rotation);
            Destroy(gameObject);
        }
        else if (target.gameObject.tag == "BOSS")
        {
            target.GetComponent <slime_boss>().life--;
            if (target.GetComponent <slime_boss>().life <= 0)
            {
                GameController_Script.IncreaseScore(20);
                Debug.Log(GameController_Script.GetScore());

                Destroy(target.gameObject);
            }
            Instantiate(explosion, transform.position, transform.rotation);
            Destroy(gameObject);
        }
    }
Ejemplo n.º 3
0
    private void FixedUpdate()
    {
        if (GameController_Script.GameTime.isPaused)
        {
            return;
        }
        timer++;
        spawnRateTimer++;
        if (spawnRateTimer > 2000 && GameController_Script.GetScore() > 500)
        {
            spawnRate     *= 0.8f;
            spawnRateTimer = 0;
        }


        if (timer > spawnRate)
        {
            timer = 0;
            int        sideSelection = Random.Range(0, 4);
            Quaternion spawnRot      = new Quaternion();
            switch (sideSelection)
            {
            case 0:
                //topside slime spawn
                Vector3 spawnLoc = Camera.main.ViewportToWorldPoint(new Vector3(Random.Range(0.0f, 1.0f), 1, 0));
                spawnLoc.z = 0;

                GameObject slimeTop = Instantiate(slime, spawnLoc, spawnRot);
                break;

            case 1:
                //botside slime spawn
                spawnLoc   = Camera.main.ViewportToWorldPoint(new Vector3(Random.Range(0.0f, 1.0f), 0, 0));
                spawnLoc.z = 0;

                GameObject slimeBot = Instantiate(slime, spawnLoc, spawnRot);
                break;

            case 2:
                //leftside slime spawn
                spawnLoc   = Camera.main.ViewportToWorldPoint(new Vector3(0, Random.Range(0.0f, 1.0f), 0));
                spawnLoc.z = 0;

                GameObject slimeLeft = Instantiate(slime, spawnLoc, spawnRot);
                break;

            case 3:
                //rightside slime spawn
                spawnLoc   = Camera.main.ViewportToWorldPoint(new Vector3(1, Random.Range(0.0f, 1.0f), 0));
                spawnLoc.z = 0;

                GameObject slimeRight = Instantiate(slime, spawnLoc, spawnRot);
                break;
            }
        }
        if (GameController_Script.spawnBoss)
        {
            Quaternion spawnRot = new Quaternion();
            Vector3    spawnLoc = Camera.main.ViewportToWorldPoint(new Vector3(0.51f, 1, 0));
            spawnLoc.z = 0;

            GameObject slimeBoss = Instantiate(boss, spawnLoc, spawnRot);
            GameController_Script.spawnBoss = false;
        }
    }