// Update is called once per frame void Update() { if (tool.GetMode() == ToolModes.buildingMode || tool.GetMode() == ToolModes.farmMode) { indicator.SetActive(true); } else { indicator.SetActive(false); } }
IEnumerator runAttack() { if (!(tool.GetMode() == ToolModes.combatMode)) { yield return(null); } else if (Input.GetMouseButtonDown(0)) { checkMelee(); // attackDelay = 1; //yield return new WaitForSeconds(1f); // attackDelay = 0; } }
void Update() { if (multiTool.GetMode() != ToolModes.combatMode) { return; } else { if (Input.GetMouseButtonDown(1)) { GetComponent <ProjectileSpawner>().shootProjectiles = true; } else if (Input.GetMouseButtonUp(1)) { GetComponent <ProjectileSpawner>().shootProjectiles = false; } } }
void Update() { if (!(tool.GetMode() == ToolModes.buildingMode)) { return; } indicatorRenderer.sprite = currentObject.GetComponent <SpriteRenderer>().sprite; GetMouseTile(out int tileX, out int tileY); indicator.transform.position = new Vector2(tileX, tileY); if (InBounds(tileX, tileY) && NearPlayer(tileX, tileY, 4)) { GameObject tileObject = GetComponent <TileLayout>().GetTile(tileX, tileY).getObjectOnTile(); if (tileObject == null) { indicatorRenderer.color = green; if (Input.GetMouseButtonDown(0)) { CreateObject(currentObject, tileX, tileY); } } else { indicatorRenderer.color = orange; if (Input.GetMouseButtonDown(1)) { DestroyObject(tileX, tileY); //PlayAttackAnimation(); } } } else { indicatorRenderer.color = red; } }
private void Update() { if (!(tool.GetMode() == ToolModes.farmMode)) { return; } place.GetMouseTile(out int tileX, out int tileY); indicator.transform.position = new Vector2(tileX, tileY); if (!place.InBounds(tileX, tileY) || !place.NearPlayer(tileX, tileY, 2)) { indicatorRenderer.color = red; return; } if (tileMap.GetTile(new Vector3Int(tileX - 1, tileY - 1, 0)).name != "dirtc") { indicatorRenderer.sprite = tiles[0].sprite; indicatorRenderer.color = green; if (Input.GetMouseButtonDown(1)) { tileMap.SetTile(new Vector3Int(tileX - 1, tileY - 1, 0), tiles[0]); } } else { indicatorRenderer.sprite = plant.GetComponent <SpriteRenderer>().sprite; if (tileLayout.GetTile(tileX, tileY).getObjectOnTile() == null) { indicatorRenderer.color = orange; if (Input.GetMouseButtonDown(0)) { Tutorial.Instance.TriggerDialogue(6); place.CreateObject(plant, tileX, tileY); } if (Input.GetMouseButtonDown(1)) { tileMap.SetTile(new Vector3Int(tileX - 1, tileY - 1, 0), tiles[1]); } } else { indicatorRenderer.color = red; if (Input.GetMouseButtonDown(1)) { if (tileLayout.GetTile(tileX, tileY).getObjectOnTile().tag == "Plant") { if (tileLayout.GetTile(tileX, tileY).getObjectOnTile().GetComponent <Plants>().getStages() == 5) { Tutorial.Instance.TriggerDialogue(10); Tutorial.Instance.TriggerDialogue(11); Debug.Log("yay"); } place.DestroyObject(tileX, tileY); } else { tileMap.SetTile(new Vector3Int(tileX - 1, tileY - 1, 0), tiles[1]); } } } } }