private void onPlayerMoveSet(PlayerMoveEventArgs i_EventArgs) { if (PlayerMoveSet != null) { PlayerMoveSet.Invoke(this, i_EventArgs); } }
//Check if this slot has a valid command card public PlayerMoveSet CheckOccupancy() { if (transform.childCount <= 0) { _moveSetInSlot = PlayerMoveSet.none; } return(_moveSetInSlot); }
//Iterate Over the player commands during the players turn void RelayCommand() { float waitForNextCommandDuration; PlayerMoveSet tempPlayerMoveSet = _playerMoveSetArray [_currentMoveCnt]; waitForNextCommandDuration = _playerRobotController.HandlePlayerCommand(tempPlayerMoveSet); _currentMoveCnt++; StartCoroutine(WaitForNextCommand(waitForNextCommandDuration)); }
//bring back removed cards into play when drawn from deck public void Activate(Sprite sprite, PlayerMoveSet playerMoveSet) { _image.sprite = sprite; _whichMoveSet = playerMoveSet; _commandHover.enabled = true; if (_thisCanvasGroup == null) { _thisCanvasGroup = GetComponent <CanvasGroup> (); } _thisCanvasGroup.interactable = true; _image.raycastTarget = true; _image.color = _fullColor; transform.SetParent(_handArea); _removedFromPlay = false; }
// Iteration of the enemy moveset to determine next action void HandleEnemyMove() { PlayerMoveSet tempMoveSet = _enemyMoveSetArray [_currentMoveIndex]; switch (tempMoveSet) { case PlayerMoveSet.AttackLeft: Attack(true); break; case PlayerMoveSet.AttackRight: Attack(false); break; case PlayerMoveSet.MoveLeft: Move(true); break; case PlayerMoveSet.MoveRight: Move(false); break; case PlayerMoveSet.JumpUp: Jump(true); break; case PlayerMoveSet.JumpDown: Jump(false); break; case PlayerMoveSet.Rest: Rest(); break; default: break; } _currentMoveIndex++; if (_currentMoveIndex >= _thisEnemyMovesetLength) { _currentMoveIndex = 0; } }
//Handle drop of command card public void OnDrop(PointerEventData eventData) { CommandDrag commandDrag = eventData.pointerDrag.GetComponent <CommandDrag> (); if (commandDrag != null) { //Code specific to handling Slots if (_whichSlot != Slot.Hand) { if (transform.childCount > 0) { _occupantCommand.ReturnToHand(); } _moveSetInSlot = commandDrag.WhichMoveSet; _occupantCommand = commandDrag; } commandDrag.OriginParent = this.transform; } }
public float HandlePlayerCommand(PlayerMoveSet playerMoveSet) { float waitDuration = 0f; switch (playerMoveSet) { case PlayerMoveSet.AttackLeft: waitDuration = Attack(true); break; case PlayerMoveSet.AttackRight: waitDuration = Attack(false); break; case PlayerMoveSet.MoveLeft: waitDuration = Move(true); break; case PlayerMoveSet.MoveRight: waitDuration = Move(false); break; case PlayerMoveSet.JumpUp: waitDuration = Jump(true); break; case PlayerMoveSet.JumpDown: waitDuration = Jump(false); break; case PlayerMoveSet.Rest: waitDuration = Rest(); break; default: break; } return(waitDuration + 0.5f); }
//Triggered by button press // Checks if all appropriate slots have been filled to either accept or reject player sequence input public void ConfirmStrategy() { AudioManager._audioManagerInstance.PlayButtonClick(); int slotCnt = _slots.Length; for (int i = 0; i < slotCnt; i++) { PlayerMoveSet tempMoveSet = _slots [i].CheckOccupancy(); if (tempMoveSet != PlayerMoveSet.none) { _tentativePlayerMoveSet [i] = tempMoveSet; } else { Debug.Log(tempMoveSet); ReturnAllCardsToHand(slotCnt); return; } } _playerCommandManager.FeedInCommands(_tentativePlayerMoveSet); GameManager._gameManagerInstance.MoveToNextState(); RemoveConfirmedCardsFromPlay(slotCnt); _confirmButton.interactable = false; }
/* Current level Parsing Logic (Line 0 - 4: Level Composition) * F = floor * W = wall * J = jump * L = jump Wall * */ //Parse a line from the text document void ParseString(string line, int lineCnt) { if (lineCnt < 5) { int length = line.Length; int y = 4 - lineCnt; int x = length < _tileGridData.horizontalTileCnt ? length : _tileGridData.horizontalTileCnt; for (int i = 0; i < x; i++) { Tile tempTile = _tiles [i, y]; switch (line [i]) { case 'H': break; case 'W': tempTile.isWall = true; break; case 'J': tempTile.isJump = true; break; case 'L': tempTile.isWall = true; tempTile.isJump = true; break; default: break; } _tiles [i, y] = tempTile; } } else { // Split string by delimiter string[] tempString = line.Split(_delimiter); // 0 - horizontal index int enemyH = int.Parse(tempString [0]); // 1 - vertical index int enemyV = int.Parse(tempString [1]); // 2 - enemy moveset int length = tempString [2].Length; PlayerMoveSet[] tempEnemyMoveset = new PlayerMoveSet[length]; for (int i = 0; i < length; i++) { switch (tempString [2] [i]) { case 'C': tempEnemyMoveset[i] = PlayerMoveSet.MoveLeft; break; case 'D': tempEnemyMoveset[i] = PlayerMoveSet.MoveRight; break; case 'E': tempEnemyMoveset[i] = PlayerMoveSet.JumpUp; break; case 'F': tempEnemyMoveset[i] = PlayerMoveSet.JumpDown; break; case 'G': tempEnemyMoveset[i] = PlayerMoveSet.Rest; break; default: break; } } //Call to instantiate enemy GenerateEnemy(enemyH, enemyV, tempEnemyMoveset); } }