void Update() { if (canReset) { if (Input.GetKeyDown(KeyCode.R)) { SceneManager.LoadScene("mainLabScene"); tileCounter = 0; } } if (tileCounter < tileLimit) { float randNo = Random.Range(0f, 1f); if (randNo < ltCutoff) { transform.Rotate(0, 90f, 0); } else if (randNo < rtCutoff) { transform.Rotate(0, -90f, 0); } else if (randNo > newFinderCutoff) { Pathmaker fT = Instantiate(pathmakerSpherePrefab, transform.position, transform.rotation); fT.tileLimit = tileLimit; fT.ltCutoff = ltCutoff; fT.rtCutoff = rtCutoff; fT.newFinderCutoff = newFinderCutoff; fT.floorPrefab1 = floorPrefab1; fT.floorPrefab2 = floorPrefab2; fT.floorPrefab3 = floorPrefab3; fT.canReset = false; fT.pathmakerSpherePrefab = pathmakerSpherePrefab; } if (!Physics.CheckSphere(transform.position, 1)) { if (Random.Range(0, 3) == 0) { Transform floorTile = Instantiate(floorPrefab1, transform.position, Quaternion.identity); } else if (Random.Range(0, 3) == 1) { Transform floorTile = Instantiate(floorPrefab2, transform.position, Quaternion.identity); } else { Transform floorTile = Instantiate(floorPrefab3, transform.position, Quaternion.identity); } //floorTileList[tileCounter] = floorTile; tileCounter++; } transform.position += transform.forward * 5f; } else { } }
// Start is called before the first frame update void Start() { pathmaker = GetComponent <Pathmaker>(); // Get our pathmaker TimeTicker.Instance.AddOnTimeTickDelegate(SpawnGoblin, SpawnTickRate); // Plug us into the time ticker event levels = SpawnFile.text.Split(new string[] { "\r\n\r\n" }, StringSplitOptions.RemoveEmptyEntries); if (Instance == null) { Instance = this; } }
public Map() { Entities = new ConcurrentDictionary <int, Entity>(); Interactives = new ConcurrentDictionary <int, InteractivObject>(); Pathmaker = new Pathmaker(); }
// Update is called once per frame void Update() { if (counter < 50) { //Code for random direction float randomNumber = Random.value; if (randomNumber < turnChance) { //transform.rotation = Quaternion.Euler(transform.eulerAngles + new Vector3(0, 90, 0)); transform.Rotate(new Vector3(0, 90, 0)); } else if (randomNumber >= turnChance && randomNumber < turnChance * 2) { //transform.rotation = Quaternion.Euler(transform.eulerAngles - new Vector3(0, 90, 0)); transform.Rotate(new Vector3(0, -90, 0)); } else if (randomNumber >= (1.0f - spawnChance) && randomNumber <= 1.0f) { if (manager.count < manager.max) { Object temp = Instantiate(pathmakerPrefab, transform.position, Quaternion.identity); Transform obj = temp as Transform; Pathmaker script = obj.GetComponent <Pathmaker>(); script.turnChance = turnChance; script.spawnChance = spawnChance; manager.count++; } } //Code for random floor tile randomNumber = Random.value; if (randomNumber < 0.17f) { spawn = floorPrefab3; } else if (randomNumber < 0.34f) { spawn = floorPrefab2; } else if (randomNumber < 0.5f) { spawn = floorPrefab1; } //Code for random floor height randomNumber = Random.value; float heightChange; if (randomNumber < 0.5f) { heightChange = 0; } else if (randomNumber < 0.8f) { heightChange = 3; } else { heightChange = 6; } Object spawnTemp = Instantiate(spawn, transform.position, Quaternion.identity); Transform trans = spawnTemp as Transform; trans.localScale += new Vector3(0, 3 + heightChange, 0); trans.position -= new Vector3(0, 1 - heightChange / 2, 0); transform.position += transform.forward * 5; counter++; } else { Destroy(this); } }
void Start() { pathmakerScript = GameObject.Find("Pathmaker").GetComponent <Pathmaker>(); }
private void Awake() { me = this; }
/// <summary> /// /// </summary> private void Initialize() { var triggers = MapTriggerRepository.Instance.GetTriggers(Id); for (int i = 0; i < Data.Length; i += 10) { string currentCell = Data.Substring(i, 10); var id = i / 10; byte[] cellData = new byte[currentCell.Length]; for (int j = 0; j < currentCell.Length; j++) { cellData[j] = (byte)HASH_CELL.IndexOf(currentCell[j]); } var cell = new MapCell(this, id, cellData, triggers.Find(trigger => trigger.CellId == id)); if(cell.InteractiveObject != null) { AddUpdatable(cell.InteractiveObject); cell.InteractiveObject.AddHandler(Dispatch); m_interactiveObjects.Add(cell.InteractiveObject); } m_cellById.Add(id, cell); m_cells.Add(cell); } Pathmaker = new Pathmaker(this); }