//this is how we tell if a hex is occupied public void OccupiedHex() { string clickTile; //open and access the map and click GameObject board = GameObject.Find("map"); Map_v12 map = board.GetComponent <Map_v12>(); ClickableTile_v5 click = board.GetComponent <ClickableTile_v5>(); clickTile = click.clickCoor; //access the lizard battle so it runs on that, not the general battle script GameObject liz = GameObject.Find("Lizard"); Lizard_v3 lizClass = liz.GetComponent <Lizard_v3>(); Battle_v3 lizBattle = liz.GetComponent <Battle_v3>(); //Debug.Log(clickTile); //this is how battle is called, and the condition is if the hex is in occupied hex list AND is in the lizards neighbor list if ((lizBattle.OccupiedHexs.ContainsKey(clickTile)) && (lizClass.actualNeighbors.Contains(clickTile))) { GameObject bird = GameObject.Find(lizBattle.OccupiedHexs[clickTile]); Bird_v3 birdClass = bird.GetComponent <Bird_v3>(); lizBattle.enemy = birdClass.unit; lizBattle.Battle(); } //Healing if ((lizClass.healingTiles.Contains(clickTile)) && (lizClass.actualNeighbors.Contains(clickTile))) { Debug.Log("Lizard walked into a healing fountain and replenished 10 Health"); self.health += 10; lizClass.healingTiles.Remove(clickTile); //lizBattle.healing(); Debug.Log(self.health); } }
// Use this for initialization void Start() { //List<int> neighborX = new List<int>(); //neighborX.Add(3); GameObject board = GameObject.Find("map"); Map_v12 map = board.GetComponent <Map_v12>(); maxX = map.width - 1; maxY = map.height - 1; //Debug.Log(neighborX); }
public void Battle() { //access lizard and his battle script GameObject liz = GameObject.Find("Lizard"); Lizard_v3 lizClass = liz.GetComponent <Lizard_v3>(); Battle_v3 lizBattle = liz.GetComponent <Battle_v3>(); //access the map and clickableTile scripts GameObject board = GameObject.Find("map"); Map_v12 map = board.GetComponent <Map_v12>(); ClickableTile_v5 click = board.GetComponent <ClickableTile_v5>(); GameObject textEd = GameObject.Find("textControl"); Debug.Log("A Battle has Begun!"); textEd.BroadcastMessage("textUpdate", "A Battle has Begun!"); canvas.SetActive(true); GameObject scrH = GameObject.Find("Scriptholder"); scrH.SendMessage("setRUnit", gameObject.name); mapHolder.SetActive(false); }
public void Battle() { //access lizard and his battle script GameObject liz = GameObject.Find("Lizard"); Lizard_v3 lizClass = liz.GetComponent <Lizard_v3>(); Battle_v3 lizBattle = liz.GetComponent <Battle_v3>(); //access the map and clickableTile scripts GameObject board = GameObject.Find("map"); Map_v12 map = board.GetComponent <Map_v12>(); ClickableTile_v5 click = board.GetComponent <ClickableTile_v5>(); //debug info about battle Debug.Log("A Battle has Begun!"); //attack lowers the enemy's health enemy.health = enemy.health - self.attack; Debug.Log("Bird has " + enemy.health + " health remaining!"); //it also hurts our hero equal to enemy's attack value. self.health = self.health - enemy.attack; Debug.Log(self.name + " has " + self.health + " health remaining!"); //if an enemy is killed, this is what we do if (enemy.health <= 0) { //tell us he died, name him dead, and then destroy the game object Debug.Log(enemy.toonName + " has DIED!"); GameObject dead = GameObject.Find(lizBattle.OccupiedHexs[click.clickCoor]); Destroy(dead); lizBattle.OccupiedHexs.Remove(click.clickCoor); //increment birds slain for scoring purposes birdsSlain += 1; Debug.Log("Lizard has slain " + birdsSlain + " birds"); } //if the hero dies. This should end game more elegently than crashing, as we do now. if (self.health <= 0) { Debug.Log(self.toonName + " has DIED"); GameObject dead = GameObject.Find("Lizard"); Destroy(dead); } }
public void characterLocationUpdate() { //updates location info. Does so when called with "ON CLICK" in ClickableTile script //data we will need Vector3 coor; string xLocStr; string yLocStr; string unityCoorStr; string xTileStr; string yTileStr; float floatUnityX; float floatUnityY; //find the lizard and get his coordinates from unity, turn these into a string. GameObject liz = GameObject.Find("Lizard"); GameObject board = GameObject.Find("map"); Map_v12 map = board.GetComponent <Map_v12>(); coor = liz.transform.position; floatUnityX = coor.x; floatUnityY = coor.z; xLoc = floatUnityX; yLoc = floatUnityY; xLocStr = coor.x.ToString(); yLocStr = coor.z.ToString(); //create unity coordinate system to search inverse dictionary unityCoorStr = '(' + xLocStr + ", " + yLocStr + ')'; //takes our unity coordinate system and pulls out the hex (x,y) system from inverse dictionary tileStr = map.tileLocPairsInverse[unityCoorStr]; //split that string from dictionary into the tile numbers string[] tiles = tileStr.Split(new char[] { '(', ',', ')' }); //x tile coordinate xTileStr = tiles[1]; xTile = int.Parse(xTileStr); //y tile coordinate yTileStr = tiles[2]; yTile = int.Parse(yTileStr); }
public void battleWithResults(bool qResult) { //access lizard and his battle script GameObject liz = GameObject.Find("Lizard"); Lizard_v3 lizClass = liz.GetComponent <Lizard_v3>(); Battle_v3 lizBattle = liz.GetComponent <Battle_v3>(); //access the map and clickableTile scripts GameObject board = GameObject.Find("map"); Map_v12 map = board.GetComponent <Map_v12>(); ClickableTile_v5 click = board.GetComponent <ClickableTile_v5>(); GameObject textEd = GameObject.Find("textControl"); if (qResult == true) { Debug.Log("Player Answered Correctly"); textEd.BroadcastMessage("textUpdate", "Correct! You recieved a stat buff to help in battle."); self.attack = self.attack * 2; enemy.health = enemy.health - self.attack; Debug.Log("Bird has " + enemy.health + " health remaining!"); //it also hurts our hero equal to enemy's attack value. self.health = self.health - enemy.attack; Debug.Log(self.name + " has " + self.health + " health remaining!"); self.attack = self.attack / 2; } else { Debug.Log("Player Answered Incorrectly"); textEd.BroadcastMessage("textUpdate", "Incorrect! Your defense is weakened."); self.health -= 2; enemy.health = enemy.health - self.attack; Debug.Log("Bird has " + enemy.health + " health remaining!"); //it also hurts our hero equal to enemy's attack value. self.health = self.health - enemy.attack; Debug.Log(self.name + " has " + self.health + " health remaining!"); } /* * enemy.health = enemy.health - self.attack; * Debug.Log("Bird has " + enemy.health + " health remaining!"); * //it also hurts our hero equal to enemy's attack value. * self.health = self.health - enemy.attack; * Debug.Log(self.name + " has " + self.health + " health remaining!"); */ //if an enemy is killed, this is what we do if (enemy.health <= 0) { //tell us he died, name him dead, and then destroy the game object Debug.Log(enemy.toonName + " has DIED!"); GameObject dead = GameObject.Find(lizBattle.OccupiedHexs[click.clickCoor]); Destroy(dead); lizBattle.OccupiedHexs.Remove(click.clickCoor); //increment birds slain for scoring purposes birdsSlain += 1; Debug.Log("Lizard has slain " + birdsSlain + " birds"); } //if the hero dies. This should end game more elegently than crashing, as we do now. if (self.health <= 0) { Debug.Log(self.toonName + " has DIED"); GameObject dead = GameObject.Find("Lizard"); Destroy(dead); } }
void OnMouseUp() { string xstr; string ystr; string unityStr; string unityStrX; string unityStrY; //testing int length; //end testing GameObject board = GameObject.Find("map"); map = board.GetComponent <Map_v12>(); ClickableTile_v5 ct = board.GetComponent <ClickableTile_v5>(); GameObject liz = GameObject.Find("Lizard"); Lizard_v3 lizard = liz.GetComponent <Lizard_v3>(); Battle_v3 lizBattle = liz.GetComponent <Battle_v3>(); lizBattle.OccupiedHexs.Remove(lizard.tileStr); GameObject mouse = GameObject.Find("mouse"); MouseInputControl_v3 mouseInput = mouse.GetComponent <MouseInputControl_v3>(); ct.clickX = tileX; ct.clickY = tileY; xstr = tileX.ToString(); ystr = tileY.ToString(); ct.clickCoor = "(" + xstr + ", " + ystr + ")"; unityStr = map.tileLocPairs[ct.clickCoor]; string[] tiles = unityStr.Split(new char[] { '(', ',', ')' }); //x tile coordinate unityStrX = tiles[1]; unityStrY = tiles[2]; ct.xLoc = float.Parse(unityStrX); //y tile coordinate ct.yLoc = float.Parse(unityStrY); lizard.lizardMove(); lizard.characterLocationUpdate(); //test from here down(battle testing) Battle_v3 battle = liz.GetComponent <Battle_v3>(); battle.OccupiedHex(); battle.OccupiedHexList(); length = battle.OccupiedHexs.Count; //selected unit toggling? //mouseInput.SelectedUnit(); if (length == 0) { Debug.Log("No Occupied Hexs"); } if (length >= 1) { //foreach (var units in battle.OccupiedHexs) // Debug.Log("Key:" + units.Key + " Value:" + units.Value); } /* * Debug.Log("Click!"); * map.MoveUnitTo(xLoc, yLoc); * GameObject liz = GameObject.Find("Lizard"); * lizard lizard = liz.GetComponent<lizard>(); * lizard.characterLocationUpdate(); */ }
// Use this for initialization void Start() { //start declarations for class unit.toonName = "Lizard"; unit.description = "He eats birds."; unit.elementType = "Water"; unit.attack = 2; unit.health = 100; unit.movement = 2; unit.pageCost = 1; unit.Print(); //fill in location info at start characterLocationUpdate(); //grabbing info from the map in an inefficient way. DEBUGS are if you want to look at either coordinate dictionary GameObject board = GameObject.Find("map"); Map_v12 map = board.GetComponent <Map_v12>(); //foreach (var group in map.tileLocPairs) // Debug.Log("Key:" + group.Key + " Value:" + group.Value); //foreach (var group in map.tileLocPairsInverse) //Debug.Log("Key:" + group.Key + " Value:" + group.Value); //move hexes, getting our location in unity coordinates by looking up the dictionary that stores all the pairs unityStr = map.tileLocPairs[tileStr]; //everything below is to spawn the highlights that show player their possible moves. //temporary strings we will be saving to and combining for dictionary and list reasons. string unityXStr; string unityYStr; string neighUnityStr; //down 1 tile GameObject moveTiles = (GameObject)Instantiate(mouseHexPrefab, new Vector3(xLoc, 0, (yLoc - .89f)), Quaternion.Euler(90, 90, 0)); moveTiles.gameObject.tag = "moveHex"; //we take our unity location, turn it into a string, then add this neighbor to list if it is "in bounds" of map unityXStr = xLoc.ToString(); unityYStr = (yLoc - .89f).ToString(); neighUnityStr = '(' + unityXStr + ", " + unityYStr + ')'; actualNeighbors.Add(map.tileLocPairsInverse[neighUnityStr]); //to the left 1 and up 1 if ((xLoc - .76f) > 0 && yLoc + (.445f) < 5.8) { moveTiles = (GameObject)Instantiate(mouseHexPrefab, new Vector3(xLoc - .76f, 0, yLoc + (.445f)), Quaternion.Euler(90, 90, 0)); moveTiles.gameObject.tag = "moveHex"; //we take our unity location, turn it into a string, then add this neighbor to list if it is "in bounds" of map unityXStr = (xLoc - .76f).ToString(); unityYStr = (yLoc + (.445f)).ToString(); neighUnityStr = '(' + unityXStr + ", " + unityYStr + ')'; actualNeighbors.Add(map.tileLocPairsInverse[neighUnityStr]); } //left 1, down 1 if (((xLoc - .76f) > 0) && (yLoc - (.445f) > 0)) { moveTiles = (GameObject)Instantiate(mouseHexPrefab, new Vector3(xLoc - (.76f), 0, yLoc - (.445f)), Quaternion.Euler(90, 90, 0)); moveTiles.gameObject.tag = "moveHex"; //we take our unity location, turn it into a string, then add this neighbor to list if it is "in bounds" of map unityXStr = (xLoc - .76f).ToString(); unityYStr = (yLoc - (.445f)).ToString(); neighUnityStr = '(' + unityXStr + ", " + unityYStr + ')'; actualNeighbors.Add(map.tileLocPairsInverse[neighUnityStr]); } //to the left 2 if (xLoc - (.76f * 2) > 0) { moveTiles = (GameObject)Instantiate(mouseHexPrefab, new Vector3(xLoc - (.76f * 2), 0, yLoc), Quaternion.Euler(90, 90, 0)); moveTiles.gameObject.tag = "moveHex"; //we take our unity location, turn it into a string, then add this neighbor to list if it is "in bounds" of map unityXStr = (xLoc - (.76f * 2)).ToString(); unityYStr = (yLoc).ToString(); neighUnityStr = '(' + unityXStr + ", " + unityYStr + ')'; actualNeighbors.Add(map.tileLocPairsInverse[neighUnityStr]); } //to the left 2, up 2 if ((xLoc - (.76f * 2) > 0) && ((yLoc + .89f) < 5.8)) { moveTiles = (GameObject)Instantiate(mouseHexPrefab, new Vector3(xLoc - (.76f * 2), 0, yLoc + .89f), Quaternion.Euler(90, 90, 0)); moveTiles.gameObject.tag = "moveHex"; //we take our unity location, turn it into a string, then add this neighbor to list if it is "in bounds" of map unityXStr = (xLoc - (.76f * 2)).ToString(); unityYStr = (yLoc + .89f).ToString(); neighUnityStr = '(' + unityXStr + ", " + unityYStr + ')'; actualNeighbors.Add(map.tileLocPairsInverse[neighUnityStr]); } //to the left 2, down 2 if ((xLoc - (.76f * 2) > 0) && ((yLoc - .89f) > 0)) { moveTiles = (GameObject)Instantiate(mouseHexPrefab, new Vector3(xLoc - (.76f * 2), 0, yLoc - .89f), Quaternion.Euler(90, 90, 0)); moveTiles.gameObject.tag = "moveHex"; //we take our unity location, turn it into a string, then add this neighbor to list if it is "in bounds" of map unityXStr = (xLoc - (.76f * 2)).ToString(); unityYStr = (yLoc - .89f).ToString(); neighUnityStr = '(' + unityXStr + ", " + unityYStr + ')'; actualNeighbors.Add(map.tileLocPairsInverse[neighUnityStr]); } //to the right one and up if (((xLoc + (.76f)) < 4.56) && (yLoc + ((.445f)) < 5.8)) { moveTiles = (GameObject)Instantiate(mouseHexPrefab, new Vector3(xLoc + (.76f), 0, yLoc + (.445f)), Quaternion.Euler(90, 90, 0)); moveTiles.gameObject.tag = "moveHex"; //we take our unity location, turn it into a string, then add this neighbor to list if it is "in bounds" of map unityXStr = (xLoc + .76f).ToString(); unityYStr = (yLoc + (.445f)).ToString(); neighUnityStr = '(' + unityXStr + ", " + unityYStr + ')'; actualNeighbors.Add(map.tileLocPairsInverse[neighUnityStr]); } //to the right one and down if (((xLoc + (.76f)) < 4.56) && (yLoc - (.445f) >= 0)) { moveTiles = (GameObject)Instantiate(mouseHexPrefab, new Vector3(xLoc + (.76f), 0, yLoc - (.445f)), Quaternion.Euler(90, 90, 0)); moveTiles.gameObject.tag = "moveHex"; //we take our unity location, turn it into a string, then add this neighbor to list if it is "in bounds" of map unityXStr = (xLoc + .76f).ToString(); unityYStr = Math.Round((yLoc - .445f), 4).ToString(); neighUnityStr = '(' + unityXStr + ", " + unityYStr + ')'; actualNeighbors.Add(map.tileLocPairsInverse[neighUnityStr]); } //to the right 2 if ((xLoc + (.76f * 2)) < 4.56) { moveTiles = (GameObject)Instantiate(mouseHexPrefab, new Vector3(xLoc + (.76f * 2), 0, yLoc), Quaternion.Euler(90, 90, 0)); moveTiles.gameObject.tag = "moveHex"; //we take our unity location, turn it into a string, then add this neighbor to list if it is "in bounds" of map unityXStr = (xLoc + (.76f * 2)).ToString(); unityYStr = (yLoc).ToString(); neighUnityStr = '(' + unityXStr + ", " + unityYStr + ')'; actualNeighbors.Add(map.tileLocPairsInverse[neighUnityStr]); } //right 2, up 2 if (((xLoc + (.76f * 2)) < 4.56) && (yLoc + .89f < 5.8)) { moveTiles = (GameObject)Instantiate(mouseHexPrefab, new Vector3(xLoc + (.76f * 2), 0, yLoc + .89f), Quaternion.Euler(90, 90, 0)); moveTiles.gameObject.tag = "moveHex"; //we take our unity location, turn it into a string, then add this neighbor to list if it is "in bounds" of map unityXStr = (xLoc + (.76f * 2)).ToString(); unityYStr = (yLoc + .89f).ToString(); neighUnityStr = '(' + unityXStr + ", " + unityYStr + ')'; actualNeighbors.Add(map.tileLocPairsInverse[neighUnityStr]); } //right 2, up 2 if (((xLoc + (.76f * 2)) < 4.56) && (yLoc - .89f > 0)) { moveTiles = (GameObject)Instantiate(mouseHexPrefab, new Vector3(xLoc + (.76f * 2), 0, yLoc - .89f), Quaternion.Euler(90, 90, 0)); moveTiles.gameObject.tag = "moveHex"; //we take our unity location, turn it into a string, then add this neighbor to list if it is "in bounds" of map unityXStr = (xLoc + (.76f * 2)).ToString(); unityYStr = (yLoc - .89f).ToString(); neighUnityStr = '(' + unityXStr + ", " + unityYStr + ')'; actualNeighbors.Add(map.tileLocPairsInverse[neighUnityStr]); } //one up if ((yLoc + .89f) < 5.8) { moveTiles = (GameObject)Instantiate(mouseHexPrefab, new Vector3(xLoc, 0, yLoc + .89f), Quaternion.Euler(90, 90, 0)); moveTiles.gameObject.tag = "moveHex"; //we take our unity location, turn it into a string, then add this neighbor to list if it is "in bounds" of map unityXStr = (xLoc).ToString(); unityYStr = (yLoc + .89f).ToString(); neighUnityStr = '(' + unityXStr + ", " + unityYStr + ')'; actualNeighbors.Add(map.tileLocPairsInverse[neighUnityStr]); } }
//test movement module public void lizardMove() { //open map and clickable tile GameObject board = GameObject.Find("map"); Map_v12 map = board.GetComponent <Map_v12>(); ClickableTile_v5 click = board.GetComponent <ClickableTile_v5>(); //declarations string xstr; string ystr; xstr = click.x.ToString(); ystr = click.y.ToString(); float charHeight; //opening lizard and lizards battle script for battle GameObject liz = GameObject.Find("Lizard"); Battle_v3 battle = liz.GetComponent <Battle_v3>(); Lizard_v3 lizClass = liz.GetComponent <Lizard_v3>(); //give movement permissions: aka these below are the only valid click options to move/attack //left or right 2 if (((click.clickX == xTile - 2 & click.clickY == yTile) || (click.clickX == xTile + 2 & click.clickY == yTile)) || //left or right 1 ((click.clickX == xTile - 1 & click.clickY == yTile) || (click.clickX == xTile + 1 & click.clickY == yTile)) || //diagonal up 2 ((click.clickX == xTile - 2 & click.clickY == yTile + 1) || (click.clickX == xTile + 2 & click.clickY == yTile + 1)) || //up and down 1 ((click.clickX == xTile & click.clickY == yTile - 1) || (click.clickX == xTile & click.clickY == yTile + 1)) || //diagonal down 2 ((click.clickX == xTile - 2 & click.clickY == yTile - 1) || (click.clickX == xTile + 2 & click.clickY == yTile - 1)) || //bug cases, because they are dependent on orientation of x value being odd/even //diagonal up 1 if x is even (((click.clickX == xTile - 1 & click.clickY == yTile + 1) || (click.clickX == xTile + 1 & click.clickY == yTile + 1)) & (xTile % 2 == 0)) || //diagonal down 1 if x is odd (((click.clickX == xTile - 1 & click.clickY == yTile - 1) || (click.clickX == xTile + 1 & click.clickY == yTile - 1)) & ((xTile % 2 == 1) || (xTile % 2 == -1)))) { //names we need float unityX; float unityY; unityX = click.xLoc; unityY = click.yLoc; charHeight = .5f; //checks if the coordinates of the tile clicked on matches the coordinates of a list containing all occupied tiles //if true (ie if tile is occuppied) then battle commences //this needs to be cleaned up/unwrapped I believe it is wholly unneccessary/redundent here, as battle is called elsewhere if (battle.OccupiedHexs.ContainsKey(click.clickCoor)) { //Debug.Log("BATTLE"); //battle.Battle(); } else if (lizClass.healingTiles.Contains(click.clickCoor)) { //heal } //otherwise, move if it is a valid destination else { //restart neighbors list because we moved actualNeighbors.Clear(); //find the list of move tiles and destroy all the game objects GameObject[] moveTilesArray; moveTilesArray = GameObject.FindGameObjectsWithTag("moveHex"); foreach (GameObject moveTile in moveTilesArray) { Destroy(moveTile); } //move to the unity coordinates of valid click/move/attack tile liz.transform.position = new Vector3(unityX, charHeight, unityY); //temporary strings we will be using to create next batch of highlight tiles and update our list of neighbors for valid locations string unityXStr; string unityYStr; string neighUnityStr; //spawn optional move highlights, ensure these spawns are bound in the map //down 1 if ((unityY - .89f) >= 0) { GameObject moveTiles = (GameObject)Instantiate(mouseHexPrefab, new Vector3(unityX, 0, unityY - .89f), Quaternion.Euler(90, 90, 0)); moveTiles.gameObject.tag = "moveHex"; //we take our unity location, turn it into a string, then add this neighbor to list if it is "in bounds" of map unityXStr = (unityX).ToString(); unityYStr = Math.Round((unityY - .89f), 3).ToString(); neighUnityStr = '(' + unityXStr + ", " + unityYStr + ')'; Debug.Log(neighUnityStr); actualNeighbors.Add(map.tileLocPairsInverse[neighUnityStr]); } //to the left 1 and up 1 if (((unityX - .76f) >= 0) && ((unityY + .445f) <= 5.8)) { GameObject moveTiles = (GameObject)Instantiate(mouseHexPrefab, new Vector3(unityX - .76f, 0, unityY + .445f), Quaternion.Euler(90, 90, 0)); moveTiles.gameObject.tag = "moveHex"; //we take our unity location, turn it into a string, then add this neighbor to list if it is "in bounds" of map unityXStr = (unityX - .76f).ToString(); unityYStr = Math.Round((unityY + .445f), 3).ToString(); neighUnityStr = '(' + unityXStr + ", " + unityYStr + ')'; actualNeighbors.Add(map.tileLocPairsInverse[neighUnityStr]); } //left 1, down 1 if (((unityX - .76f) >= 0) && (unityY - (.445f) >= 0)) { GameObject moveTiles = (GameObject)Instantiate(mouseHexPrefab, new Vector3(unityX - (.76f), 0, unityY - (.445f)), Quaternion.Euler(90, 90, 0)); moveTiles.gameObject.tag = "moveHex"; //we take our unity location, turn it into a string, then add this neighbor to list if it is "in bounds" of map unityXStr = (unityX - .76f).ToString(); unityYStr = Math.Round((unityY - .445f), 3).ToString(); neighUnityStr = '(' + unityXStr + ", " + unityYStr + ')'; actualNeighbors.Add(map.tileLocPairsInverse[neighUnityStr]); } //to the left 2 if (unityX - (.76f * 2) >= 0) { GameObject moveTiles = (GameObject)Instantiate(mouseHexPrefab, new Vector3(unityX - (.76f * 2), 0, unityY), Quaternion.Euler(90, 90, 0)); moveTiles.gameObject.tag = "moveHex"; //we take our unity location, turn it into a string, then add this neighbor to list if it is "in bounds" of map unityXStr = (unityX - (.76f * 2)).ToString(); unityYStr = Math.Round(unityY, 3).ToString(); neighUnityStr = '(' + unityXStr + ", " + unityYStr + ')'; actualNeighbors.Add(map.tileLocPairsInverse[neighUnityStr]); } //to the left 2, up 2 if ((unityX - (.76f * 2) >= 0) && ((unityY + .89f) <= 5.785)) { GameObject moveTiles = (GameObject)Instantiate(mouseHexPrefab, new Vector3(unityX - (.76f * 2), 0, unityY + .89f), Quaternion.Euler(90, 90, 0)); moveTiles.gameObject.tag = "moveHex"; //we take our unity location, turn it into a string, then add this neighbor to list if it is "in bounds" of map unityXStr = (unityX - (.76f * 2)).ToString(); unityYStr = Math.Round((unityY + .89f), 3).ToString(); neighUnityStr = '(' + unityXStr + ", " + unityYStr + ')'; actualNeighbors.Add(map.tileLocPairsInverse[neighUnityStr]); } //to the left 2, down 2 if ((unityX - (.76f * 2) >= 0) && ((unityY - .89f) >= 0)) { GameObject moveTiles = (GameObject)Instantiate(mouseHexPrefab, new Vector3(unityX - (.76f * 2), 0, unityY - .89f), Quaternion.Euler(90, 90, 0)); moveTiles.gameObject.tag = "moveHex"; //we take our unity location, turn it into a string, then add this neighbor to list if it is "in bounds" of map unityXStr = (unityX - (.76f * 2)).ToString(); unityYStr = Math.Round((unityY - .89f), 3).ToString(); neighUnityStr = '(' + unityXStr + ", " + unityYStr + ')'; actualNeighbors.Add(map.tileLocPairsInverse[neighUnityStr]); } //to the right one, up one if (((unityX + .76f) <= 4.56) && ((unityY + (.445f)) <= 5.8)) { GameObject moveTiles = (GameObject)Instantiate(mouseHexPrefab, new Vector3(unityX + .76f, 0, unityY + (.445f)), Quaternion.Euler(90, 90, 0)); moveTiles.gameObject.tag = "moveHex"; //we take our unity location, turn it into a string, then add this neighbor to list if it is "in bounds" of map unityXStr = (unityX + .76f).ToString(); unityYStr = Math.Round((unityY + .445f), 3).ToString(); neighUnityStr = '(' + unityXStr + ", " + unityYStr + ')'; actualNeighbors.Add(map.tileLocPairsInverse[neighUnityStr]); } //to the right one, down 1 if (((unityX + .76f) <= 4.56) && ((unityY - (.445f)) >= 0)) { GameObject moveTiles = (GameObject)Instantiate(mouseHexPrefab, new Vector3(unityX + .76f, 0, unityY - .445f), Quaternion.Euler(90, 90, 0)); moveTiles.gameObject.tag = "moveHex"; //we take our unity location, turn it into a string, then add this neighbor to list if it is "in bounds" of map unityXStr = (unityX + .76f).ToString(); unityYStr = Math.Round((unityY - .445f), 3).ToString(); neighUnityStr = '(' + unityXStr + ", " + unityYStr + ')'; actualNeighbors.Add(map.tileLocPairsInverse[neighUnityStr]); } //to the right 2 if ((unityX + (.76f * 2)) <= 4.56) { GameObject moveTiles = (GameObject)Instantiate(mouseHexPrefab, new Vector3(unityX + (.76f * 2), 0, unityY), Quaternion.Euler(90, 90, 0)); moveTiles.gameObject.tag = "moveHex"; //we take our unity location, turn it into a string, then add this neighbor to list if it is "in bounds" of map unityXStr = (unityX + (.76f * 2)).ToString(); unityYStr = Math.Round(unityY, 3).ToString(); neighUnityStr = '(' + unityXStr + ", " + unityYStr + ')'; actualNeighbors.Add(map.tileLocPairsInverse[neighUnityStr]); } //right 2, up 2 if (((unityX + (.76f * 2)) <= 4.56) && (unityY + .89f <= 5.8)) { GameObject moveTiles = (GameObject)Instantiate(mouseHexPrefab, new Vector3(unityX + (.76f * 2), 0, unityY + .89f), Quaternion.Euler(90, 90, 0)); moveTiles.gameObject.tag = "moveHex"; //we take our unity location, turn it into a string, then add this neighbor to list if it is "in bounds" of map unityXStr = (unityX + (.76f * 2)).ToString(); unityYStr = Math.Round((unityY + .89f), 3).ToString(); neighUnityStr = '(' + unityXStr + ", " + unityYStr + ')'; actualNeighbors.Add(map.tileLocPairsInverse[neighUnityStr]); } //right 2, up 2 if (((unityX + (.76f * 2)) <= 4.56) && (unityY - .89f >= 0)) { GameObject moveTiles = (GameObject)Instantiate(mouseHexPrefab, new Vector3(unityX + (.76f * 2), 0, unityY - .89f), Quaternion.Euler(90, 90, 0)); moveTiles.gameObject.tag = "moveHex"; //we take our unity location, turn it into a string, then add this neighbor to list if it is "in bounds" of map unityXStr = (unityX + (.76f * 2)).ToString(); unityYStr = Math.Round((unityY - .89f), 3).ToString(); neighUnityStr = '(' + unityXStr + ", " + unityYStr + ')'; actualNeighbors.Add(map.tileLocPairsInverse[neighUnityStr]); } //one up if ((unityY + .89f) <= 5.8) { GameObject moveTiles = (GameObject)Instantiate(mouseHexPrefab, new Vector3(unityX, 0, unityY + .89f), Quaternion.Euler(90, 90, 0)); moveTiles.gameObject.tag = "moveHex"; //we take our unity location, turn it into a string, then add this neighbor to list if it is "in bounds" of map unityXStr = (unityX).ToString(); unityYStr = Math.Round((unityY + .89f), 3).ToString(); neighUnityStr = '(' + unityXStr + ", " + unityYStr + ')'; actualNeighbors.Add(map.tileLocPairsInverse[neighUnityStr]); } } } //too far to move there, tell the player so in a better way than this. else { Debug.Log("Cannot move this far"); } }