private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Obsticale"))
        {
            //game over
            UiManager.uiManager.GameOverUIState(true);
            UiManager.uiManager.UpdateGameOverScoreUi();
            UiManager.uiManager.CheckForHighscore();
            UiManager.uiManager.SetTime(0);
            joystick.SetActive(false);
            Destroy(other.gameObject);
        }

        if (other.CompareTag("PickUp"))
        {
            //Apply new color
            ObjectColor colorOfThisPickup = other.GetComponent <PickupColor>().pickupColor;
            EM.ChangeStripedBallColor(myMaterial, colorOfThisPickup, true);
            EM.currentPlayerColor = colorOfThisPickup;
            EM.spawnParticles(gameObject, colorOfThisPickup);

            //Collect points

            UiManager.uiManager.AddToScore(pickUpPoints);
            Destroy(other.gameObject);
            //point up
        }

        if (other.CompareTag("CreateGroup1"))
        {
            obstacleSpawner.ResetDstValue();
            Debug.LogError("CreateGroup1");
            obstacleSpawner.SetSpawnerState(SpawnerState.createGroup1);
        }

        if (other.CompareTag("CreateGroup2"))
        {
            Debug.LogError("CreateGroup2");
            obstacleSpawner.SetSpawnerState(SpawnerState.createGroup2);
        }

        if (other.CompareTag("DestroyGroup1"))
        {
            Debug.LogError("DestroyGroup1");
            obstacleSpawner.SetSpawnerState(SpawnerState.destroyGroup1);
        }

        if (other.CompareTag("DestroyGroup2"))
        {
            Debug.LogError("DestroyGroup2");
            obstacleSpawner.SetSpawnerState(SpawnerState.destroyGroup2);
        }
    }
Beispiel #2
0
    // Start is called before the first frame update
    void Start()
    {
        myMaterial = GetComponent <MeshRenderer>().material;
        EM         = EffectManager.instance;

        int colorNumber = Random.Range(1, 4); //Can only produce 1-3

        switch (colorNumber)
        {
        case 1:

            //Blue
            pickupColor = ObjectColor.Blue;
            EM.ChangeStripedBallColor(myMaterial, ObjectColor.Blue, false);
            break;

        case 2:

            //Green
            pickupColor = ObjectColor.Green;
            EM.ChangeStripedBallColor(myMaterial, ObjectColor.Green, false);
            break;

        case 3:

            //Yellow
            pickupColor = ObjectColor.Yellow;
            EM.ChangeStripedBallColor(myMaterial, ObjectColor.Yellow, false);
            break;

        default:

            Debug.Log("Random.range in PickupColor on the pickups is out of bounds");
            break;
        }
    }