// Use this for initialization void Start() { if (buildingLocations == null) { buildingLocations = new List <Vertex> (); } freeBois = new List <SmolMan>(); busyBois = new List <SmolMan>(); if (huts == null) { huts = new List <Vertex> (); } goods = new Dictionary <string, int> (); SphereTerrain terrain = FindObjectOfType <SphereTerrain> (); setCampfireVertex(terrain.getVertex(terrain.findIndexOfNearest(gameObject.transform.position))); AddBois(5); GetComponent <TierController>().FireBuilt(); }
public void setPath() { path = AStar.FindPath(sphere.getVertex(sphere.findIndexOfNearest(transform.position)), targetGoal, this.gameObject); if (path != null && path.Count > 1) { curIndex = 0; curTarget = path[1]; disabled = false; } else if (path != null && path.Count == 1) { curTarget = path[0]; disabled = false; } else { disabled = true; } }
// Update is called once per frame void Update() { if (Input.GetMouseButton(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hitInfo; int layerMask = 1 << 8; if (Physics.Raycast(ray, out hitInfo, layerMask)) { if (downInPreviousFrame) { if (isDragActive) { //(GameObject.FindObjectOfType(typeof(MusicController)) as MusicController).PlaceSingle(); } else { isDragActive = true; //(GameObject.FindObjectOfType(typeof(MusicController)) as MusicController).StartPlacing(); } } downInPreviousFrame = true; } } else { if (isDragActive) { isDragActive = false; (GameObject.FindObjectOfType(typeof(MusicController)) as MusicController).SetFading(); } downInPreviousFrame = false; } if (Input.GetMouseButton(0) && buffer > maxBuffer) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hitInfo; int layerMask = 1 << 8; if (Physics.Raycast(ray, out hitInfo, layerMask)) { switch (curType) { case BuildType.Terrain: st.incHeightAtIndex(st.findIndexOfNearest(hitInfo.point), incrDir * 0.1f); break; case BuildType.Smooth: st.setHeightAtIndex(st.findIndexOfNearest(hitInfo.point), 0.0f); break; case BuildType.Water: st.waterAtIndex(st.findIndexOfNearest(hitInfo.point)); break; case BuildType.Stone: st.StoneAtIndex(st.findIndexOfNearest(hitInfo.point)); break; case BuildType.Sand: st.SandAtIndex(st.findIndexOfNearest(hitInfo.point)); break; case BuildType.Tree: st.TreeAtIndex(st.findIndexOfNearest(hitInfo.point)); break; case BuildType.Wheat: st.WheatAtIndex(st.findIndexOfNearest(hitInfo.point)); break; case BuildType.Oil: st.OilAtIndex(st.findIndexOfNearest(hitInfo.point)); break; case BuildType.Iron: st.IronAtIndex(st.findIndexOfNearest(hitInfo.point)); break; case BuildType.Copper: st.CopperAtIndex(st.findIndexOfNearest(hitInfo.point)); break; case BuildType.Coal: st.CoalAtIndex(st.findIndexOfNearest(hitInfo.point)); break; case BuildType.Deiton: st.DeitonAtIndex(st.findIndexOfNearest(hitInfo.point)); break; default: break; } } buffer = 0.0f; } buffer += Time.deltaTime; }