예제 #1
0
    void Update()
    {
        if (!canvasInitialised_)
        {
            if (diseaseRef_)
            {
                diseaseNameText_.text = diseaseRef_.diseaseName_ + " - " + diseaseRef_.GetComponent <WheelDrive>().playerId;

                canvasInitialised_ = true;
            }
        }
    }
예제 #2
0
    void CreatePlayer(int playerId)
    {
        BaseDisease diseasePrefab = baseDiseasePrefab_;

        int val = Random.Range(1, 6);

        switch (val)
        {
        case 1:
            diseasePrefab = blackDeathPrefab_;
            break;

        case 2:
            diseasePrefab = SyphilisPrefab_;
            break;

        case 3:
            diseasePrefab = ChlamydiaPrefab_;
            break;

        case 4:
            diseasePrefab = EcoliPrefab_;
            break;

        case 5:
            diseasePrefab = MadCowPrefab_;
            break;

        default:
            Debug.LogError("You f****d up");
            break;
        }


        BaseDisease disease = Instantiate(diseasePrefab, GetSpawnPoint().position, Quaternion.identity);
        var         motor   = disease.GetComponent <WheelDrive>();

        motor.playerId = playerId;

        var camera = Instantiate(splitCameraPrefab_, disease.transform);

        switch (playerId)
        {
        case 0:
            camera.GetComponent <Camera>().rect = new Rect(0, 0.5f, 1, 0.5f);
            break;

        case 1:
            camera.GetComponent <Camera>().rect = new Rect(0, 0, 1, 0.5f);
            break;

        default:
            Debug.LogError("unable to setup split screen camera");
            break;
        }

        camera.GetComponentInChildren <SplitCanvas>().diseaseRef_ = disease;

        camera.GetComponent <FollowCamera>().target = disease.gameObject;

        cameras_.Add(camera.GetComponent <Camera>());

        diseases_.Add(disease);
    }