Beispiel #1
0
    private void GenerateSpawnables(SpawnableLayer layer)
    {
        ForestManager manager = ForestManager.INSTANCE;

        if (manager.chunkCount <= 1 || manager.chunkCount <= layer.minChunkCount)
        {
            return;
        }

        int expectedAmount = 8 + (3 * (manager.waveNr > fibbonacci.Length ? fibbonacci[fibbonacci.Length] : fibbonacci[manager.waveNr]));

        Debug.Log(manager.chunkCount + " - " + expectedAmount + " will be spawned");
        for (int i = 0; i < expectedAmount; i++)
        {
            //spawn at a random spot
            float      x         = transform.position.x + Random.Range(.05f, .95f) * bc.bounds.size.x;
            GameObject spawnable = GameObject.Instantiate(layer.prefab);
            spawnable.transform.position = new Vector2(x, layer.yValue);
            spawnable.transform.parent   = null;
            objects.Add(spawnable);
            EnemyKnight enemy = spawnable.GetComponent <EnemyKnight>();
            if (enemy != null)
            {
                enemy.hp = 3 + (manager.waveNr * 2);
            }


            //        }
        }
    }
Beispiel #2
0
 // Use this for initialization
 void Start()
 {
     time = Time.time;
     ForestManager fM = new ForestManager();
        List<ITree> species= new List<ITree>();
     species.Add(tree);
     f = fM.createForest(map, species);
     for (int i = 0; i < 30; i++)
     {
         f.NextYear(10);
         Debug.Log(i.ToString());
     }
 }
Beispiel #3
0
    // Use this for initialization
    void Start()
    {
        time = Time.time;
        ForestManager fM      = new ForestManager();
        List <ITree>  species = new List <ITree>();

        species.Add(tree);
        f = fM.createForest(map, species);
        for (int i = 0; i < 30; i++)
        {
            f.NextYear(10);
            Debug.Log(i.ToString());
        }
    }
Beispiel #4
0
    public void Awake()
    {
        Random.InitState(12080511);
        INSTANCE       = this;
        existingChunks = new List <ForestGenerator>();
        ForestGenerator instance = GameObject.Instantiate(chunkPrefab) as ForestGenerator;

        instance.transform.position = Vector3.right * 0f;
        instance.transform.parent   = transform;
        maxChunk = instance;

        chunkCount++;
        instance.InitChunk(true, 0, 0, 30);
        existingChunks.Add(instance);

        /*
         * GenerateNext();
         */
    }
Beispiel #5
0
    void Awake()
    {
        Time.timeScale = 1;

        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(this.gameObject);
        }

        //TODO: Hand prefabs down to forests, really only when there are other kinds
        //of forest.
        //Spawn forest
        GameObject forestGO = new GameObject("Forest");

        forestGO.transform.position = new Vector3(0, 0, 0);
        forestGO.transform.parent   = transform;
        forest = forestGO.AddComponent <ForestManager>();
        PrepPhase();

        //Spawn agent
        //Raymarching toolkit doesn't support spawning of raymarching objects
        //so to have a raymarched agent, need to put it in the scene beforehand.
        //If it doesn't exist, fall back to prefab.
        //(Blob asset not public)
        GameObject agent = GameObject.FindGameObjectWithTag("agent");

        if (agent == null)
        {
            agent = Instantiate(agentPrefab);
            agent.transform.parent = GameObject.Find("ground").transform;
        }
        agent.transform.localPosition = agentInitialPosition;
        agent.transform.eulerAngles   = agentInitialEulerRotation;


        ac        = agent.AddComponent <AgentController>();
        ac.forest = forest;

        GameObject home = GameObject.Find("home");

        if (home == null)
        {
            home = Instantiate(homePrefab);
            //home.transform.position = new Vector3(10, 0, 10);
            home.transform.parent = transform;
        }
        //TODO: Changing this for the demo instead of making a whole animation to go
        //in the house.
        //Old, good for now code: ac.home = home;
        //Bad, only for the demo code:
        GameObject tempHome = new GameObject("temp home");

        tempHome.transform.position = ac.transform.position;
        ac.home = tempHome;

        GameObject box = GameObject.Find("box");

        if (box == null)
        {
            box = Instantiate(boxPrefab);
            //box.transform.position = new Vector3(10, 0, 10);
            //box.transform.parent = home.transform;
            box.transform.SetParent(home.transform, false);
        }
        ac.box = box;
    }
 // Start is called before the first frame update
 void Start()
 {
     instance = this;
     GenerateStartingForest();
 }
Beispiel #7
0
    // Start is called before the first frame update
    public void InitChunk(bool spawnCheckpoint, int amount, int waveNr, float xOffset)
    {
        objects = new List <GameObject>();

        ForestManager manager = ForestManager.INSTANCE;

        UnlockLeft();
        UnlockRight();
        cam = Camera.main.gameObject;
        //  bc = GetComponent<BoxCollider2D>();
        foreach (ForestLayer layer in forestLayers)
        {
            switch (layer.parallaxLayer)
            {
            case 0:
                layer.parent = manager.front;
                break;

            case 1:
                layer.parent = manager.back1;
                break;

            case 2:
                layer.parent = manager.back2;
                break;

            default:
                layer.parent = manager.back3;
                break;
            }

            GenerateTrees(layer);
        }

        foreach (SpawnableLayer layer in spawnableLayers)
        {
            if (spawnCheckpoint && !layer.allowInSpawnZone)
            {
                //TODO move it to the next or previous?
            }
            else
            {
                GenerateSpawnables(layer);
            }
        }

        // spawn a house if needed
        if (spawnCheckpoint)
        {
            GameObject checkPoint = waveNr == finalLevel?GameObject.Instantiate(EndPointPrefab) : GameObject.Instantiate(CheckPointPrefab);

            objects.Add(checkPoint);
            if (waveNr == finalLevel)
            {
                HintsController.INSTANCE?.ShowText("The castle is right up ahead ! Let's go !");
            }
            //  checkPoint.transform.parent = forestLayers[0].parent;

            checkPoint.transform.position = transform.position + (Vector3.right * 22.6f) + (Vector3.up * 4.2f);



            checkPoint.GetComponent <CheckPoint>()?.EnsureDoorIsClear();
        }
        Camera.main.GetComponent <CameraFollow>().onCameraTranslate += Parallax;
    }