// Use this for initialization void Start() { Debug.Log("START CURSOR"); map = GameObject.Find("Map"); mapGeneratorScript = map.GetComponent <MapGenerator>(); mapSize = mapGeneratorScript.getMapSize(); combatController = GameObject.Find("CombatController"); combatControllerScript = combatController.GetComponent <CombatControllerScript>(); cursorCoords = combatControllerScript.getCursorCoords(); //cursorScript = this.GetComponent<CursorController>(); //Debug.Log (cursorScript.currentState); //CombatControllerScript.UpdateCursorStatus(cursorScript); SetStateIdle(); }
private void CursorMove(string direction) { if (direction.Equals("Left") && (transform.position.x - Hoffset.x) >= -Mathf.Floor(mapSize.x / 2)) { transform.position = transform.position - Hoffset; combatControllerScript.UpdateCursorCoords(-1, 0); cursorCoords = combatControllerScript.getCursorCoords(); } else if (direction.Equals("Up") && (transform.position.z + Voffset.z) <= Mathf.Floor(mapSize.y / 2)) { transform.position = transform.position + Voffset; combatControllerScript.UpdateCursorCoords(0, 1); cursorCoords = combatControllerScript.getCursorCoords(); } else if (direction.Equals("Down") && (transform.position.z - Voffset.z) >= -Mathf.Floor(mapSize.y / 2)) { transform.position = transform.position - Voffset; combatControllerScript.UpdateCursorCoords(0, -1); cursorCoords = combatControllerScript.getCursorCoords(); } else if (direction.Equals("Right") && (transform.position.x + Hoffset.x) <= Mathf.Floor(mapSize.x / 2)) { transform.position = transform.position + Hoffset; combatControllerScript.UpdateCursorCoords(1, 0); cursorCoords = combatControllerScript.getCursorCoords(); } else if (direction.Equals("DUpLeft") && (transform.position.x - Hoffset.x) >= -Mathf.Floor(mapSize.x / 2) && (transform.position.z + Voffset.z) <= Mathf.Floor(mapSize.y / 2)) { transform.position = transform.position - Hoffset; transform.position = transform.position + Voffset; combatControllerScript.UpdateCursorCoords(-1, 1); cursorCoords = combatControllerScript.getCursorCoords(); } else if (direction.Equals("DUpRight") && (transform.position.x + Hoffset.x) <= Mathf.Floor(mapSize.x / 2) && (transform.position.z + Voffset.z) <= Mathf.Floor(mapSize.y / 2)) { transform.position = transform.position + Hoffset; transform.position = transform.position + Voffset; combatControllerScript.UpdateCursorCoords(1, 1); cursorCoords = combatControllerScript.getCursorCoords(); } else if (direction.Equals("DDownRight") && (transform.position.x + Hoffset.x) <= Mathf.Floor(mapSize.x / 2) && (transform.position.z - Voffset.z) >= -Mathf.Floor(mapSize.y / 2)) { transform.position = transform.position + Hoffset; transform.position = transform.position - Voffset; combatControllerScript.UpdateCursorCoords(1, -1); cursorCoords = combatControllerScript.getCursorCoords(); } else if (direction.Equals("DDownLeft") && (transform.position.x - Hoffset.x) >= -Mathf.Floor(mapSize.x / 2) && (transform.position.z - Voffset.z) >= -Mathf.Floor(mapSize.y / 2)) { transform.position = transform.position - Hoffset; transform.position = transform.position - Voffset; combatControllerScript.UpdateCursorCoords(-1, -1); cursorCoords = combatControllerScript.getCursorCoords(); } }