public void PickUpItem() { player.current_item = (o_item)Grid.ObjectFromWorld(player.transform.position, 1); Grid.DespawnObject(Grid.ObjectFromWorld(player.transform.position, 1)); STATES = STATEMACHINE.SELECT_CHAR; }
public IEnumerator Defeat() { defeated = true; s_sound.PlaySound(sound); for (int i = 0; i < 5; i++) { renderer.enabled = false; yield return(new WaitForSeconds(0.1f)); renderer.enabled = true; yield return(new WaitForSeconds(0.1f)); } if (playable) { charctMnger.Players.Remove(this); } else { charctMnger.Enemies.Remove(this); } if (current_item != null) { if (grid.ObjectFromWorld(transform.position) != null) { grid.SpawnObject(current_item.name, transform.position); } } grid.DespawnObject(this); hasdisapeared = true; }
public void UpdateMouseInput() { Vector3 mousepos = Camera.main.ScreenToWorldPoint(Input.mousePosition); Vector3Int mousepogrid = Grid.GetObjectPositionToGrid(mousepos); cursor.transform.position = new Vector3(mousepogrid.x * Grid.GetNodeLength, mousepogrid.y * Grid.GetNodeLength + z * Grid.GetNodeLength); if (Input.GetKeyDown(KeyCode.A) && Input.GetKeyDown(KeyCode.Space)) { m_position += "\n" + "mpos: " + new Vector3Int(mousepogrid.x, mousepogrid.y, z) + " in area " + levels[currentLevNum].name; } if (Input.GetKeyDown(KeyCode.B) && Input.GetKeyDown(KeyCode.Space)) { m_position = string.Empty; } if (Grid.GetObjectFromGrid(new Vector3(mousepogrid.x * Grid.GetNodeLength, mousepogrid.y * Grid.GetNodeLength, z * Grid.GetNodeLength))) { txt.text = "Space + A to memorise position \n" + "Space + B to delete position \n" + "Position: " + new Vector3Int(mousepogrid.x, mousepogrid.y, z) + " Focusing on: " + Grid.GetObjectFromGrid(new Vector3(mousepogrid.x * Grid.GetNodeLength, mousepogrid.y * Grid.GetNodeLength, z * Grid.GetNodeLength)) + " " + m_position; } else { txt.text = "Space + A to memorise position \n" + "Space + B to delete position \n" + "Position: " + new Vector3Int(mousepogrid.x, mousepogrid.y, z) + " " + m_position; } switch (TOOLKIT) { case TOOLKT.BRUSH: text.text = "Brush: " + currentblock.name; if (Input.GetMouseButton(0)) { Grid.SpawnObject(currentblock.name, new Vector3(mousepos.x, mousepos.y, z * Grid.GetNodeLength)); } if (Input.GetMouseButton(1)) { Grid.DespawnObject(new Vector3(mousepos.x, mousepos.y, z * Grid.GetNodeLength)); } break; } }
private void Update() { if (Grid.gridworldsize.y > 0 && Grid.gridworldsize.x > 0) { Vector3 mousePositon = Camera.main.ScreenToWorldPoint(Input.mousePosition); s_object selectedObj = Grid.ObjectFromWorld(mousePositon); if (Input.GetKeyDown(KeyCode.W)) { spritenum++; } if (Input.GetKeyDown(KeyCode.S)) { spritenum--; } if (Input.GetKeyDown(KeyCode.E)) { angle += 90; } if (angle > 360) { angle = 0; } examplerend.gameObject.transform.localRotation = Quaternion.Euler(0, 0, angle); spritenum = Mathf.Clamp(spritenum, 0, spriteArray.Length - 1); examplerend.sprite = spriteArray[spritenum]; if (Grid.NodeFromWorld(mousePositon) != null) { Vector2 snap = Grid.SnapToGrid(mousePositon); if (Input.GetMouseButton(0)) { if (selectedObj != null) { if (selectedObj.GetComponent <s_object>().GetType() == typeof(o_tile)) { SpriteRenderer ren = selectedObj.GetComponent <SpriteRenderer>(); ren.sprite = spriteArray[spritenum]; ren.gameObject.transform.localRotation = examplerend.gameObject.transform.localRotation; } } //target.transform.position = mousePositon; if (Grid.ObjectFromWorld(mousePositon) == null) { Vector2Int vecint = Grid.VectorPositionFromWorld(mousePositon); if (selected_object != null) { s_object obj = Grid.SpawnObject(selected_object.name, snap); } } } if (Input.GetMouseButton(1)) { if (Grid.ObjectFromWorld(mousePositon) != null) { Vector2Int vecint = Grid.VectorPositionFromWorld(mousePositon); if (selected_object != null) { Grid.DespawnObject(snap); } } } } } if (Grid.nodes != null) { for (int x = 0; x < Grid.gridworldsize.x; x++) { for (int y = 0; y < Grid.gridworldsize.y; y++) { /* * SpriteRenderer colourRender = Grid.nodegameobjects[x, y].GetComponent<SpriteRenderer>(); * colourRender.color = Color.white; * if (Grid.CheckForNodeOnGrid(mousePositon, x, y)) * { * colourRender.color = Color.blue; * } */ } } } }