// 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 = 10; unit.movement = 2; unit.pageCost = 1; unit.Print(); //fill in location info at start characterLocationUpdate(); //just looking at dict in debug log. GameObject board = GameObject.Find("map"); Map_v11 map = board.GetComponent <Map_v11>(); 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); } }
public void characterLocationUpdate() { //updates location info. Does so every second, we may want to change to on.click if (gameObject.activeInHierarchy == true) //Only check location if not on quiz screen (object script is attatched to is active) { Vector3 coor; string xLocStr; string yLocStr; string unityCoorStr; string xTileStr; string yTileStr; float floatUnityX; float floatUnityY; float X; float Y; GameObject liz = gameObject; //Rather than having it search for a lizard in the scene, it instead just selects the gameobject this scripts attatched to GameObject board = GameObject.Find("map"); Map_v11 map = board.GetComponent <Map_v11>(); 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 + ')'; Debug.Log(unityCoorStr); //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); X = floatUnityX; Y = floatUnityY; if (X != coor.x || Y != coor.y) { Counter = Counter + 1; string outText = "Turn " + Counter; Debug.Log(outText); } } }
public void SelectedUnit() { //remove later, hard coded but should be procedural GameObject lizard = GameObject.Find("Lizard"); GameObject bird = GameObject.Find("Bird"); GameObject board = GameObject.Find("map"); if (ourHitObject == bird) { Map_v11 map = board.GetComponent <Map_v11>(); map.SelectedUnit = bird; } if (ourHitObject == lizard) { Map_v11 map = board.GetComponent <Map_v11>(); map.SelectedUnit = lizard; } }
public void characterLocationUpdate() { //updates location info. Does so every second, we may want to change to on.click Vector3 coor; string xLocStr; string yLocStr; string unityCoorStr; string xTileStr; string yTileStr; float floatUnityX; float floatUnityY; GameObject liz = GameObject.Find("Lizard"); GameObject board = GameObject.Find("map"); Map_v11 map = board.GetComponent <Map_v11>(); 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 + ')'; Debug.Log(unityCoorStr); //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); }
//test movement module public void lizardMove() { GameObject board = GameObject.Find("map"); Map_v11 map = board.GetComponent <Map_v11>(); ClickableTile_v5 click = board.GetComponent <ClickableTile_v5>(); //declarations string xstr; string ystr; xstr = click.x.ToString(); ystr = click.y.ToString(); float charHeight; //new, for 2-Y movement in a turn int twoYup = yTile + 1; int twoYDown = yTile - 1; string twoYUpStr = twoYup.ToString(); string twoYDownStr = twoYDown.ToString(); //finds, assignments GameObject liz = GameObject.Find("Lizard"); /* * * * //finds the hex on which the lizard sits * GameObject currentHex = GameObject.Find("Hex_" + xstr + "_" + ystr); * //2Yup neighbor game object * GameObject twoYUpHex = GameObject.Find("Hex_" + xstr + "_" + twoYUpStr); * //2YDown neighbor ob * GameObject twoYDownHex = GameObject.Find("Hex_" + xstr + "_" + twoYDownStr); * //pulls the neighbors for that hex * Neighbor_v3 neighbors = currentHex.GetComponent<Neighbor_v3>(); * //also pulls the neighbor for 1UpYaxis so he can move 1 X, 1 Y, or 2 Y in a single turn * Neighbor_v3 neighbor2Yup = twoYUpHex.GetComponent<Neighbor_v3>(); * //pulls neighbor 1DownAxis * Neighbor_v3 neighbor2YDown = twoYDownHex.GetComponent<Neighbor_v3>(); * */ //new, used to find battle Battle_v3 battle = liz.GetComponent <Battle_v3>(); //valid neighbor click if (((click.clickX == xTile + 1 || click.clickX == xTile + 2 || click.clickX == xTile - 1 || click.clickX == xTile - 2) & ((click.clickY == yTile + 1) || (click.clickY == yTile - 1) || (click.clickY == yTile))) || ((click.clickY == yTile + 1 || click.clickY == yTile - 1) & click.clickX == xTile)) { //string unityCoor; float unityX; float unityY; //unityCoor = map.tileLocPairs[click.clickCoor]; unityX = click.xLoc; unityY = click.yLoc; charHeight = .5f; //new shit to make occupied hexs un-enterable if (battle.OccupiedHexs.ContainsKey(click.clickCoor)) { battle.Battle(); } //otherwise, move if it is a valid destination else { liz.transform.position = new Vector3(unityX, charHeight, unityY); } } //too far to move there else { Debug.Log("Cannot move this far"); } }
void OnMouseUp() { string xstr; string ystr; string unityStr; string unityStrX; string unityStrY; //testing int length; //end testing GameObject board = GameObject.Find("map"); Map_v11 map = board.GetComponent <Map_v11>(); ClickableTile_v5 ct = board.GetComponent <ClickableTile_v5>(); GameObject liz = GameObject.Find("Lizard"); Lizard_v3 lizard = liz.GetComponent <Lizard_v3>(); 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(); */ }