// Update is called once per frame void Update() { if (GameManager.instance.CurrentPlayer.isAI) { } else { currentMouseDirection = UpdateMouseDirection(); if (Input.GetKeyDown(KeyCode.RightArrow)) { Move(Tile.Direction.East); } if (Input.GetKeyDown(KeyCode.LeftArrow)) { Move(Tile.Direction.West); } if (Input.GetKeyDown(KeyCode.UpArrow)) { Move(Tile.Direction.North); } if (Input.GetKeyDown(KeyCode.DownArrow)) { Move(Tile.Direction.South); } if (Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject()) { UseCurrentAbility(); } currentAbility.VisualEffect(); } }
public void Move( Tile.Direction direction, Player movingPlayer, Player destinationTilePlayer, MoveDetails moveDetails ) { Tile currentTile = GetTile(movingPlayer); Wall wall = currentTile.GetWall(direction); if (wall == null) { moveDetails.Status = MoveDetails.MoveStatus.ABORTED; } else { wall.GoThrough( movingPlayer, destinationTilePlayer, moveDetails ); if (moveDetails.Status != MoveDetails.MoveStatus.FAILURE) { movingPlayer.Pos.Move(direction); } } }
public bool IsTileFree(Tile.Direction direction) { switch (direction) { case Tile.Direction.North: if (!playerController.IsTileOccupied(GameManager.instance.CurrentPlayer.mapPosition.x, GameManager.instance.CurrentPlayer.mapPosition.y + 1)) { return(true); } break; case Tile.Direction.East: if (!GameManager.instance.map.tiles[GameManager.instance.CurrentPlayer.mapPosition.x, GameManager.instance.CurrentPlayer.mapPosition.y].east && !playerController.IsTileOccupied(GameManager.instance.CurrentPlayer.mapPosition.x + 1, GameManager.instance.CurrentPlayer.mapPosition.y)) { return(true); } break; case Tile.Direction.South: if (!playerController.IsTileOccupied(GameManager.instance.CurrentPlayer.mapPosition.x, GameManager.instance.CurrentPlayer.mapPosition.y - 1)) { return(true); } break; case Tile.Direction.West: if (!playerController.IsTileOccupied(GameManager.instance.CurrentPlayer.mapPosition.x - 1, GameManager.instance.CurrentPlayer.mapPosition.y)) { return(true); } break; } return(false); }
public bool IsWalled(Tile.Direction direction) { switch (direction) { case Tile.Direction.North: if (!GameManager.instance.map.tiles[GameManager.instance.CurrentPlayer.mapPosition.x, GameManager.instance.CurrentPlayer.mapPosition.y].north) { return(true); } break; case Tile.Direction.East: if (!GameManager.instance.map.tiles[GameManager.instance.CurrentPlayer.mapPosition.x, GameManager.instance.CurrentPlayer.mapPosition.y].east) { return(true); } break; case Tile.Direction.South: if (!GameManager.instance.map.tiles[GameManager.instance.CurrentPlayer.mapPosition.x, GameManager.instance.CurrentPlayer.mapPosition.y].south) { return(true); } break; case Tile.Direction.West: if (!GameManager.instance.map.tiles[GameManager.instance.CurrentPlayer.mapPosition.x, GameManager.instance.CurrentPlayer.mapPosition.y].west) { return(true); } break; } return(false); }
public Position OffsetPosition(Tile.Direction direction) { Position position = new Position(x, y); position.Move(direction); return(position); }
protected bool GetEventCollision() { int[] playerPos = Global.action.tileMap.player.GetMapPos(); bool isPlayerThere = false; Tile.Direction dir = GetDir(); IEvent e = null; if (dir == Tile.Direction.NORTH) { e = Global.action.tileMap.GetEvent(mapX, mapY + 1, mapZ); isPlayerThere = (playerPos[BasicEvent.X] == mapX && playerPos[BasicEvent.Y] == mapY + 1 && playerPos[BasicEvent.Z] == mapZ); } if (dir == Tile.Direction.SOUTH) { e = Global.action.tileMap.GetEvent(mapX, mapY - 1, mapZ); isPlayerThere = (playerPos[BasicEvent.X] == mapX && playerPos[BasicEvent.Y] == mapY - 1 && playerPos[BasicEvent.Z] == mapZ); } if (dir == Tile.Direction.EAST) { e = Global.action.tileMap.GetEvent(mapX + 1, mapY, mapZ); isPlayerThere = (playerPos[BasicEvent.X] == mapX + 1 && playerPos[BasicEvent.Y] == mapY && playerPos[BasicEvent.Z] == mapZ); } if (dir == Tile.Direction.WEST) { e = Global.action.tileMap.GetEvent(mapX - 1, mapY, mapZ); isPlayerThere = (playerPos[BasicEvent.X] == mapX - 1 && playerPos[BasicEvent.Y] == mapY && playerPos[BasicEvent.Z] == mapZ); } return(!isPlayerThere && (e == null || (e != null && e.GetPassage() && !e.IsForPlayerOnly()))); }
public void Move(Tile.Direction direction) { switch (direction) { case Tile.Direction.North: if (!GameManager.instance.map.tiles[GameManager.instance.CurrentPlayer.mapPosition.x, GameManager.instance.CurrentPlayer.mapPosition.y].north && !IsTileOccupied(GameManager.instance.CurrentPlayer.mapPosition.x, GameManager.instance.CurrentPlayer.mapPosition.y + 1)) { GameManager.instance.CurrentPlayer.transform.Translate(new Vector3(0, 0, 1 + GameManager.instance.map.tilePadding)); GameManager.instance.CurrentPlayer.mapPosition.y++; } else { return; } break; case Tile.Direction.East: if (!GameManager.instance.map.tiles[GameManager.instance.CurrentPlayer.mapPosition.x, GameManager.instance.CurrentPlayer.mapPosition.y].east && !IsTileOccupied(GameManager.instance.CurrentPlayer.mapPosition.x + 1, GameManager.instance.CurrentPlayer.mapPosition.y)) { GameManager.instance.CurrentPlayer.transform.Translate(new Vector3(1 + GameManager.instance.map.tilePadding, 0, 0)); GameManager.instance.CurrentPlayer.mapPosition.x++; } else { return; } break; case Tile.Direction.South: if (!GameManager.instance.map.tiles[GameManager.instance.CurrentPlayer.mapPosition.x, GameManager.instance.CurrentPlayer.mapPosition.y].south && !IsTileOccupied(GameManager.instance.CurrentPlayer.mapPosition.x, GameManager.instance.CurrentPlayer.mapPosition.y - 1)) { GameManager.instance.CurrentPlayer.transform.Translate(new Vector3(0, 0, -1 - GameManager.instance.map.tilePadding)); GameManager.instance.CurrentPlayer.mapPosition.y--; } else { return; } break; case Tile.Direction.West: if (!GameManager.instance.map.tiles[GameManager.instance.CurrentPlayer.mapPosition.x, GameManager.instance.CurrentPlayer.mapPosition.y].west && !IsTileOccupied(GameManager.instance.CurrentPlayer.mapPosition.x - 1, GameManager.instance.CurrentPlayer.mapPosition.y)) { GameManager.instance.CurrentPlayer.transform.Translate(new Vector3(-1 - GameManager.instance.map.tilePadding, 0, 0)); GameManager.instance.CurrentPlayer.mapPosition.x--; } else { return; } break; } UseMoves(MoveCost); }
public void UseCurrentAbility(Tile.Direction direction) { if (currentAbility.cost > GameManager.instance.CurrentPlayer.Moves) { return; } currentAbility.Use(direction); }
public OWPlayer(string texturePath, int[] mapPos, Tile.Direction dir) : base(texturePath, mapPos, dir, "Player") { this.texturePath = texturePath; mapX = mapPos[0]; mapY = mapPos[1]; mapZ = mapPos[2]; SetDir(dir); }
void Update() { m_newInput = GetCurrentInput(); if (m_waitForNoInput && m_newInput == Tile.Direction.NONE) { m_waitForNoInput = false; } }
public Character(string texturePath, int[] mapPos, Tile.Direction dir, string name) { this.texturePath = texturePath; mapX = mapPos[0]; mapY = mapPos[1]; mapZ = mapPos[2]; this.dir = dir; this.name = name; }
public override bool Use(Tile.Direction direction) { if (GameManager.instance.map.tiles[GameManager.instance.CurrentPlayer.mapPosition.x, GameManager.instance.CurrentPlayer.mapPosition.y].DestroyWall(direction)) { GameManager.instance.playerController.UseMoves(cost); return(true); } return(false); }
public override void VisualEffect() { Player player = GameManager.instance.CurrentPlayer; Tile.Direction direction = GameManager.instance.playerController.currentMouseDirection; Tile playerTile = GameManager.instance.map.tiles[player.mapPosition.x, player.mapPosition.y]; Wall newVfxWall = null; switch (direction) { case Tile.Direction.North: if (playerTile.north) { newVfxWall = playerTile.north; } break; case Tile.Direction.East: if (playerTile.east) { newVfxWall = playerTile.east; } break; case Tile.Direction.South: if (playerTile.south) { newVfxWall = playerTile.south; } break; case Tile.Direction.West: if (playerTile.west) { newVfxWall = playerTile.west; } break; } if (lastVfxedWall != newVfxWall) { if (lastVfxedWall != null) { lastVfxedWall.GetComponent <MeshRenderer>().material = lastVfxedWallMaterial; } if (newVfxWall != null) { lastVfxedWallMaterial = newVfxWall.GetComponent <MeshRenderer>().material; if (newVfxWall.destructable) { newVfxWall.GetComponent <MeshRenderer>().material = vfxMaterial; } } lastVfxedWall = newVfxWall; } }
public void SetTileMap(string mapName, int[] destPos, Tile.Direction dir) { TileMap nextMap = tileMaps[mapName]; nextMap.player = tileMap.player; nextMap.player.SetMapPos(destPos); nextMap.Initialize(); nextMap.player.SetDir(dir); tileMap = nextMap; }
public void SetDir(Tile.Direction dir) { this.dir = dir; if (animations != null) { animation = animations[dir.ToString()]; animation.PauseSet(0); } travel = new Vector2(0f); }
public SlidingDoor(string texturePath, int[] mapPos, int[] destPos, Tile.Direction dir, Tile.Direction playerDir, string mapDestKey) { this.texturePath = texturePath; mapX = mapPos[0]; mapY = mapPos[1]; mapZ = mapPos[2]; this.destPos = destPos; this.dir = dir; this.playerDir = playerDir; this.mapDestKey = mapDestKey; passage = true; }
public IVela GetVela(Tile.Direction direction) { switch (direction) { case Tile.Direction.Up: return(colliderUp.Vela); case Tile.Direction.Right: return(colliderRight.Vela); case Tile.Direction.Down: return(colliderDown.Vela); case Tile.Direction.Left: return(colliderLeft.Vela); } return(null); }
public bool CanPushing(Tile.Direction direction) { switch (direction) { case Tile.Direction.Up: return(colliderUp.CanPushing); case Tile.Direction.Right: return(colliderRight.CanPushing); case Tile.Direction.Down: return(colliderDown.CanPushing); case Tile.Direction.Left: return(colliderLeft.CanPushing); } return(true); }
/// <summary> /// Called when a directional button is being held. /// </summary> /// <param name="dir">The direction requested for motion</param> public void Move(Tile.Direction dir) { //DIRECT CLONE IN OWPLAYER... if (travel.X == 0 && travel.Y == 0) { this.dir = dir; animation = animations[dir.ToString()]; if (GetTileCollision() && GetBuildingCollision() && GetEventCollision()) { if (!animation.running) { animation.Start(); } else { animation.running = true; } if (dir == Tile.Direction.NORTH) { travel.Y = +0.01f; Global.action.tileMap.UpdateEventGrid(this, GetMapPos(), new int[2] { GetMapPos()[0], GetMapPos()[1] + 1 }); } if (dir == Tile.Direction.SOUTH) { travel.Y = -0.01f; Global.action.tileMap.UpdateEventGrid(this, GetMapPos(), new int[2] { GetMapPos()[0], GetMapPos()[1] - 1 }); } if (dir == Tile.Direction.EAST) { travel.X = +0.01f; Global.action.tileMap.UpdateEventGrid(this, GetMapPos(), new int[2] { GetMapPos()[0] + 1, GetMapPos()[1] }); } if (dir == Tile.Direction.WEST) { travel.X = -0.01f; Global.action.tileMap.UpdateEventGrid(this, GetMapPos(), new int[2] { GetMapPos()[0] - 1, GetMapPos()[1] }); } } } }
public Tile GetTile(int x, int y, Tile.Direction direction) { switch (direction) { case Tile.Direction.EAST: return(m_tiles[x + 1, y]); case Tile.Direction.WEST: return(m_tiles[x - 1, y]); case Tile.Direction.SOUTH: return(m_tiles[x, y + 1]); case Tile.Direction.NORTH: return(m_tiles[x, y - 1]); } return(null); }
public override void VisualEffect() { Player player = GameManager.instance.CurrentPlayer; Tile.Direction direction = GameManager.instance.playerController.currentMouseDirection; Tile playerTile = GameManager.instance.map.tiles[player.mapPosition.x, player.mapPosition.y]; switch (direction) { case Tile.Direction.North: if (!playerTile.north) { vfxWallInstance.transform.position = player.transform.position + new Vector3(0, 0, 0.5f + GameManager.instance.map.tilePadding / 2); vfxWallInstance.transform.LookAt(player.transform.position + Vector3.forward); } break; case Tile.Direction.East: if (!playerTile.east) { vfxWallInstance.transform.position = player.transform.position + new Vector3(0.5f + GameManager.instance.map.tilePadding / 2, 0, 0); vfxWallInstance.transform.LookAt(player.transform.position + Vector3.right); } break; case Tile.Direction.South: if (!playerTile.south) { vfxWallInstance.transform.position = player.transform.position + new Vector3(0, 0, -0.5f - GameManager.instance.map.tilePadding / 2); vfxWallInstance.transform.LookAt(player.transform.position - Vector3.forward); } break; case Tile.Direction.West: if (!playerTile.west) { vfxWallInstance.transform.position = player.transform.position + new Vector3(-0.5f - GameManager.instance.map.tilePadding / 2, 0, 0); vfxWallInstance.transform.LookAt(player.transform.position - Vector3.right); } break; } }
public override bool Use(Tile.Direction direction) { Wall result = GameManager.instance.map.tiles[GameManager.instance.CurrentPlayer.mapPosition.x, GameManager.instance.CurrentPlayer.mapPosition.y].CreateWall(direction, GameManager.instance.CurrentPlayer); if (result) { if (result.back.north && result.back.south && result.back.east && result.back.west) { if (!GameManager.instance.playerController.IsTileOccupied(result.back.mapPosition.x, result.back.mapPosition.y)) { Tile.ClaimTile(result.back, GameManager.instance.CurrentPlayer); GameManager.instance.CheckWinConditions(); return(true); } } GameManager.instance.playerController.UseMoves(cost); return(true); } return(false); }
public bool ChangeToMatch(WaveElement origin, Tile.Direction to) { if (collapsed) { return(false); } bool changed = false; for (int i = 0; i < this.coeff.Length; i++) { bool edgeMatchFound = false; for (int j = 0; j < origin.coeff.Length; j++) { if (this.coeff[i] && origin.coeff[j]) { //if (possibleTiles[j].side[(int)to] == possibleTiles[i].side[(int)from]) Tile checkedTile = this.possibleTiles[i].tile; Tile originTile = origin.possibleTiles[j].tile; if (checkedTile.Match(originTile, to)) { edgeMatchFound = true; break; } } } if (!edgeMatchFound && coeff[i]) //if the edge doesn't match and the tile isn't already disabled { Remove(i); changed = true; } } if (changed) { CalculateProbAndEntropy(); } return(changed); }
public void Move(Tile.Direction direction) { switch (direction) { case Tile.Direction.EAST: x += 1; break; case Tile.Direction.WEST: x -= 1; break; case Tile.Direction.SOUTH: y += 1; break; case Tile.Direction.NORTH: y -= 1; break; } }
public void Update() { switch (m_stateMachine.CurrentState) { case GameManagerStateMachine.State.WAIT_FOR_INPUT: Tile.Direction input = m_gameInput.GetNewInput(); if (input != Tile.Direction.NONE) { Debug.Log("Input detected : " + input); MoveDetails moveDetails = m_game.Move(input); List <SoundMixer.SoundFX> allSounds = SoundMixer.GetMoveSounds(moveDetails); if (moveDetails.Status != MoveDetails.MoveStatus.ABORTED) { allSounds.AddRange(SoundMixer.GetNextPlayerSounds( moveDetails, m_game )); } m_soundManager.PlayAllSounds(allSounds); m_stateMachine.MoveNext( GameManagerStateMachine.Event.INPUT_RECEIVED ); } break; case GameManagerStateMachine.State.PLAYING_SOUNDS: if (m_soundManager.Done()) { m_stateMachine.MoveNext( GameManagerStateMachine.Event.SOUND_FINISHED ); } break; default: Debug.LogError("Unknown state: " + m_stateMachine.CurrentState); break; } }
/// <summary> /// Devuelve la direccion hacia la que se encuentra "b" respecto a "a" /// </summary> private Tile.Direction TileDirection(int a, int b) { Tile.Direction dir = Tile.Direction.UNDEFINED; if (a == b + 1) { dir = Tile.Direction.LEFT; } else if (a == b - 1) { dir = Tile.Direction.RIGHT; } else if (a == b - cols) { dir = Tile.Direction.UP; } else if (a == b + cols) { dir = Tile.Direction.DOWN; } return(dir); }
void Action() { //Turn if (Input.GetAxisRaw("Horizontal") > 0) { Direction = Tile.Direction.Right; //Direita } else if (Input.GetAxisRaw("Horizontal") < 0) { Direction = Tile.Direction.Left; //Esquerda } else if (Input.GetAxisRaw("Vertical") > 0) { Direction = Tile.Direction.Up; //Cima } else if (Input.GetAxisRaw("Vertical") < 0) { Direction = Tile.Direction.Down; //Baixo } if (CanMove() || CanPushing()) { if (sliderSt.Use(1)) //Usa Stamina { Move(); SoundManager.instance.PlaySE(somAndando); if (CanPushing()) { Push(); SoundManager.instance.PlaySE(somEmpurrando); } } else { DialogInBattle.Instance.Player("player-stamina"); } } }
public void Move(Tile.Direction dir) { if (dir == Tile.Direction.NORTH) { //jump } else if (dir == Tile.Direction.SOUTH) { //crouch } else if (dir == Tile.Direction.EAST) { velocity.X = speed; animation = animations["Walking"]; flipped = false; } else if (dir == Tile.Direction.WEST) { velocity.X = -speed; animation = animations["Walking"]; flipped = true; } }
/// <summary> /// Dado un index de la tabla de tiles, lo establece a seleccionado o no /// Si se selecciona, se anyade al camino actual /// Si se deselecciona, se quita del camino actual /// </summary> /// <param name="boardIndex">Index de la tabla a tratar</param> /// <param name="pressed">Si se selecciona o no</param> private void PressTile(int boardIndex, bool pressed) { Tile tileComponent = board_[boardIndex].GetComponent <Tile>(); boolBoard_[boardIndex] = pressed; tileComponent.SetPressed(pressed); if (pressed) { if (path_.Count > 0) // se anyade a un camino existente { int lastTileIndex = path_[path_.Count - 1]; Tile.Direction dir = TileDirection(boardIndex, lastTileIndex); tileComponent.AddPath(dir); } path_.Add(boardIndex); // se anyade como inicio de camino } else { path_.Remove(boardIndex); } }
public TilePos addDirection(Tile.Direction dir) { TilePos returnVal = new TilePos(this); if (dir == Tile.Direction.Up) { returnVal.y++; } if (dir == Tile.Direction.Right) { returnVal.x++; } if (dir == Tile.Direction.Down) { returnVal.y--; } if (dir == Tile.Direction.Left) { returnVal.x--; } return(returnVal); }
public void SetDir(Tile.Direction dir) { this.dir = dir; if (animations != null){ animation = animations[dir.ToString()]; animation.PauseSet(0); } travel = new Vector2(0f); }
/// <summary> /// Called when a directional button is being held. /// </summary> /// <param name="dir">The direction requested for motion</param> public void Move(Tile.Direction dir) { //DIRECT CLONE IN OWPLAYER... if (travel.X == 0 && travel.Y == 0){ this.dir = dir; animation = animations[dir.ToString()]; if (GetTileCollision() && GetBuildingCollision() && GetEventCollision()){ if (!animation.running) animation.Start(); else animation.running = true; if (dir == Tile.Direction.NORTH){ travel.Y = +0.01f; Global.action.tileMap.UpdateEventGrid(this, GetMapPos(), new int[2] { GetMapPos()[0], GetMapPos()[1] + 1 }); } if (dir == Tile.Direction.SOUTH){ travel.Y = -0.01f; Global.action.tileMap.UpdateEventGrid(this, GetMapPos(), new int[2] { GetMapPos()[0], GetMapPos()[1] - 1 }); } if (dir == Tile.Direction.EAST){ travel.X = +0.01f; Global.action.tileMap.UpdateEventGrid(this, GetMapPos(), new int[2] { GetMapPos()[0] + 1, GetMapPos()[1] }); } if (dir == Tile.Direction.WEST){ travel.X = -0.01f; Global.action.tileMap.UpdateEventGrid(this, GetMapPos(), new int[2] { GetMapPos()[0] - 1, GetMapPos()[1] }); } } } }