public void GetInput(PlayerInfo.MovementDirection current, PlayerInfo.MovementDirection previous) { if(this.isMoving) return; this._canUndo = false; this.GetCurrentBlock(); this.CheckCurrentBlock(); AIMovement.instance.ResetMovement(); AIMovement.instance.UndoPosition = this.transform.position; if(current == PlayerInfo.MovementDirection.FORWARD) { this._currentDirection = PlayerInfo.MovementDirection.BACKWARD; AIMovement.instance.RotateToMovement(180.0f); AIMovement.instance.MoveVector = new Vector3(0, 0, -1); } else if(current == PlayerInfo.MovementDirection.RIGHT) { this._currentDirection = PlayerInfo.MovementDirection.LEFT; AIMovement.instance.RotateToMovement(270.0f); AIMovement.instance.MoveVector = new Vector3(-1, 0, 0); } else if(current == PlayerInfo.MovementDirection.BACKWARD) { this._currentDirection = PlayerInfo.MovementDirection.FORWARD; AIMovement.instance.RotateToMovement(0.0f); AIMovement.instance.MoveVector = new Vector3(0, 0, 1); } else if(current == PlayerInfo.MovementDirection.LEFT) { this._currentDirection = PlayerInfo.MovementDirection.RIGHT; AIMovement.instance.RotateToMovement(90.0f); AIMovement.instance.MoveVector = new Vector3(1, 0, 0); } this.CheckCurrentBlock(); //AIAudio.instance.PlayMovement(); this.isMoving = true; this.previousPos = this.currentPos; this.currentPos = new Vector2(this.transform.position.x, this.transform.position.z); }
public void UndoMovement() { this._moveCount -= 1; this.UndoBlocks(this.directionCurrent, this.directionPrevious); this.directionCurrent = this.directionPrevious; this.directionPrevious = PlayerInfo.MovementDirection.NONE; }
void Awake() { instance = this; characterController = GetComponent<CharacterController>() as CharacterController; this._currentBlock = null; this._currentDirection = PlayerInfo.MovementDirection.NONE; }
void Awake() { instance = this; characterController = GetComponent<CharacterController>() as CharacterController; this.indicationTexture = this.indication.GetComponent<AnimateTextureSheet>() as AnimateTextureSheet; this._currentBlock = null; this._currentDirection = PlayerInfo.MovementDirection.NONE; }
void Awake() { instance = this; characterController = GetComponent <CharacterController>() as CharacterController; this._currentBlock = null; this._currentDirection = PlayerInfo.MovementDirection.NONE; }
void Awake() { instance = this; characterController = GetComponent <CharacterController>() as CharacterController; this.indicationTexture = this.indication.GetComponent <AnimateTextureSheet>() as AnimateTextureSheet; this._currentBlock = null; this._currentDirection = PlayerInfo.MovementDirection.NONE; }
public void UndoMovement() { if (this._canUndo) { this.isMoving = false; AIMovement.instance.UndoMovement(); this._currentDirection = PlayerInfo.MovementDirection.NONE; this._canUndo = false; } }
public override void SetupBlock(BlockInfo.BlockTypes type, BlockInfo.BlockDirection direction, BlockInfo.BlockState state) { base.SetupBlock(type, direction, state); this.warpDirection = (PlayerInfo.MovementDirection)((int)direction); #if UNITY_EDITOR this.SetMiscMaterial(); #endif this.blockMaterials[1] = this.warpDownMaterial; this.blockRenderer.sharedMaterials = this.blockMaterials; }
public void GetInput(PlayerInfo.MovementDirection current, PlayerInfo.MovementDirection previous) { if (this.isMoving) { return; } if (this.indicationTexture.isPlaying || this.isStunned) { this.indication.SetActive(false); } this._canUndo = false; this.GetCurrentBlock(); this.CheckCurrentBlock(); PlayerMovement.instance.ResetMovement(); PlayerMovement.instance.UndoPosition = this.transform.position; if (current == PlayerInfo.MovementDirection.FORWARD) { this._currentDirection = current; PlayerMovement.instance.RotateToMovement(0.0f); PlayerMovement.instance.MoveVector = new Vector3(0, 0, 1); } else if (current == PlayerInfo.MovementDirection.RIGHT) { this._currentDirection = current; PlayerMovement.instance.RotateToMovement(90.0f); PlayerMovement.instance.MoveVector = new Vector3(1, 0, 0); } else if (current == PlayerInfo.MovementDirection.BACKWARD) { this._currentDirection = current; PlayerMovement.instance.RotateToMovement(180.0f); PlayerMovement.instance.MoveVector = new Vector3(0, 0, -1); } else if (current == PlayerInfo.MovementDirection.LEFT) { this._currentDirection = current; PlayerMovement.instance.RotateToMovement(270.0f); PlayerMovement.instance.MoveVector = new Vector3(-1, 0, 0); } this.CheckCurrentBlock(); PlayerAudio.instance.PlayMovement(); this.isMoving = true; this.previousPos = this.currentPos; this.currentPos = new Vector2(this.transform.position.x, this.transform.position.z); }
public override void SetupBlock(BlockInfo.BlockTypes type, BlockInfo.BlockDirection direction) { base.SetupBlock(type, direction); this.warpDirection = (PlayerInfo.MovementDirection)((int)direction); #if UNITY_EDITOR this.SetMiscMaterial(); #endif this.blockMaterials[1] = this.warpDownMaterial; this.blockRenderer.sharedMaterials = this.blockMaterials; }
public void UndoMovement() { if(this._canUndo) { this.isMoving = false; GridController.instance.UndoMovement(); PlayerMovement.instance.UndoMovement(); this._currentDirection = PlayerInfo.MovementDirection.NONE; this._canUndo = false; } }
private void GetInput() { if(PlayerController.instance.isMoving || AIController.instance.isMoving) return; if(PlayerController.instance.isStunned || AIController.instance.isStunned){ this._stunTimer += Time.deltaTime; if(this._stunTimer > 2.0f) { PlayerController.instance.isStunned = false; AIController.instance.isStunned = false; this._moveCount++; this._stunTimer = 0.0f; } } if(MazeInfo.MazeMoveValue != null) { if(this._moveCount >= (this._maxMoves * 3)) { PlayerController.instance.isMoving = false; AIController.instance.isMoving = false; PlayerController.instance.isDeath = true; PlayerController.instance.charactorAnimator.SetBool("IsDeath", PlayerController.instance.isDeath); AIController.instance.charactorAnimator.SetBool("IsDeath", PlayerController.instance.isDeath); GameController.instance.isStageFinished = true; } } #if UNITY_IPHONE || UNITY_ANDROID if(!this._swipeController.GetInput()) GridController.instance.blocksReady = false; #else if(Input.GetKeyDown(KeyCode.UpArrow)) { this.directionPrevious = this.directionCurrent; this.directionCurrent = PlayerInfo.MovementDirection.FORWARD; if(!PlayerController.instance.isStunned) { PlayerController.instance.GetInput(this.directionCurrent, this.directionPrevious); if(!AIController.instance.isStunned) AIController.instance.GetInput(this.directionCurrent, this.directionPrevious); if(this._moveCount > 0) this.ResetUndoStates(); this.ActivateBlocks(this.directionCurrent, this.directionPrevious); this._moveCount++; } if(MazeInfo.MazeMoveValue != null) { if(this._moveCount >= this._maxMoves * 2) { this.warningColor.a = (this._moveCount / this._maxMoves); } } } else if(Input.GetKeyDown(KeyCode.RightArrow)) { this.directionPrevious = this.directionCurrent; this.directionCurrent = PlayerInfo.MovementDirection.RIGHT; if(!PlayerController.instance.isStunned) { PlayerController.instance.GetInput(this.directionCurrent, this.directionPrevious); if(!AIController.instance.isStunned) AIController.instance.GetInput(this.directionCurrent, this.directionPrevious); if(this._moveCount > 0) this.ResetUndoStates(); this.ActivateBlocks(this.directionCurrent, this.directionPrevious); this._moveCount++; } if(MazeInfo.MazeMoveValue != null) { if(this._moveCount >= this._maxMoves * 2) { this.warningColor.a = (this._moveCount / this._maxMoves); } } } else if(Input.GetKeyDown(KeyCode.DownArrow)) { this.directionPrevious = this.directionCurrent; this.directionCurrent = PlayerInfo.MovementDirection.BACKWARD; if(!PlayerController.instance.isStunned) { PlayerController.instance.GetInput(this.directionCurrent, this.directionPrevious); if(!AIController.instance.isStunned) AIController.instance.GetInput(this.directionCurrent, this.directionPrevious); if(this._moveCount > 0) this.ResetUndoStates(); this.ActivateBlocks(this.directionCurrent, this.directionPrevious); this._moveCount++; } if(MazeInfo.MazeMoveValue != null) { if(this._moveCount >= this._maxMoves * 2) { this.warningColor.a = (this._moveCount / this._maxMoves); } } } else if(Input.GetKeyDown(KeyCode.LeftArrow)) { this.directionPrevious = this.directionCurrent; this.directionCurrent = PlayerInfo.MovementDirection.LEFT; if(!PlayerController.instance.isStunned) { PlayerController.instance.GetInput(this.directionCurrent, this.directionPrevious); if(!AIController.instance.isStunned) AIController.instance.GetInput(this.directionCurrent, this.directionPrevious); if(this._moveCount > 0) this.ResetUndoStates(); this.ActivateBlocks(this.directionCurrent, this.directionPrevious); this._moveCount++; } if(MazeInfo.MazeMoveValue != null) { if(this._moveCount >= this._maxMoves * 2) { this.warningColor.a = (this._moveCount / this._maxMoves); } } } else { GridController.instance.blocksReady = false; } #endif PlayerController.instance.CheckCurrentBlock(); AIController.instance.CheckCurrentBlock(); if(PlayerController.instance.CanUndo & AIController.instance.CanUndo) GameMenuController.instance.undoButton.SetActive(true); else GameMenuController.instance.undoButton.SetActive(false); if(MazeInfo.MazeMoveValue == null) { if(PlayerController.instance.isStunned) GameMenuController.instance.moveText.text = "Moves: " + this._moveCount.ToString() + " (Player Stunned)"; else GameMenuController.instance.moveText.text = "Moves: " + this._moveCount.ToString(); } else { if(MazeInfo.MazeMoveValue.ContainsKey(MazeInfo.CurrentMazeNumber - 1)) { if(PlayerController.instance.isStunned) GameMenuController.instance.moveText.text = "Maze: " + MazeInfo.CurrentMazeNumber.ToString() + " / " + MazeInfo.MaxMazeLength.ToString() + '\n' + "Moves: " + this._moveCount.ToString() + " / " + (this._maxMoves * 3).ToString() + " (Player Stunned)"; else GameMenuController.instance.moveText.text = "Maze: " + MazeInfo.CurrentMazeNumber.ToString() + " / " + MazeInfo.MaxMazeLength.ToString() + '\n' + "Moves: " + this._moveCount.ToString() + " / " + (this._maxMoves * 3).ToString(); } else GameMenuController.instance.moveText.text = "Moves: " + this._moveCount.ToString() + " (Player Stunned)"; } }
public void UndoBlocks(PlayerInfo.MovementDirection currentDirection, PlayerInfo.MovementDirection previousDirection) { int i = 0; int count = 0; BlockInfo.BlockDirection current = (BlockInfo.BlockDirection)((int)currentDirection); BlockInfo.BlockDirection previous = (BlockInfo.BlockDirection)((int)previousDirection); if (currentDirection == previousDirection) { if (this._numberBlocks.Count > 0) { count = this._numberBlocks.Count; for (i = 0; i < count; i++) { this._numberBlocks[i].Undo(); } } this.blocksReady = true; return; } if (this._numberBlocks.Count > 0) { count = this._numberBlocks.Count; for (i = 0; i < count; i++) { this._numberBlocks[i].Undo(); } } if (this._normalBlocks.Count > 0) { count = this._normalBlocks.Count; for (i = 0; i < count; i++) { if (this._normalBlocks[i].FirstDirection == current) { this._normalBlocks[i].BlockState = this._normalBlocks[i].PreviousState; } if (this._normalBlocks[i].FirstDirection == previous) { this._normalBlocks[i].BlockState = this._normalBlocks[i].PreviousState; } else if (previous == BlockInfo.BlockDirection.NONE) { this._normalBlocks[i].BlockState = this._normalBlocks[i].FirstState; } } } if (this._multiBlocks.Count > 0) { count = this._multiBlocks.Count; for (i = 0; i < count; i++) { if (this._multiBlocks[i].BlockDirections.Contains(current) && !this._multiBlocks[i].BlockDirections.Contains(previous)) { this._multiBlocks[i].BlockState = this._multiBlocks[i].PreviousState; } if (this._multiBlocks[i].BlockDirections.Contains(previous)) { if (!this._multiBlocks[i].isUp) { this._multiBlocks[i].BlockState = this._multiBlocks[i].PreviousState; } } else if (previous == BlockInfo.BlockDirection.NONE) { this._multiBlocks[i].BlockState = this._multiBlocks[i].FirstState; } } } if (this._switchBlocks.Count > 0) { count = this._switchBlocks.Count; for (i = 0; i < count; i++) { if (this._switchBlocks[i].IsFlipped) { this._switchBlocks[i].Undo(); this._switchBlocks[i].IsFlipped = false; } } } this.blocksReady = true; }
/// <summary> /// This Function is called whenever the player moves around, so that we can activate the blocks connnected to each movement. /// </summary> /// <param name="currentDirection">The Current Direction The Player Is Moving At.</param> /// <param name="previousDirection">The Previous Direction The Player Was Moving Before.</param> public void ActivateBlocks(PlayerInfo.MovementDirection currentDirection, PlayerInfo.MovementDirection previousDirection) { int i = 0; int count = 0; BlockInfo.BlockDirection current = (BlockInfo.BlockDirection)((int)currentDirection); //BlockInfo.BlockDirection previous = (BlockInfo.BlockDirection)((int)previousDirection); if (currentDirection == previousDirection) { if (this._numberBlocks.Count > 0) { count = this._numberBlocks.Count; for (i = 0; i < count; i++) { if (this._numberBlocks[i].currentCounter == 1) { if (this._numberBlocks[i].isReversed) { this._numberBlocks[i].BlockState = BlockInfo.BlockState.DOWN; } else { this._numberBlocks[i].BlockState = BlockInfo.BlockState.UP; } } else { if (this._numberBlocks[i].isReversed) { this._numberBlocks[i].BlockState = BlockInfo.BlockState.UP; } else { this._numberBlocks[i].BlockState = BlockInfo.BlockState.DOWN; } } } } this.blocksReady = true; return; } if ((this._numberBlocks.Count | this._normalBlocks.Count | this._multiBlocks.Count) > 0) { GridAudio.instance.PlayMovement(); } if (this._numberBlocks.Count > 0) { count = this._numberBlocks.Count; for (i = 0; i < count; i++) { if (this._numberBlocks[i].currentCounter == 1) { if (this._numberBlocks[i].isReversed) { this._numberBlocks[i].BlockState = BlockInfo.BlockState.DOWN; } else { this._numberBlocks[i].BlockState = BlockInfo.BlockState.UP; } } else { if (this._numberBlocks[i].isReversed) { this._numberBlocks[i].BlockState = BlockInfo.BlockState.UP; } else { this._numberBlocks[i].BlockState = BlockInfo.BlockState.DOWN; } } } } if (this._normalBlocks.Count > 0) { count = this._normalBlocks.Count; for (i = 0; i < count; i++) { if (this._normalBlocks[i].FirstDirection == current) { if (this._normalBlocks[i].isUp) { continue; } else { this._normalBlocks[i].BlockState = BlockInfo.BlockState.UP; } } else { if (this._normalBlocks[i].isUp) { this._normalBlocks[i].BlockState = BlockInfo.BlockState.DOWN; } } } } if (this._multiBlocks.Count > 0) { count = this._multiBlocks.Count; for (i = 0; i < count; i++) { if (this._multiBlocks[i].BlockDirections.Contains(current)) { if (this._multiBlocks[i].isUp) { this._multiBlocks[i].PreviousState = BlockInfo.BlockState.UP; continue; } else { this._multiBlocks[i].BlockState = BlockInfo.BlockState.UP; } } else { if (this._multiBlocks[i].isUp) { this._multiBlocks[i].BlockState = BlockInfo.BlockState.DOWN; } } } } this.blocksReady = true; }
private void GetInput() { if (PlayerController.instance.isMoving || AIController.instance.isMoving) { return; } if (PlayerController.instance.isStunned || AIController.instance.isStunned) { this._stunTimer += Time.deltaTime; if (this._stunTimer > 2.0f) { PlayerController.instance.isStunned = false; AIController.instance.isStunned = false; this._moveCount++; this._stunTimer = 0.0f; } } if (MazeInfo.MazeMoveValue != null) { if (this._moveCount >= (this._maxMoves * 3)) { PlayerController.instance.isMoving = false; AIController.instance.isMoving = false; PlayerController.instance.isDeath = true; PlayerController.instance.charactorAnimator.SetBool("IsDeath", PlayerController.instance.isDeath); AIController.instance.charactorAnimator.SetBool("IsDeath", PlayerController.instance.isDeath); GameController.instance.isStageFinished = true; } } #if UNITY_IPHONE || UNITY_ANDROID if (!this._swipeController.GetInput()) { GridController.instance.blocksReady = false; } #else if (Input.GetKeyDown(KeyCode.UpArrow)) { this.directionPrevious = this.directionCurrent; this.directionCurrent = PlayerInfo.MovementDirection.FORWARD; if (!PlayerController.instance.isStunned) { PlayerController.instance.GetInput(this.directionCurrent, this.directionPrevious); if (!AIController.instance.isStunned) { AIController.instance.GetInput(this.directionCurrent, this.directionPrevious); } if (this._moveCount > 0) { this.ResetUndoStates(); } this.ActivateBlocks(this.directionCurrent, this.directionPrevious); this._moveCount++; } if (MazeInfo.MazeMoveValue != null) { if (this._moveCount >= this._maxMoves * 2) { this.warningColor.a = (this._moveCount / this._maxMoves); } } } else if (Input.GetKeyDown(KeyCode.RightArrow)) { this.directionPrevious = this.directionCurrent; this.directionCurrent = PlayerInfo.MovementDirection.RIGHT; if (!PlayerController.instance.isStunned) { PlayerController.instance.GetInput(this.directionCurrent, this.directionPrevious); if (!AIController.instance.isStunned) { AIController.instance.GetInput(this.directionCurrent, this.directionPrevious); } if (this._moveCount > 0) { this.ResetUndoStates(); } this.ActivateBlocks(this.directionCurrent, this.directionPrevious); this._moveCount++; } if (MazeInfo.MazeMoveValue != null) { if (this._moveCount >= this._maxMoves * 2) { this.warningColor.a = (this._moveCount / this._maxMoves); } } } else if (Input.GetKeyDown(KeyCode.DownArrow)) { this.directionPrevious = this.directionCurrent; this.directionCurrent = PlayerInfo.MovementDirection.BACKWARD; if (!PlayerController.instance.isStunned) { PlayerController.instance.GetInput(this.directionCurrent, this.directionPrevious); if (!AIController.instance.isStunned) { AIController.instance.GetInput(this.directionCurrent, this.directionPrevious); } if (this._moveCount > 0) { this.ResetUndoStates(); } this.ActivateBlocks(this.directionCurrent, this.directionPrevious); this._moveCount++; } if (MazeInfo.MazeMoveValue != null) { if (this._moveCount >= this._maxMoves * 2) { this.warningColor.a = (this._moveCount / this._maxMoves); } } } else if (Input.GetKeyDown(KeyCode.LeftArrow)) { this.directionPrevious = this.directionCurrent; this.directionCurrent = PlayerInfo.MovementDirection.LEFT; if (!PlayerController.instance.isStunned) { PlayerController.instance.GetInput(this.directionCurrent, this.directionPrevious); if (!AIController.instance.isStunned) { AIController.instance.GetInput(this.directionCurrent, this.directionPrevious); } if (this._moveCount > 0) { this.ResetUndoStates(); } this.ActivateBlocks(this.directionCurrent, this.directionPrevious); this._moveCount++; } if (MazeInfo.MazeMoveValue != null) { if (this._moveCount >= this._maxMoves * 2) { this.warningColor.a = (this._moveCount / this._maxMoves); } } } else { GridController.instance.blocksReady = false; } #endif PlayerController.instance.CheckCurrentBlock(); AIController.instance.CheckCurrentBlock(); if (PlayerController.instance.CanUndo & AIController.instance.CanUndo) { GameMenuController.instance.undoButton.SetActive(true); } else { GameMenuController.instance.undoButton.SetActive(false); } if (MazeInfo.MazeMoveValue == null) { if (PlayerController.instance.isStunned) { GameMenuController.instance.moveText.text = "Moves: " + this._moveCount.ToString() + " (Player Stunned)"; } else { GameMenuController.instance.moveText.text = "Moves: " + this._moveCount.ToString(); } } else { if (MazeInfo.MazeMoveValue.ContainsKey(MazeInfo.CurrentMazeNumber - 1)) { if (PlayerController.instance.isStunned) { GameMenuController.instance.moveText.text = "Maze: " + MazeInfo.CurrentMazeNumber.ToString() + " / " + MazeInfo.MaxMazeLength.ToString() + '\n' + "Moves: " + this._moveCount.ToString() + " / " + (this._maxMoves * 3).ToString() + " (Player Stunned)"; } else { GameMenuController.instance.moveText.text = "Maze: " + MazeInfo.CurrentMazeNumber.ToString() + " / " + MazeInfo.MaxMazeLength.ToString() + '\n' + "Moves: " + this._moveCount.ToString() + " / " + (this._maxMoves * 3).ToString(); } } else { GameMenuController.instance.moveText.text = "Moves: " + this._moveCount.ToString() + " (Player Stunned)"; } } }