Ejemplo n.º 1
0
    public void Spawn(string path, Vector3 startPos)
    {
        GameObject go;

        go = Instantiate(Resources.Load(path), AuxLib.SetPositionOnRaycastHit2D(startPos, "Terrain", Vector2.down, spawnHeight), Quaternion.identity) as GameObject;
        //Debug.Log("Initial Position Assigned: "+startPos);
    }
Ejemplo n.º 2
0
    void SpawnTrees()
    {
        if (treeSpawnCounter <= 0 && GameCore.Instance.currentStage != Stage.Z_BOSS)
        {
            treeSpawnCounter = Random.Range(1, 6);

            Vector3 spawnPosition       = AuxLib.SetPositionOnRaycastHit2D(new Vector3(transform.position.x - 10, 20, 0), "Terrain", Vector2.down, 1);
            Vector3 spawnPositionCheckR = AuxLib.SetPositionOnRaycastHit2D(new Vector3(spawnPosition.x + 2, 20, 0), "Terrain", Vector2.down, 1);
            Vector3 spawnPositionCheckL = AuxLib.SetPositionOnRaycastHit2D(new Vector3(spawnPosition.x - 2, 20, 0), "Terrain", Vector2.down, 1);

            if (spawnPosition.y >= 20)
            {
                treeSpawnCounter = 0;
            }

            else if (spawnPositionCheckR.y <= spawnPosition.y - 0.4)
            {
                GameObject go = Instantiate(Resources.Load("Prefabs/Assets/Tree_00"), spawnPositionCheckR, Quaternion.identity) as GameObject;
            }

            else if (spawnPositionCheckL.y <= spawnPosition.y - 0.4)
            {
                GameObject go = Instantiate(Resources.Load("Prefabs/Assets/Tree_00"), spawnPositionCheckL, Quaternion.identity) as GameObject;
            }

            else
            {
                GameObject go = Instantiate(Resources.Load("Prefabs/Assets/Tree_00"), spawnPosition, Quaternion.identity) as GameObject;
            }
        }

        treeSpawnCounter -= Time.deltaTime;
    }
Ejemplo n.º 3
0
    void SpawnFlowers()
    {
        if (flowerSpawnCtr <= 0)
        {
            flowerSpawnCtr = Random.Range(minTimeFlower, maxTimeFlower);

            Vector3 spawnPosition       = AuxLib.SetPositionOnRaycastHit2D(new Vector3(transform.position.x - 10, 20, 0), "Terrain", Vector2.down, 1);
            Vector3 spawnPositionCheckR = AuxLib.SetPositionOnRaycastHit2D(new Vector3(spawnPosition.x + 2, 20, 0), "Terrain", Vector2.down, 1);
            Vector3 spawnPositionCheckL = AuxLib.SetPositionOnRaycastHit2D(new Vector3(spawnPosition.x - 2, 20, 0), "Terrain", Vector2.down, 1);

            if (spawnPosition.y >= 20)
            {
                flowerSpawnCtr = 0;
            }

            else if (spawnPositionCheckR.y <= spawnPosition.y - 0.4)
            {
                GameObject go = Instantiate(Resources.Load("Prefabs/Interactable/Flower"), spawnPositionCheckR, Quaternion.identity) as GameObject;
            }

            else if (spawnPositionCheckL.y <= spawnPosition.y - 0.4)
            {
                GameObject go = Instantiate(Resources.Load("Prefabs/Interactable/Flower"), spawnPositionCheckL, Quaternion.identity) as GameObject;
            }

            else
            {
                GameObject go = Instantiate(Resources.Load("Prefabs/Interactable/Flower"), spawnPosition, Quaternion.identity) as GameObject;
            }
        }

        flowerSpawnCtr -= Time.deltaTime;
    }
Ejemplo n.º 4
0
    // Update is called once per frame
    void FixedUpdate()
    {
        switch (GameCore.Instance.gameState)
        {
        case GameState.AWAKE:
            break;

        case GameState.PAUSE:
            break;

        case GameState.PLAY:
        {
            if (counter <= 0 && GameCore.Instance.currentStage != WorldConstructor.Stage.Z_BOSS)
            {
                counter     = Random.Range(randomSpawnTimeRange.x, randomSpawnTimeRange.y);
                spawnHeight = Random.Range(3.0f, 7.0f);

                //Debug.Log(GameCore.Instance.player.transform.position);
                Vector3 playerDistance = new Vector3(GameCore.Instance.player.transform.position.x + 30, 10, 0);
                Vector3 spawnPosition  = AuxLib.SetPositionOnRaycastHit2D(playerDistance, "Terrain", Vector2.down, spawnHeight);

                if (spawnPosition.y >= 7)
                {
                    counter = 0;
                }
                else
                {
                    GameObject go = Instantiate(Resources.Load("Prefabs/Enemies/Raven"), spawnPosition, Quaternion.identity) as GameObject;
                }
            }

            counter -= Time.deltaTime;
        }
        break;

        case GameState.GAMEOVER:
            break;

        default:
            break;
        }
    }