/// <summary> /// If the player has stopped swinging, stop parrying. /// </summary> /// <param name="e">A BothMouseButtonsUpEvent</param> private void ReleaseFromParry(global::Event e) { Debug.Assert(e.GetType() == typeof(BothMouseButtonsUpEvent), "Non-BothMouseButtonsUpEvent in ReleaseFromParry."); Services.Events.Unregister <BothMouseButtonsUpEvent>(ReleaseFromParry); SetStatus(TaskStatus.Success); }
public void IncreaseOveralMultiplier(global::Event e) { Debug.Assert(e.GetType() == typeof(SwordContactEvent), "Non-SwordContactEvent in IncreaseOverallMultiplier"); SwordContactEvent swordEvent = e as SwordContactEvent; if (swordEvent.rb.transform.parent.gameObject.name == PLAYER_OBJ && swordEvent.collision.collider.gameObject.name == OPPONENT_OBJ + OPPONENT_SWORD_OBJ) { OverallMultiplier += overallIncrement; Services.Events.Fire(new NewSpeedEvent(OverallMultiplier)); if (Services.Speed.OverallMultiplier >= vulnerableMultiplier) { Services.UI.ChangeExplanatoryMessage(STRIKE_MSG); } } else if (swordEvent.collision.collider.gameObject.name.Contains(OPPONENT_OBJ) && Services.Speed.OverallMultiplier < vulnerableMultiplier) { Services.UI.ChangeExplanatoryMessage(SPEED_UP_MSG); } else if (swordEvent.collision.collider.gameObject.name.Contains(OPPONENT_OBJ) && Services.Speed.OverallMultiplier >= vulnerableMultiplier) { Services.UI.ChangeExplanatoryMessage(SUCCESS_MSG); } else if ((swordEvent.collision.collider.gameObject.name == PLAYER_OBJ + BODY_OBJ) || (swordEvent.collision.collider.gameObject.name == PLAYER_OBJ + HEAD_OBJ) && Services.Speed.OverallMultiplier >= vulnerableMultiplier) { Services.UI.ChangeExplanatoryMessage(LOSE_MSG); } }
public void CreateGetEmployeeResponseMedAnsattTest() { var ansatt = new Ansatt() { navn = new Personnavn() { etternavn = "Olsen", fornavn = "Ole" } }; var getEmployee = new global::Event() { data = new object[] { ansatt }, verb = "getEmployee", type = type.RESPONSE, time = DateTime.Now, id = "123", orgId = "" }; var getEmployeeJson = JsonConvert.SerializeObject(getEmployee); var getEmployeeResponse = JsonConvert.DeserializeObject <global::Event>(getEmployeeJson); var getEmployeeResponseJson = JsonConvert.SerializeObject(getEmployeeResponse); Assert.IsTrue(getEmployeeJson.Equals(getEmployeeResponseJson)); }
private void HandleMoveInputs(global::Event e) { InputEvent inputEvent = e as InputEvent; //don't double-count inputs that are intended to hide the character sheet if (Services.UI.GetCharSheetStatus() == CharacterSheetBehavior.SheetStatus.Displayed) { return; } if (Services.UI.GetTutorialText() != MOVE_EXPLANATION_MSG) { return; //only move after the player has seen the explanation } if (inputEvent.selected.tag == DEFENDER_TAG) { Services.Defenders.SelectDefenderForMovement(inputEvent.selected.GetComponent <DefenderSandbox>()); Context.ToggleMoveNotice(Services.Defenders.GetSelectedDefender(), Indicate.Start); } else if (inputEvent.selected.tag == BOARD_TAG) { if (Services.Defenders.IsAnyoneSelected()) { Services.Defenders.GetSelectedDefender().TryPlanMove(inputEvent.selected.GetComponent <SpaceBehavior>().GridLocation); } } }
private void OnButtonClick(global::Event e) { switch (Services.UI.GetTutorialText()) { case WELCOME_MSG: clickHereNotice.SetActive(false); Context.ChangeUIText(THEME_MSG, DEFENDERS_WHERE_MSG); break; case THEME_MSG: Context.NoteObject(DEFENDER_TAG, Indicate.Start); Context.ChangeUIText(DEFENDERS_HERE_MSG, CANT_LOSE_MSG); break; case DEFENDERS_HERE_MSG: Context.NoteObject(DEFENDER_TAG, Indicate.Stop); Services.Board.HighlightRow(0, BoardBehavior.OnOrOff.On); Context.ChangeUIText(HOW_LOSE_MSG, TOWN_LOCATION_MSG); break; case HOW_LOSE_MSG: Services.Board.HighlightRow(0, BoardBehavior.OnOrOff.Off); Context.ChangeUIText(START_TURN_MSG, OK_MSG); break; case START_TURN_MSG: Services.UI.TogglePhaseButton(ChatUI.OnOrOff.Off); TransitionTo <AttackersAdvance>(); break; } }
protected virtual void Parry(global::Event e) { Debug.Assert(e.GetType() == typeof(StrikingEvent), "Non-StrikingEvent in Parry."); //don't attempt to parry if currently striking if (Services.Tasks.CheckForTaskOfType <StrikeTask>()) { return; } //Announce that the opponent is going to parry; important for AdoptStanceTask to know that it needs to abort so that a parrying stance can be adopted Services.Events.Fire(new ParryEvent()); //Calculate direction in which sword is being held, as a hacky way to decide which way to parry Vector3 playerSwordDir = (playerSword.position - player.position).normalized; if (playerSwordDir.y >= Mathf.Abs(playerSwordDir.x)) { Services.Tasks.AddTask(new AdoptStanceTask(OpponentStances.Parries.High, this)); } else if (playerSwordDir.x < 0.0f) { Services.Tasks.AddTask(new AdoptStanceTask(OpponentStances.Parries.Right, this)); } else { Services.Tasks.AddTask(new AdoptStanceTask(OpponentStances.Parries.Left, this)); } }
private void HandleFightInputs(global::Event e) { Debug.Assert(e.GetType() == typeof(InputEvent), "Non-InputEvent in HandleFightInputs"); InputEvent inputEvent = e as InputEvent; if (inputEvent.selected.tag == DEFENDER_TAG && (Services.UI.GetTutorialText() == DIFFERENT_CARDS_MSG || Services.UI.GetTutorialText() == CHOOSE_CARDS_MSG || Services.UI.GetTutorialText() == KEEP_FIGHTING_MSG)) { Services.Defenders.SelectDefenderForFight(inputEvent.selected.GetComponent <DefenderSandbox>()); } else if ((inputEvent.selected.tag == ATTACKER_TAG || inputEvent.selected.tag == MINION_TAG || inputEvent.selected.tag == LEADER_TAG) && Services.Defenders.IsAnyoneSelected() && Services.Defenders.GetSelectedDefender().GetChosenCardValue() != DefenderSandbox.NO_CARD_SELECTED && (Services.UI.GetTutorialText() == CHOOSE_CARDS_MSG || Services.UI.GetTutorialText() == KEEP_FIGHTING_MSG)) { Services.Defenders.GetSelectedDefender().TryFight(inputEvent.selected.GetComponent <AttackerSandbox>()); Services.UI.SetTutorialText(KEEP_FIGHTING_MSG); completedCombats++; if (completedCombats >= TOTAL_DEFENDERS) { Context.ChangeUIText(WELL_FOUGHT_MSG, TWO_QS_MSG); Services.UI.TogglePhaseButton(ChatUI.OnOrOff.On); } } }
protected virtual void RotateHandsViaInput(global::Event e) { Debug.Assert(e.GetType() == typeof(MouseEvent), "Non-MouseEvent in MoveHands."); MouseEvent mouseEvent = e as MouseEvent; //swing or return if both buttons are pressed if (mouseEvent.LMB && mouseEvent.RMB) { rb.MoveRotation(SwingOrReturn()); } //rotate hands if either LMB or RMB is pressed else if (mouseEvent.LMB || mouseEvent.RMB) { //set the amount of rotation for this frame if (mouseEvent.LMB) { deltaRotation = Quaternion.Euler(baseRotation * Services.Speed.OverallMultiplier * Time.deltaTime); } //rotate left for LMB else { deltaRotation = Quaternion.Euler(baseRotation * Services.Speed.OverallMultiplier * Time.deltaTime * -1.0f); } //rotate right for RMB //actually spin the hands rb.MoveRotation(rb.rotation * deltaRotation); } }
private void OnButtonClick(global::Event e) { Debug.Assert(e.GetType() == typeof(TutorialClick), "Non-TutorialClick in BesiegeWalls' OnButtonClick"); switch (Services.UI.GetTutorialText()) { case POWER_CONCLUSION_MSG: Services.UI.SetTutorialText(BESIEGE_INTRO_MSG); Services.UI.SetButtonText(HOW_WORK_MSG); break; case BESIEGE_INTRO_MSG: Services.UI.SetTutorialText(SPEND_CARDS_MSG); Services.UI.SetButtonText(CARD_USE_MSG); break; case SPEND_CARDS_MSG: Services.UI.SetTutorialText(ATK_CARDS_MSG); Services.UI.SetButtonText(EXAMPLE_MSG); break; case ATK_CARDS_MSG: Besiege(); break; } }
/// <summary> /// In the tutorial, it's OK to always reset momentum--the attacker doesn't get a turn 2 to use it. /// </summary> /// <param name="e">An EndPhaseEvent.</param> public override void ResetMomentum(global::Event e) { Debug.Assert(e.GetType() == typeof(EndPhaseEvent), "Non-EndPhaseEvent in ResetMomentum"); Momentum = START_MOMENTUM; }
/// <summary> /// Drop a tankard in a chosen empty space. Also set the space's state accordingly, and provide feedback. /// </summary> /// <param name="e">An InputEvent with the relevant space.</param> private void DropTankard(global::Event e) { Debug.Assert(e.GetType() == typeof(InputEvent), "Non-InputEvent in DropTankard."); InputEvent inputEvent = e as InputEvent; if (inputEvent.selected.tag == BOARD_TAG && Services.UI.GetCharSheetStatus() == CharacterSheetBehavior.SheetStatus.Hidden) { SpaceBehavior space = inputEvent.selected.GetComponent <SpaceBehavior>(); if (Services.Board.GeneralSpaceQuery(space.GridLocation.x, space.GridLocation.z) != SpaceBehavior.ContentType.None) { return; } Services.Tasks.AddTask(new BlockSpaceFeedbackTask(space.GridLocation.x, space.GridLocation.z, GetTankard())); space.Tankard = true; GameObject.Find(GetTankard()).GetComponent <TankardBehavior>().GridLoc = new TwoDLoc(space.GridLocation.x, space.GridLocation.z); drops--; } if (drops <= 0) { SetStatus(TaskStatus.Success); } }
private void PutDownBlock(global::Event e) { Debug.Assert(e.GetType() == typeof(InputEvent), "Non-InputEvent in PutDownBlock"); InputEvent inputEvent = e as InputEvent; if (inputEvent.selected.tag == BOARD_TAG) { SpaceBehavior space = inputEvent.selected.GetComponent <SpaceBehavior>(); //if the space isn't blockable for any reason, stop if (!CheckBlockable(space.GridLocation)) { return; } //the space is blockable; put down the rockfall and provide appropriate feedback space.Block = true; Services.Tasks.AddTask(new BlockSpaceFeedbackTask(space.GridLocation.x, space.GridLocation.z, BLOCK_MARKER_OBJ)); //tell the Ranger where the rockfall is if (ranger.GetCurrentTrapTrack() == RangerBehavior.TrapTrack.Rockfall) { ranger.RockfallLoc = new TwoDLoc(space.GridLocation.x, space.GridLocation.z); } Services.Board.HighlightAllAroundSpace(ranger.ReportGridLoc().x, ranger.ReportGridLoc().z, BoardBehavior.OnOrOff.Off, true); SetStatus(TaskStatus.Success); } }
/// <summary> /// Is there a need to wait before going on to PlayerFight? There is if: /// /// 1. The Guardian needs to select a column for the Hold the Line track. /// /// IMPORTANT: this assumes that there is only ever going to be one reason to wait, so there will never be /// conflicting needs (i.e., one defender still needs the system to wait while another is saying to go ahead). /// If conflicting needs are possible, this will need to be refactored to take that into account. /// </summary> private void CheckNeedWait(global::Event e) { Debug.Assert(e.GetType() == typeof(NeedWaitEvent), "Non-NeedWaitEvent in CheckNeedWait"); NeedWaitEvent waitEvent = e as NeedWaitEvent; needWait = waitEvent.needWait; }
private void UpdateMultiplierText(global::Event e) { Debug.Assert(e.GetType() == typeof(NewSpeedEvent), "Non-NewSpeedEvent in UpdateMultiplierText."); NewSpeedEvent speedEvent = e as NewSpeedEvent; multiplierText.SetText(speedEvent.newSpeed.ToString()); }
/// <summary> /// When the player chooses a power, see if the player is done upgrading and it's time to move on to the next phase. /// </summary> /// <param name="e">A PowerChoiceEvent sent out by the character sheet.</param> private void HandlePowerChoice(global::Event e) { Debug.Assert(e.GetType() == typeof(TutorialPowerChoiceEvent), "Non-TutorialPowerChoiceEvent in HandlePowerChoice"); TutorialPowerChoiceEvent powerEvent = e as TutorialPowerChoiceEvent; CheckForAllFinished(powerEvent.defender); }
private void MoveSpeedMarker(global::Event e) { Debug.Assert(e.GetType() == typeof(PositionEvent), "Non-PositionEvent in MoveSpeedMarker"); PositionEvent posEvent = e as PositionEvent; readout.rectTransform.position = RepositionMarker(posEvent.pos); readout.text = ChangeMarkerText(posEvent.pos); readout.color = ChangeMarkerColor(posEvent.pos); }
/// <summary> /// Stop the icon's movement when the fight phase ends (implicitly occurs if the Besiege Walls phase has begun). /// </summary> /// <param name="e">A PhaseStartEvent.</param> private void ListenForCombatEnd(global::Event e) { Debug.Assert(e.GetType() == typeof(PhaseStartEvent), "Non-PhaseStartEvent in ListenForCombatEnd"); PhaseStartEvent phaseEvent = e as PhaseStartEvent; if (phaseEvent.Phase.GetType() == typeof(TurnManager.BesiegeWalls)) { SetStatus(TaskStatus.Success); } }
/// <summary> /// When a defender is no longer selectable for any reason, it sends out a NotSelectableEvent. /// This script listens for those events, and stops the icon's movement when it receives such /// an event for its defender. /// </summary> /// <param name="e">A NotSelectableEvent.</param> private void ListenForDefenderDone(global::Event e) { Debug.Assert(e.GetType() == typeof(NotSelectableEvent), "Non-NotSelectableEvent in ListenForDefenderDone"); NotSelectableEvent notEvent = e as NotSelectableEvent; if (notEvent.defender == defender) { SetStatus(TaskStatus.Success); } }
/// <summary> /// This function has the opponent pull their sword back to the position it was in when they started the attack. /// </summary> /// <param name="e">A SwordContactEvent</param> protected virtual void WithdrawSequence(global::Event e) { Debug.Assert(e.GetType() == typeof(SwordContactEvent), "Non-SwordContactEvent in WithdrawSequence()."); SwordContactEvent contactEvent = e as SwordContactEvent; //make sure the contacting sword is this opponent's sword, not the player's sword, etc. if (contactEvent.rb.transform.parent.gameObject.name == opponentObjName) { Services.Tasks.AddTaskExclusive(new AdoptStanceTask(startStance, this)); } }
protected void BecomeVulnerable(global::Event e) { Debug.Assert(e.GetType() == typeof(NewSpeedEvent), "Non-NewSpeedEvent in BecomeVulnerable"); NewSpeedEvent speedEvent = e as NewSpeedEvent; if (speedEvent.newSpeed >= Services.Speed.VulnerableMultiplier) { bodyRb.isKinematic = false; headRb.isKinematic = false; } }
/// <summary> /// Starts or stops the camera's rotation. /// </summary> private void SetCameraRotation(global::Event e) { Debug.Assert(e.GetType() == typeof(ToggleCamRotEvent), "Non-ToggleCamRotEvent in SetCameraRotation"); if (camState == CameraState.Rotating) { camState = CameraState.Reading_Credits; } else { camState = CameraState.Rotating; } }
/// <summary> /// Handle player attempts to choose a space to teleport to: /// /// 1. Confirm that the player chose a space. /// 2. Confirm that the space is empty. /// 3. If the player is only allowed to move to adjacent spaces, confirm that the space is adjacent. /// 4. Start a task that moves the defender to the chosen space. /// </summary> /// <param name="e"></param> private void SelectDestination(global::Event e) { Debug.Assert(e.GetType() == typeof(InputEvent), "Non-InputEvent in SelectDestination"); InputEvent inputEvent = e as InputEvent; if (inputEvent.selected.tag == BOARD_TAG && Services.UI.GetCharSheetStatus() == CharacterSheetBehavior.SheetStatus.Hidden) { SpaceBehavior space = inputEvent.selected.GetComponent <SpaceBehavior>(); //stop if the player chose a space that has something in it if (Services.Board.GeneralSpaceQuery(space.GridLocation.x, space.GridLocation.z) != SpaceBehavior.ContentType.None) { return; } //stop if the defender needs to teleport to an adjacent space and the selected space is not adjacent if (destination == PossibleDestinations.Adjacent) { if (!Services.Board.CheckAdjacentSpace(defender.ReportGridLoc().x, defender.ReportGridLoc().z, space.GridLocation.x, space.GridLocation.z)) { return; } } //physically move the defender model Services.Tasks.AddTask(new MoveDefenderTask(defender.gameObject.GetComponent <Rigidbody>(), defender.GetScreenMoveSpeed(), new List <TwoDLoc>() { defender.ReportGridLoc(), space.GridLocation })); //update the board Services.Board.TakeThingFromSpace(defender.ReportGridLoc().x, defender.ReportGridLoc().z); Services.Board.PutThingInSpace(defender.gameObject, space.GridLocation.x, space.GridLocation.z, SpaceBehavior.ContentType.Defender); defender.NewLoc(space.GridLocation.x, space.GridLocation.z); SetStatus(TaskStatus.Success); } }
/// <summary> /// Tell the next attacker to move, or be done if there are no more attackers. /// </summary> /// <param name="e">A SequencedMoveEvent.</param> private void GoToNextAttacker(global::Event e) { Debug.Assert(e.GetType() == typeof(SequencedMoveEvent), "Non-SequencedMoveEvent in GoToNextAttacker"); index++; if (index <= attackers.Count) { OrderNextMove(); } else { SetStatus(TaskStatus.Success); } }
/// <summary> /// Decide whether the player is swinging the sword, or returning to guard. /// /// When a BothMouseButtonsEvent is detected, switch between those states. In addition, send out an event so that the opponent can decide whether and how to respond. /// </summary> /// <param name="e">A BothMouseButtonsEvent.</param> protected virtual void SwordStateViaInput(global::Event e) { Debug.Assert(e.GetType() == typeof(BothMouseButtonsEvent), "Non-BothMouseButtonsEvent in SwordStateViaInput()."); if (currentState == SwordState.Swinging) { currentState = SwordState.Returning; Services.Events.Fire(new WithdrawingEvent()); } else if (currentState == SwordState.Returning || currentState == SwordState.Guard) { currentState = SwordState.Swinging; Services.Events.Fire(new StrikingEvent()); } }
//move hands based on player input protected virtual void MoveHandsViaInput(global::Event e) { Debug.Assert(e.GetType() == typeof(KeyDirectionEvent), "Non-KeyDirectionEvent in MoveHands."); KeyDirectionEvent dirEvent = e as KeyDirectionEvent; //move hands InputManager.Directions dir = dirEvent.direction; switch (dir) { case InputManager.Directions.Up: rb.AddForce(ApplyMovement(Vector3.up), ForceMode.VelocityChange); break; case InputManager.Directions.Down: rb.AddForce(ApplyMovement(Vector3.down), ForceMode.VelocityChange); break; case InputManager.Directions.Left: rb.AddForce(ApplyMovement(Vector3.left), ForceMode.VelocityChange); break; case InputManager.Directions.Right: rb.AddForce(ApplyMovement(Vector3.right), ForceMode.VelocityChange); break; case InputManager.Directions.Diag_Up_Left: rb.AddForce(ApplyMovement(Vector3.up), ForceMode.VelocityChange); rb.AddForce(ApplyMovement(Vector3.left), ForceMode.VelocityChange); break; case InputManager.Directions.Diag_Up_Right: rb.AddForce(ApplyMovement(Vector3.up), ForceMode.VelocityChange); rb.AddForce(ApplyMovement(Vector3.right), ForceMode.VelocityChange); break; case InputManager.Directions.Diag_Down_Left: rb.AddForce(ApplyMovement(Vector3.down), ForceMode.VelocityChange); rb.AddForce(ApplyMovement(Vector3.left), ForceMode.VelocityChange); break; case InputManager.Directions.Diag_Down_Right: rb.AddForce(ApplyMovement(Vector3.down), ForceMode.VelocityChange); rb.AddForce(ApplyMovement(Vector3.right), ForceMode.VelocityChange); break; } }
private void OnButtonClick(global::Event e) { switch (Services.UI.GetTutorialText()) { case MOVE_START_MSG: Services.UI.SetTutorialText(MOVE_EXPLANATION_MSG); Services.UI.TogglePhaseButton(ChatUI.OnOrOff.Off); Services.UI.ToggleUndoButton(ChatUI.OnOrOff.On); HighlightGoalSpaces(); break; case MOVE_EXPLANATION_MSG: TransitionTo <PlayerFight>(); break; } }
private void ChooseAttacker(global::Event e) { Debug.Assert(e.GetType() == typeof(InputEvent), "Non-InputEvent in ChooseAttacker"); InputEvent inputEvent = e as InputEvent; if (inputEvent.selected.tag == attackerType.ToString()) { AttackerSandbox attacker = inputEvent.selected.GetComponent <AttackerSandbox>(); attacker.TakeDamage(attacker.Health); defender.DefeatAttacker(); SetStatus(TaskStatus.Success); } }
private void OnButtonClick(global::Event e) { Debug.Assert(e.GetType() == typeof(TutorialClick), "Non-TutorialClick in BesiegeWalls' OnButtonClick"); switch (Services.UI.GetTutorialText()) { case EVERYTHING_MSG: Services.UI.SetTutorialText(WARLORD_A_MSG); Services.UI.SetButtonText(EXPLANATION_Q_MSG); break; case WARLORD_A_MSG: Services.UI.SetTutorialText(EXPLANATION_A_MSG); Services.UI.SetButtonText(OVERVIEW_REQ_MSG); break; case EXPLANATION_A_MSG: Services.UI.SetTutorialText(OVERVIEW_1_MSG); Services.UI.SetButtonText(ELLIPSIS_MSG); break; case OVERVIEW_1_MSG: Services.UI.SetTutorialText(OVERVIEW_2_MSG); break; case OVERVIEW_2_MSG: Services.UI.SetTutorialText(OVERVIEW_3_MSG); break; case OVERVIEW_3_MSG: Services.UI.SetTutorialText(OVERVIEW_4_MSG); break; case OVERVIEW_4_MSG: Services.UI.SetTutorialText(OVERVIEW_5_MSG); break; case OVERVIEW_5_MSG: Services.UI.SetTutorialText(WAVES_MSG); Services.UI.SetButtonText(START_MSG); break; case WAVES_MSG: SceneManager.LoadScene(NEXT_SCENE); break; } }
private void OnButtonClick(global::Event e) { Debug.Assert(e.GetType() == typeof(TutorialClick), "Non-TutorialClick in PowerUp's OnButtonClick"); switch (Services.UI.GetTutorialText()) { case WHEN_POWER_MSG: Context.ChangeUIText(SHEET_EXPLANATION_MSG, READY_MSG); break; case SHEET_EXPLANATION_MSG: Services.UI.ToggleTutorialText(ChatUI.OnOrOff.Off); Services.UI.TogglePhaseButton(ChatUI.OnOrOff.Off); BeginUpgrading(); break; } }
private void HandlePausing(global::Event e) { Debug.Assert(e.GetType() == typeof(PauseEvent), "Non-PauseEvent in HandlePausing."); PauseEvent pauseEvent = e as PauseEvent; if (pauseEvent.action == PauseEvent.Pause.Pause) { paused = true; Services.Sound.PlayPauseMusic(); } else { paused = false; Services.Sound.ResumeMusic(); } }