// Update is called once per frame void Update() { if (!MECH_MasterControls.GamePaused) { if (atTrash) { Vector3 direction = (EnemyTarget.pos - transform.position).normalized; transform.position += direction * Time.deltaTime * mSpeed; if ((EnemyTarget.pos - transform.position).magnitude < 2.7f) { DiggingScript.HurtTrash(10); damage(mHealth); } } else { Vector3 direction = (target.position - transform.position).normalized; transform.position += direction * Time.deltaTime * mSpeed; if (Vector3.Distance(target.position, transform.position) < 0.5f) { GetNextWaypoint(); } } if (attackTimer > 0) { attackTimer -= Time.deltaTime; } } }
void Update() { timer -= Time.deltaTime; if (timer <= 0) { timer = timeBetweenDigs; DiggingScript.AddTrash(5); } }
void Update() { if (Input.GetMouseButtonDown(1)) { Ray mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(mouseRay, out hit, 500.0f)) { if (current >= 0 && buildables[current].cost <= DiggingScript.Trash && hit.collider.tag != "Buildable") { if (buildables[current].requiredRank == 0) { ; } Vector3Int at = tm.WorldToCell(hit.point); Tile clicked = (Tile)tm.GetTile(at); if (buildables[current].buildableOn.Contains(clicked)) { DiggingScript.SpendTrash(buildables[current].cost); GameObject go = Instantiate(buildables[current], tm.CellToWorld(at) + new Vector3(0.5f, 0.5f), Quaternion.identity).gameObject; Instantiate(BuilderCollider, go.transform); } } else if (current == -2) { if (hit.collider.tag == BuilderCollider.tag) { hit.transform.parent.GetComponent <Buildables>().Remove(); } } } } if (Input.GetMouseButtonDown(2)) { current = -1; } if (Input.GetKeyDown(KeyCode.BackQuote)) { current = -2; } for (int i = 0; i < buildables.Length; i++) { if (Input.GetKeyDown("" + (i + 1))) { current = i; } } }
public override void Remove() { DiggingScript.MaxTrash -= 50; DiggingScript.AddTrash(0); GameObject.Destroy(gameObject); }