Beispiel #1
0
    void OnTriggerEnter(Collider other)
    {
        if (transform.position.z <= 15 && transform.position.x < 7.5 && transform.position.x > -7.5)
        {
            GameObject      gameControllerObject = GameObject.FindGameObjectWithTag("GameController");
            ItemsController itemController       = gameControllerObject.GetComponent <ItemsController> ();
            UIController    uiController         = gameControllerObject.GetComponent <UIController> ();

            switch (other.tag)
            {
            case "Player":
                if (owner == "Enemies")
                {
                    Hit();
                    PlayerController shipScript = other.GetComponent <PlayerController> ();
                    shipScript.IsHitted(Damage);
                }
                break;

            case "Lore":
                if (owner == "Player")
                {
                    Hit();
                    Lore loreScript = other.GetComponent <Lore> ();
                    if (loreScript.IsHitted(Damage) == Constants.DEAD)
                    {
                        uiController.AddScore(Constants.INDEXSCORETLORES, Constants.INDEXSCORESSHOT, false, 0);
                        itemController.spawnItem(other.transform);
                    }
                }
                break;

            case "Enemies":
                if (owner == "Player")
                {
                    Hit();
                    EnemyController shipScript = other.GetComponent <EnemyController> ();
                    if (shipScript.IsHitted(Damage) == Constants.DEAD)
                    {
                        uiController.AddScore(shipScript.indexScoreEnemy, Constants.INDEXSCORESSHOT, false, 0);
                        itemController.spawnItem(other.transform);
                    }
                }
                break;

            default:
                break;
            }
        }
    }
Beispiel #2
0
    private void hasCollide(Collider other)
    {
        GameObject      gameControllerObject = GameObject.FindGameObjectWithTag("GameController");
        ItemsController itemController       = gameControllerObject.GetComponent <ItemsController>();
        UIController    uiController         = gameControllerObject.GetComponent <UIController>();

        switch (other.tag)
        {
        case "Player":
            break;

        case "Lore":
            Lore loreScript = other.GetComponent <Lore>();
            if (loreScript.IsHitted(loreScript.GetHealth()) == Constants.DEAD)
            {
                uiController.AddScore(Constants.INDEXSCORETLORES, Constants.INDEXSCORESBOMB, false, 0);
                itemController.spawnItem(other.transform);
            }
            break;

        case "Enemies":
            Ship shipScript = other.GetComponent <Ship>();
            if (shipScript.IsHitted(shipScript.GetHealth()) == Constants.DEAD)
            {
                uiController.AddScore(Constants.INDEXSCORETENEMIES, Constants.INDEXSCORESBOMB, false, 0);
                itemController.spawnItem(other.transform);
            }
            break;

        case "Shot":
            Shot shotScript = other.GetComponent <Shot>();

            if (shotScript.GetOwner() != "Player")
            {
                shotScript.IsDestroyed();
                uiController.AddScore(Constants.INDEXSCORETSHOT, Constants.INDEXSCORESBOMB, false, 0);
            }
            break;

        default:
            break;
        }
    }