예제 #1
0
        private GameObject padGreen(Vector3 padPosition)
        {
            GameObject padGreen = Instantiate(level, padPosition, Quaternion.identity);

            padGreen.GetComponent <SpriteRenderer>().sprite = greenPadSprite;
            padGreen.GetComponent <JumpPad>().Type          = JumpPadType.Green;
            padGreen.GetComponent <JumpPad>().SetSpring(false);
            padGreen.GetComponent <JumpPad>().SetRocket(false);

            switch (collectibleType)
            {
            case PadObjectType.SPRING:
                padGreen.GetComponent <JumpPad>().SetSpring(true);
                padGreen.GetComponent <JumpPad>().SetRocket(false);
                break;

            case PadObjectType.ROCKET:
                padGreen.GetComponent <JumpPad>().SetSpring(false);
                padGreen.GetComponent <JumpPad>().SetRocket(true);
                break;
            }

            collectibleType = PadObjectType.NONE;

            return(padGreen);
        }
예제 #2
0
        public GameObject GenerateJumpPad(Vector3 lastPadPosition)
        {
            level = jumpPad;
            count++;
            collectibleType = PadObjectType.NONE;
            Vector3 spawnPosition   = Vector3.zero;
            int     randCollectible = Random.Range(1, 10);

            spawnPosition.x = Random.Range(-2.5f, 2.5f);
            spawnPosition.y = Random.Range(lastPadPosition.y + 0.5f, lastPadPosition.y + 2f);

            if (count % 3 == 0)
            {
                int randomObject = Random.Range(1, 12);
                switch (randomObject)
                {
                case 3:
                    collectibleType = PadObjectType.SPRING;
                    break;

                case 5:
                    collectibleType = PadObjectType.ROCKET;
                    break;
                }
            }

            switch (randCollectible)
            {
            case 3:
                level = padBrown(spawnPosition);
                break;

            case 7:
                level = padBlue(spawnPosition);
                break;

            default:
                level = padGreen(spawnPosition);
                break;
            }

            level.name = "JumpPad";
            level.GetComponent <JumpPad>().JumpPadIndex = count;
            level.SetActive(true);

            return(level);
        }