Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        pathGenerator = new PathGenerator();

        activeCows = new List <CreatureController>();
        cowPool    = new List <CreatureController>();

        treePool    = new List <ForestController> ();
        activeTrees = new List <ForestController>();

        rockPool    = new List <RockController>();
        activeRocks = new List <RockController>();

        for (var i = 0; i < 30; i++)
        {
            RockController rock = (RockController)Instantiate(rock1Prefab, new Vector3(-1000, 0, 0), Quaternion.identity);
            rockPool.Add(rock);
        }

        //Populate the pool of trees

        for (var i = 0; i < 10; i++)
        {
            ForestController forest = (ForestController)Instantiate(forestPrefab, new Vector3(-1000, 0, 0), Quaternion.identity);
            treePool.Add(forest);
        }


        points = pathGenerator.GeneratePath(new Vector2(0, 0));

        //lets get the last cell
        Vector3 firstCell = points[0];
        Vector3 lastCell  = points[points.Count - 1];
        int     numCells  = (int)System.Math.Ceiling((lastCell.x - firstCell.x) / 20f);


        //now


        mazeManager.CreateCells(new Vector3(50, 0, 0), numCells, 10, 20);


        List <Bounds> bounds = mazeManager.GetCellsNotIntersectedBy(points);

        //mazeManager.MarkCellsAsPath(bounds);

        //mazeManager.RenderCells(bounds);


        foreach (RockController rock in rockPool)
        {
            mazeManager.AddToCell(rock, bounds);
        }


        //add the start position
        CreateBarn(new Vector3(100, 0, 0));
    }
 private void Awake()
 {
     if (Instance)
     {
         Destroy(gameObject);
     }
     else
     {
         ForestController.Instance = this;
     }
 }
	private void Awake()
	{
		if (Instance)
		{
			Destroy(gameObject);
		}
		else
		{
			ForestController.Instance = this;
		}
	}
Exemplo n.º 4
0
    private void Start()
    {
        _controller           = GameObject.Find("Forest Controller").GetComponent <ForestController>();
        _transform            = GetComponentInChildren <Transform>();
        _transform.localScale = new Vector2(xScale, 0.75f);
        _collider             = GetComponent <BoxCollider2D>();

        // If the branch is on the right tree, flip its sprite and collider.
        if (_transform.position.x > 0f)
        {
            GetComponent <SpriteRenderer>().flipX = true;
            _collider.offset = new Vector2(-_collider.offset.x, _collider.offset.y);
        }

        IsGrowing  = true;
        _isFading  = false;
        _storedSap = 0;
        _finishedInitialGrowing = false;
    }
Exemplo n.º 5
0
 private void Start()
 {
     _controller = GameObject.Find("Forest Controller").GetComponent <ForestController>();
 }
Exemplo n.º 6
0
 public void RemoveTreeFromScene(ForestController tree)
 {
     activeTrees.Remove(tree);
     treePool.Add(tree);
     tree.GetTransform().position = new Vector3(0, 0, -1000);
 }
Exemplo n.º 7
0
 private void Start()
 {
     _forest = GameObject.Find("Forest Controller").GetComponent <ForestController>();
     _cursor = CursorOption.Undefined;
 }
 public void Start()
 {
     this.anim   = gameObject.GetComponent <Animator>();
     this.forest = this.GetComponentInParent <ForestController>();
 }