示例#1
0
    public void Create()
    {
        GameObject platform           = platforms[platforms.Count - 1];
        GameObject whereToInstantiate = platform.GetComponent <PlatformBehaviour>().whereToPlace;

        bool shufflin   = false;
        bool rotate     = false;
        int  givenColor = Random.Range(0, allMaterials.Count);

        PlatformColors color = (PlatformColors)givenColor;
        Material       mat   = allMaterials[givenColor];

        if (Random.Range(0, 100) < changePercentage)
        {
            int disp = Random.Range(0, 2);
            shufflin = disp == 0 ? true : false;
            rotate   = disp == 1 ? true : false;
        }

        if (Random.Range(0, 100) < changePercentage)
        {
            int disp = Random.Range(0, 2);
            shufflin = disp == 0 ? true : false;
            rotate   = disp == 1 ? true : false;
        }

        GameObject        platInstantiation = Instantiate(platformPrefab);
        PlatformBehaviour behaviour         = platInstantiation.GetComponent <PlatformBehaviour>();

        behaviour.SetUp(rotate, shufflin, mat, color);
        platInstantiation.transform.position = whereToInstantiate.transform.position;
        platforms.Add(platInstantiation);
    }
示例#2
0
    public void Dispatch(PlatformColors color)
    {
        if (!FindObjectOfType <CharacterController>().isGrounded)
        {
            return;
        }

        GameObject platform = platforms[0];

        if (platform && platform.GetComponent <PlatformBehaviour>().color != color)
        {
            FindObjectOfType <CharacterController>().stun();
            livesNumber -= 1;

            switch (livesNumber)
            {
            case 2:
                foreach (GameObject go in firstLive)
                {
                    go.SetActive(false);
                }
                break;

            case 1:
                foreach (GameObject go in secondLive)
                {
                    go.SetActive(false);
                }
                break;

            case 0:
                foreach (GameObject go in thirdLive)
                {
                    go.SetActive(false);
                }
                break;
            }

            if (livesNumber <= 0)
            {
                GameOver("BAD COLOR !", "Too bad...you missed it...");
                return;
            }
            return;
        }

        if (!hasStarted)
        {
            hasStarted = true;
        }

        platformCount++;
        HandlePlatforming();
        Create();
        platforms.RemoveAt(0);
        PlatformBehaviour platformBehave = platform.GetComponent <PlatformBehaviour>();

        FindObjectOfType <CharacterController>().jumpTo(platformBehave.whereToLand.transform);

        if (platformBehave.isRotating && timeRotate <= 0f)
        {
            Camera.main.transform.rotation = Quaternion.Euler(0, 0, 180);
            timeRotate += 5f;
        }

        if (platformBehave.isShuffling)
        {
            ShuffleButtons();
        }
    }