Пример #1
0
    private GameObject CreatePillar(float x, float z, float s, float h, Color[] ringColor, GameObject obj, bool isAnimate, int ring)
    {
        Vector3 position   = new Vector3(x, transform.position.y, z);
        Color   floorColor = ringColor[0];
        Color   bodyColor  = ringColor[1];

        BiomData biomData = Bioms.instance.GetCurrentBiomData();

        GameObject pillar = Instantiate(obj, position, Quaternion.identity);

        pillar.GetComponent <Pillar>().SetRing(ring);

        // Animations
        if (isAnimate)
        {
            pillar.GetComponent <Animator>().SetTrigger("Appear");
        }

        // Coloring
        Transform pillarModel = pillar.transform.GetChild(0);

        if (obj.tag == "Bounce")
        {
            pillarModel.GetChild(0).GetComponent <Renderer>().material.color = floorColor;
            pillarModel.GetChild(1).GetComponent <Renderer>().material.color = bodyColor;
        }
        pillarModel.localScale = new Vector3(s, h, s);

        // Puddle
        if (Random.value <= biomData.PuddleSpawnChance && obj.tag == "Bounce")
        {
            Puddle puddle = pillarModel.GetChild(0).gameObject.AddComponent(typeof(Puddle)) as Puddle;

            // Text
            Vector3 textSpawnPosition = pillarModel.GetChild(0).position;
            textSpawnPosition = new Vector3(textSpawnPosition.x, textSpawnPosition.y + 0.1f, textSpawnPosition.z);
            GameObject textPuddle = Instantiate(pillarTextObj, textSpawnPosition, Quaternion.identity);
            textPuddle.transform.parent = pillarModel.GetChild(0);

            if (Random.value <= biomData.PuddleBoostChance)
            {
                // Text
                textPuddle.GetComponentInChildren <TMPro.TextMeshProUGUI>().text = (int)(biomData.PuddleBoostPower * 100) + "%";

                puddle.SetPuddleType(Puddle.PuddleTypes.BOOST);
            }
            else
            {
                // Text
                textPuddle.GetComponentInChildren <TMPro.TextMeshProUGUI>().text = (int)(biomData.PuddleSlowPower * 100) + "%";

                puddle.SetPuddleType(Puddle.PuddleTypes.SLOW);
            }
        }

        // Diamonds
        if (Random.value <= biomData.DiamondsSpawnChance && obj.tag == "Bounce")
        {
            GameObject diamond = Diamond.SpawnDiamond(
                biomData.DiamondsVariety,
                Bioms.instance.GetDiamondsPrefabs(),
                Bioms.instance.GetDiamondsProbabilities(),
                pillarModel.GetChild(0));
            diamond.transform.parent = pillarModel;
        }

        return(pillar);
    }