// ---------- MAP MOVEMENT ----------------------------------------------------+ #region START HERO ENTERING STATE public void StartHeroEnteringState() { // Start following intro route introRouteFollower.StartFollowingRoute(heroDirectionX < 0); // Set state as entering mapState = MapStates.HERO_ENTERING; }
public MapState(IIndex map, MapStates state) { Map = map; State = state; RemovedDocuments = new List<Document>(); AddedDocuments = new List<Document>(); }
public MapState(IIndex map, MapStates state) { Map = map; State = state; RemovedDocuments = new List <Document>(); AddedDocuments = new List <Document>(); }
public Level ToLevel() { string[] mapLines = this.map.Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); int height = mapLines.Length, width = mapLines[0].Length; MapStates[,] map = new MapStates[width, height]; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { switch (mapLines[y][x]) { case '.': map[x, y] = MapStates.Visited; break; default: case ' ': map[x, y] = MapStates.Unknown; break; case '#': map[x, y] = MapStates.Wall; break; } } } string[] pathLines = paths.Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); int pheight = pathLines.Length, pwidth = pathLines[0].Length; Point[,] points = new Point[pwidth, pheight]; for (int y = 0; y < pheight; y++) { for (int i = 0, x = 0; i < pwidth; i += 2, x++) { points[x, y] = new Point { X = (int)(pathLines[y][i] - 'A'), Y = (int)(pathLines[y][i + 1] - 'A'), }; } } return(new Level { map = map, paths = points, playerStart = new Point { X = startx, Y = starty, } }); }
// This method gets called when any route is exited private void StartHeroDefaultState() { // Adjust curved route start and ending point curvedRouteFollower.AdjustRoutesOriginsAndEnds(); // ----- FREEZE VERTICAL MOVEMENT ----- if (mapState == MapStates.HERO_TURNING || mapState == MapStates.HERO_ENTERING) { introRoad1.rigidbody.constraints = RigidbodyConstraints2D.FreezePositionY; introRoad2.rigidbody.constraints = RigidbodyConstraints2D.FreezePositionY; introRoad3.rigidbody.constraints = RigidbodyConstraints2D.FreezePositionY; introRoad4.rigidbody.constraints = RigidbodyConstraints2D.FreezePositionY; for (int i = 0; i < standardRoads.Length; i++) { standardRoads[i].rigidbody.constraints = RigidbodyConstraints2D.FreezePositionY; } curvedRoad1.rigidbody.constraints = RigidbodyConstraints2D.FreezePositionY; curvedRoad2.rigidbody.constraints = RigidbodyConstraints2D.FreezePositionY; } // ----- SET BACKGROUNDS' VELOCITIES ----- // Move intro road if this is a new match if (mapState == MapStates.HERO_ENTERING) { introRoad1.rigidbody.velocity = Vector2.left * speed; introRoad2.rigidbody.velocity = Vector2.left * speed; introRoad3.rigidbody.velocity = Vector2.left * speed; introRoad4.rigidbody.velocity = Vector2.left * speed; } // Move other roads for (int i = 0; i < standardRoads.Length; i++) { standardRoads[i].rigidbody.velocity = Vector2.left * speed; } curvedRoad1.rigidbody.velocity = Vector2.left * speed; curvedRoad2.rigidbody.velocity = Vector2.left * speed; // Hide curved roads if (mapState == MapStates.HERO_ENTERING) { // Hide roads curvedRoad1.renderer.enabled = false; curvedRoad2.renderer.enabled = false; } // ----- START DEFAULT STATE ----- // Set state mapState = MapStates.HERO_DEFAULT; // Fire event: Hero default state started HeroDefaultStateStarted?.Invoke(); }
private void Reset() { if (buttonPressed) { gotItemOrWeapon = false; buttonPressed = false; getText.text = ""; getScene.SetActive(false); mapStates = MapStates.Standing; } }
public async Task <IActionResult> Create([Bind("StateCode,Id")] MapStates mapStates) { if (ModelState.IsValid) { _context.Add(mapStates); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(mapStates)); }
private void EnterCurve() { // ----- ACTIVATE / DEACTIVATE OBJECTS ----- // Deactivate background loop checker loopCheckerRoadBgs.SetActive(false); // Show curved road 2 curvedRoad2.renderer.enabled = true; // ----- STOP RIGID BODIES ----- // Standard movement stop (velocity) for (int i = 0; i < standardRoads.Length; i++) { standardRoads[i].rigidbody.velocity = Vector2.zero; } curvedRoad1.rigidbody.velocity = Vector2.zero; curvedRoad2.rigidbody.velocity = Vector2.zero; // Forced movement stop (constraints) for (int i = 0; i < standardRoads.Length; i++) { standardRoads[i].rigidbody.constraints = RigidbodyConstraints2D.FreezeAll; } curvedRoad1.rigidbody.constraints = RigidbodyConstraints2D.FreezeAll; curvedRoad2.rigidbody.constraints = RigidbodyConstraints2D.FreezeAll; // ----- FLIP AND RESET BACKGROUND POSITIONS ----- FlipAndResetBackgroundPositions_OnReachingCurve(); // ----- SET CONSTRAINTS FOR NEW MOVEMENT ----- for (int i = 0; i < standardRoads.Length; i++) { standardRoads[i].rigidbody.constraints = RigidbodyConstraints2D.None; } curvedRoad1.rigidbody.constraints = RigidbodyConstraints2D.None; curvedRoad2.rigidbody.constraints = RigidbodyConstraints2D.None; // ----- START FOLLOWING CURVE ROUTE ----- curvedRouteFollower.StartFollowingRoute(heroDirectionX > 0); // ----- CHANGE STATE & FIRE EVENT ----- // Change state mapState = MapStates.HERO_TURNING; // Fire event: curve was entered CurveWasEntered?.Invoke(); }
public ConsoleMapSelectionController() { data = Application.GetData(); state = Application.GetState(); current = new MapStates(); current = MapStates.RANDOM; states = new List <MapStates>(); foreach (MapStates value in Enum.GetValues(typeof(MapStates))) { states.Add(value); } index = 0; }
public ConsoleMapSelectionController() { data = Application.GetData(); state = Application.GetState(); current = new MapStates(); current = MapStates.RANDOM; states = new List<MapStates>(); foreach (MapStates value in Enum.GetValues(typeof(MapStates))) { states.Add(value); } index = 0; }
public void StartDragging() { // Set map state mapState = MapStates.HERO_DEAD; // Set drag as allowed dragAllowed = true; // Change body type of intro roads introRoad1.rigidbody.bodyType = RigidbodyType2D.Dynamic; introRoad2.rigidbody.bodyType = RigidbodyType2D.Dynamic; introRoad3.rigidbody.bodyType = RigidbodyType2D.Dynamic; introRoad4.rigidbody.bodyType = RigidbodyType2D.Dynamic; // Change body type of curved roads curvedRoad1.rigidbody.bodyType = RigidbodyType2D.Dynamic; curvedRoad2.rigidbody.bodyType = RigidbodyType2D.Dynamic; // Change body type of standard roads for (int i = 0; i < standardRoads.Length; i++) { standardRoads[i].rigidbody.bodyType = RigidbodyType2D.Dynamic; } }
public MapState(IIndex map, MapStates state) { Map = map; State = state; }
// ---------- SERENITY STATE ----------------------------------------------------+ #region SET SERENITY STATE public void SetSerenityState() { // ----- SET STATE & FLAGS ----- // Set map state mapState = MapStates.SERENITY; // Set drag as not allowed dragAllowed = false; // ----- ACTIVATE INTRO ROADS ----- introRoad1.obj.SetActive(true); introRoad2.obj.SetActive(true); introRoad3.obj.SetActive(true); introRoad4.obj.SetActive(true); // ----- RESET BODY TYPES ----- // Change body type of intro roads introRoad1.rigidbody.bodyType = RigidbodyType2D.Kinematic; introRoad2.rigidbody.bodyType = RigidbodyType2D.Kinematic; introRoad3.rigidbody.bodyType = RigidbodyType2D.Kinematic; introRoad4.rigidbody.bodyType = RigidbodyType2D.Kinematic; // Change body type of standard roads for (int i = 0; i < standardRoads.Length; i++) { standardRoads[i].rigidbody.bodyType = RigidbodyType2D.Kinematic; } // Change body type of curved roads curvedRoad1.rigidbody.bodyType = RigidbodyType2D.Kinematic; curvedRoad2.rigidbody.bodyType = RigidbodyType2D.Kinematic; // ----- FREEZE & ALLOW BACKGROUND MOVEMENT ----- // Freeze background's movement introRoad1.rigidbody.velocity = Vector2.zero; introRoad2.rigidbody.velocity = Vector2.zero; introRoad3.rigidbody.velocity = Vector2.zero; introRoad4.rigidbody.velocity = Vector2.zero; for (int i = 0; i < standardRoads.Length; i++) { standardRoads[i].rigidbody.velocity = Vector2.zero; } curvedRoad1.rigidbody.velocity = Vector2.zero; curvedRoad2.rigidbody.velocity = Vector2.zero; // Freeze background's movement introRoad1.rigidbody.constraints = RigidbodyConstraints2D.FreezeAll; introRoad2.rigidbody.constraints = RigidbodyConstraints2D.FreezeAll; introRoad3.rigidbody.constraints = RigidbodyConstraints2D.FreezeAll; introRoad4.rigidbody.constraints = RigidbodyConstraints2D.FreezeAll; for (int i = 0; i < standardRoads.Length; i++) { standardRoads[i].rigidbody.constraints = RigidbodyConstraints2D.FreezeAll; } curvedRoad1.rigidbody.constraints = RigidbodyConstraints2D.FreezeAll; curvedRoad2.rigidbody.constraints = RigidbodyConstraints2D.FreezeAll; // Allow background's movement introRoad1.rigidbody.constraints = RigidbodyConstraints2D.None; introRoad2.rigidbody.constraints = RigidbodyConstraints2D.None; introRoad3.rigidbody.constraints = RigidbodyConstraints2D.None; introRoad4.rigidbody.constraints = RigidbodyConstraints2D.None; for (int i = 0; i < standardRoads.Length; i++) { standardRoads[i].rigidbody.constraints = RigidbodyConstraints2D.None; } curvedRoad1.rigidbody.constraints = RigidbodyConstraints2D.None; curvedRoad2.rigidbody.constraints = RigidbodyConstraints2D.None; // ----- RESET SERENITY POSITIONS ----- // Set background parents positions introRouteFollower.SetRoadParentsPosition_AtZeroZero(); // Set background positions, on serenity state SetBackgroundPositions_OnSerenityState(); // Set background parents positions introRouteFollower.SetRoadParentsPosition_AtRoutesOrigins(heroDirectionX); // Deny camera movement on curved routes curvedRouteFollower.DenyCameraMovement(); // Reset curved route start and end point curvedRouteFollower.ResetRoutesOriginsAndEnds(); // Set camera position introRouteFollower.ResetCameraPosition(heroDirectionX); }
public void Execute() { data = Application.GetData(); state = Application.GetState(); ConsoleKey input = Console.ReadKey().Key; switch (input) { case ConsoleKey.W: if (index <= 0) { index = states.Count - 1; } else { index--; } current = states[index]; break; case ConsoleKey.S: if (index >= states.Count - 1) { index = 0; } else { index++; } current = states[index]; break; case ConsoleKey.Enter: if (current == MapStates.RANDOM) { Application.ChangeGameState(GameStates.GAME); Application.NewGame(); } if (current == MapStates.TINY) { MasterControlProgram.map = "layout_all.bmp"; Application.ChangeGameState(GameStates.GAME); Application.NewGame(); } if (current == MapStates.SMALL) { MasterControlProgram.map = "small.bmp"; Application.ChangeGameState(GameStates.GAME); Application.NewGame(); } if (current == MapStates.MEDIUM) { Application.ChangeGameState(GameStates.GAME); Application.NewGame(); } if (current == MapStates.LARGE) { Application.ChangeGameState(GameStates.GAME); Application.NewGame(); } if (current == MapStates.VERYLARGE) { Application.ChangeGameState(GameStates.GAME); Application.NewGame(); } if (current == MapStates.WHYWOULDYOU) { Application.ChangeGameState(GameStates.GAME); Application.NewGame(); } break; } }
// ---------- OTHER ----------------------------------------------------+ #region SET HERO DEAD STATE public void SetHeroDeadState() { // Set map state mapState = MapStates.HERO_DEAD; }
static void ExploreTest(Level level, Level levelExplored) { int width = level.map.GetLength(0); int height = level.map.GetLength(1); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { Console.Write("{0}", level.map[x, y] == MapStates.Wall ? '#' : level.map[x, y] == MapStates.Visited ? '.' : ' '); } Console.WriteLine(); } Console.WriteLine(); width = levelExplored.map.GetLength(0); height = levelExplored.map.GetLength(1); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { Console.Write("{0}", levelExplored.map[x, y] == MapStates.Wall ? '#' : levelExplored.map[x, y] == MapStates.Visited ? '.' : ' '); } Console.WriteLine(); } Console.WriteLine(); MapStates[,] map = new MapStates[width, height]; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { if (level.map[x, y] == MapStates.Wall || levelExplored.map[x, y] == MapStates.Wall) { map[x, y] = MapStates.Wall; } else if (level.map[x, y] == MapStates.Visited || levelExplored.map[x, y] == MapStates.Visited) { map[x, y] = MapStates.Visited; } else { map[x, y] = MapStates.Unknown; } } } for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { Console.Write("{0}", map[x, y] == MapStates.Wall ? '#' : map[x, y] == MapStates.Visited ? '.' : ' '); } Console.WriteLine("|"); } Console.WriteLine(); int nextx = -1, nexty = -1; int[] directionX = new int[] { -1, 0, 1, 0 }; int[] directionY = new int[] { 0, -1, 0, 1 }; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { if (map[x, y] == MapStates.Visited) { bool wallFound = false, allVisited = true; for (int i = 0; i < directionX.Length && !wallFound; i++) { int newx = x + directionX[i]; int newy = y + directionY[i]; if (newx >= 0 && newy >= 0 && newx < width && newy < height) { if (map[newx, newy] == MapStates.Wall) { wallFound = true; } else if (map[newx, newy] != MapStates.Visited) { allVisited = false; } } } if (!wallFound && !allVisited) { map[x, y] = MapStates.Visited2; } } } } for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { if (map[x, y] == MapStates.Visited) { for (int i = 0; i < directionX.Length; i++) { int newx = x + directionX[i]; int newy = y + directionY[i]; if (newx >= 0 && newy >= 0 && newx < width && newy < height && map[newx, newy] != MapStates.Wall && map[newx, newy] != MapStates.Visited) { nextx = newx; nexty = newy; Console.WriteLine("Next: ({0}, {1})", nextx, nexty); } } } } } PrintMap(map, nextx, nexty, new Bot[0]); }
static MapStates[,] ParseMap(string mapInput, out Point me, out Bot[] bots) { string[] lines = mapInput.Split("\n".ToCharArray()); int height = lines.Length, width = (lines[0].Length + 1) / 2; MapStates[,] map = new MapStates[width, height]; Point[] botPoints = new Point[4]; bots = new Bot[4]; for (int i = 0; i < bots.Length; i++) { bots[i] = new Bot(); } me = new Point(); for (int y = 0; y < lines.Length; y++) { for (int i = 0, x = 0; i < lines[y].Length; i += 2, x++) { char c = lines[y][i]; switch (c) { case 'X': me.X = x; me.Y = y; map[x, y] = MapStates.Visited; break; case '1': map[x, y] = MapStates.Visited; break; case '3': case '4': case '5': case '6': map[x, y] = c - '3' + MapStates.Visited2; break; case 'A': case 'B': case 'C': case 'D': // TODO: map[x, y] = c - 'A' + MapStates.Visited2; map[x, y] = MapStates.Visited; botPoints[c - 'A'] = new Point { X = x, Y = y }; break; case ' ': map[x, y] = MapStates.Unknown; break; case '#': map[x, y] = MapStates.Wall; break; } } } for (int i = 0; i < bots.Length; i++) { bots[i].AddPoint(map, botPoints[i].X, botPoints[i].Y); } return(map); }
void MapStateMachine() { switch (mapStates) { case MapStates.Standing: //just standing on block buttonText.text = "Roll to Move"; if (buttonPressed) { buttonPressed = false; mapStates = MapStates.Rolling; } break; case MapStates.Rolling: buttonText.text = "Rolling..."; RollingDice(); mapStates = MapStates.Moving; break; case MapStates.Moving: buttonText.text = "Moving..."; spacesMovedText.text = spacesMoved.ToString(); CountdownTimer(); if (timer <= 0) { timer = .3f; Move(); spacesMoved++; } if (spacesMoved == Values.currDiceRollVal) { spacesMoved = 0; mapStates = MapStates.ExecuteBlockAction; } break; case MapStates.ExecuteBlockAction: //sends to correct state depending on which block of the map you stopped on if (hit.collider.CompareTag("EnemyBlock")) { Debug.Log("btl"); mapStates = MapStates.Battle; } else if (hit.collider.CompareTag("ItemBlock")) { Debug.Log("itm"); rand = Random.Range(0, allItemsList.Capacity); mapStates = MapStates.ItemGet; } else if (hit.collider.CompareTag("WeaponBlock")) { Debug.Log("wep"); rand = Random.Range(0, allWeaponsList.Capacity); mapStates = MapStates.WeaponGet; } else if (hit.collider.CompareTag("BossBlock")) { Debug.Log("bss"); mapStates = MapStates.Boss; } break; case MapStates.Battle: //opens battle state, see menu script battleScene.SetActive(true); mapStates = MapStates.Standing; break; case MapStates.ItemGet: //get random item getScene.SetActive(true); //Values.currItemList.Add(allItemsList[rand]); getText.text = "You got a " + allItemsList[rand].name + " charge"; if (allItemsList[rand].name == "Player Adder" && !gotItemOrWeapon) { Values.playerAdderCharge++; } if (allItemsList[rand].name == "Player Subtracter" && !gotItemOrWeapon) { Values.playerSubtracterCharge++; } if (allItemsList[rand].name == "Enemy Adder" && !gotItemOrWeapon) { Values.enemyAdderCharge++; } if (allItemsList[rand].name == "Enemy Subtracter" && !gotItemOrWeapon) { Values.enemySubtracterCharge++; } gotItemOrWeapon = true; buttonText.text = "Click to Continue"; Reset(); break; case MapStates.WeaponGet: //get random weapon getScene.SetActive(true); //Values.currWeaponList.Add(allWeaponsList[rand]); getText.text = "You got a " + allWeaponsList[rand].name + " charge"; if (allWeaponsList[rand].name == "Oddener" && !gotItemOrWeapon) { Values.oddenerCharge++; } if (allWeaponsList[rand].name == "Evener" && !gotItemOrWeapon) { Values.evenerCharge++; } if (allWeaponsList[rand].name == "Basic" && !gotItemOrWeapon) { Values.basicCharge++; } if (allWeaponsList[rand].name == "Extremes" && !gotItemOrWeapon) { Values.extremesCharge++; } gotItemOrWeapon = true; buttonText.text = "Click to Continue"; Reset(); break; case MapStates.Boss: //sends to boss depending on level if (map1) { SceneManager.LoadScene("Boss1"); } if (map2) { SceneManager.LoadScene("Boss2"); } if (map3) { SceneManager.LoadScene("Boss3"); } break; } }