void executeAction(tileEdgeAction act, bool left) { if (act == tileEdgeAction.turn || act == tileEdgeAction.dodge) { Quaternion rotation = Quaternion.AngleAxis((90 * ((left) ? 1 : -1)), Vector3.forward); //positive is left bool snapX = true; bool snapY = true; if (act == tileEdgeAction.turn) { bool notSprinting = (speedLevel != speedMaxLevel) ? true : false; bool sprinting = (speedLevel == speedMaxLevel) ? true : false; if (notSprinting || (sprinting && allowTurningWhenSprinting)) { gameObject.transform.rotation = Quaternion.AngleAxis(gameObject.transform.rotation.eulerAngles.z + rotation.eulerAngles.z, Vector3.forward); //rotate our object so the camera rotates with us runDirection = vect_2_byteArr(rotation * arr_2_vect(runDirection)); //from rundirection determine which axis we should snap to if (alwaysSnapBoth == false) { bool runningUpOrDown = (Mathf.Approximately(runDirection[0], 0)) ? true : false; snapX = (runningUpOrDown) ? true : false; snapY = (runningUpOrDown) ? false : true; } if (turningChangesRulingtile) { newRulingTile(vect_2_arr(arr_2_vect(rulingTile) + arr_2_vect(runDirection)), snapX, snapY); } else { newRulingTile(rulingTile, snapX, snapY); //we are rotating on the same square... there is no need to switch ruling tile manually } } } else { //from rundirection determine which axis we should snap to if (alwaysSnapBoth == false) { bool runningUpOrDown = (Mathf.Approximately(runDirection[0], 0)) ? true : false; snapX = (runningUpOrDown) ? true : false; snapY = (runningUpOrDown) ? false : true; } newRulingTile(vect_2_arr(arr_2_vect(rulingTile) + (Vector2)(rotation * arr_2_vect(runDirection))), snapX, snapY); //set new ruling tile } } }
void drawTileInstructs(int[] center, Color tileColor) { //basic outline for each tile Vector2[] tileCorners = getTileCorners(center); drawSquare(tileCorners, tileColor); drawX(tileCorners, tileColor); Dictionary <ushort, tileEdgeAction> thisEdgeDir_2_edgeAction = tileToMapping(center); //instruction based renderings for (byte i = 0; i < 4; i++) { sbyte[] thisDir = Camera.main.GetComponent <GameManager>().map.GetComponent <EnvironManager>().dirID_2_dir[i]; tileEdgeAction thisDirAction = thisEdgeDir_2_edgeAction[_2tuple.combine(thisDir[0], thisDir[1])]; Color thisDirActionColor = Camera.main.GetComponent <GameManager>().map.GetComponent <EnvironManager>().tileEdgeAction_2_Color[thisDirAction]; float[] starCenter = new float[] { (float)(center[0] + (thisDir[0] / 4.0)), (float)(center[1] + (thisDir[1] / 4.0)) }; drawStar(starCenter, .1f, thisDirActionColor); } }