private void Execute(AvailableAction _currentAction) { switch (_currentAction._action) { case PossibleAction.Action_TurnCorner: { if (canMove) { TurnCorner(_currentAction); } break; } case PossibleAction.Action_EnterShop: { if (canMove) { CanMove(false); CanExecuteAction(false); StartCoroutine(EnterShop(_currentAction)); } break; } case PossibleAction.Action_ExitShop: { if (canExecuteAction) { StartCoroutine(ExitShop(_currentAction)); } break; } case PossibleAction.Action_CrossStreet: { if (canMove) { if (currentCrosswalk.currentCWState == CrossWalk.CrosswalkState.CWS_Red) { if (onJayWalking != null) { onJayWalking(); } } canMove = false; StartCoroutine(CrossStreet(_currentAction)); } break; } case PossibleAction.Action_Talk: { Talk(); break; } } }
public void ReadJson(AvailableAction expected, string json) { var converter = AvailableActionsConverter.Instance; using (var stringReader = new StringReader(json)) using (var jsonReader = new JsonTextReader(stringReader)) { Assert.Equal(expected, converter.ReadJson(jsonReader, null, None, false, NewtonsoftJsonSerializer.Deserializer)); } }
private void OnGUI() { if (Event.current.type == EventType.KeyDown) { AvailableAction currentAction = currentAvailableActions.Find(aa => aa._actionKey == Event.current.keyCode); if (currentAction != null) { Execute(currentAction); } } }
private void TurnCorner(AvailableAction _currentAction) { GameObject newCamPoint = _currentAction.triggerObj.GetComponent <CornerTrigger> ().SwitchCameraPoint(); myCamera.gameObject.GetComponent <CameraScript> ().MoveTransition(newCamPoint); transform.eulerAngles = new Vector3(transform.eulerAngles.x, newCamPoint.transform.eulerAngles.y, newCamPoint.transform.eulerAngles.z); Vector3 targetPos = _currentAction.triggerObj.transform.position; targetPos.y = transform.position.y; transform.position = targetPos; }
private IEnumerator CrossStreet(AvailableAction _currentAction) { myRigidbody.velocity = Vector3.zero; GameObject newCamPoint = _currentAction.triggerObj.GetComponent <CornerTrigger> ().SwitchCameraPoint(); myCamera.gameObject.GetComponent <CameraScript> ().MoveTransition(newCamPoint); transform.eulerAngles = new Vector3(transform.eulerAngles.x, newCamPoint.transform.eulerAngles.y, newCamPoint.transform.eulerAngles.z); Vector3 targetVec = _currentAction.triggerObj.transform.position + _currentAction.triggerObj.transform.forward * _currentAction.triggerObj.GetComponent <CornerTrigger>().distanceToCross; targetVec.y = transform.position.y; while (Vector3.Distance(transform.position, targetVec) > 0.5f) { transform.position = Vector3.Lerp(transform.position, targetVec, Time.deltaTime * moveSpeed * 0.5f); if (isBeingApprehended) { yield return(new WaitForSeconds(0.25f)); break; } yield return(null); } if (isBeingApprehended) { newCamPoint = _currentAction.triggerObj.GetComponent <CornerTrigger> ().SwitchCameraPoint(); myCamera.gameObject.GetComponent <CameraScript> ().MoveTransition(newCamPoint); transform.eulerAngles = new Vector3(transform.eulerAngles.x, newCamPoint.transform.eulerAngles.y, newCamPoint.transform.eulerAngles.z); targetVec = _currentAction.triggerObj.transform.position; targetVec.y = transform.position.y; while (Vector3.Distance(transform.position, targetVec) > 0.5f) { transform.position = Vector3.Lerp(transform.position, targetVec, Time.deltaTime * moveSpeed * 0.5f); yield return(null); } yield return(new WaitForSeconds(7.5f)); isBeingApprehended = false; } canMove = true; yield return(null); }
private IEnumerator EnterShop(AvailableAction _currentAction) { Manager_GameTime.Instance.PauseGameTime(true); myRigidbody.velocity = Vector3.zero; currentAvailableActions.Remove(currentAvailableActions.Find(aa => aa._action == PossibleAction.Action_EnterShop)); Vector3 targetVec = _currentAction.triggerObj.transform.position + _currentAction.triggerObj.transform.forward * 3.0f; targetVec.y = transform.position.y; while (Vector3.Distance(transform.position, targetVec) > 0.15f) { transform.position = Vector3.Lerp(transform.position, targetVec, Time.deltaTime * moveSpeed * 0.45f); yield return(null); } _currentAction.triggerObj.GetComponent <Building_Script> ().StartDialogue(portrait, playerName, playerLastName); _currentAction.triggerObj.GetComponent <Building_Script> ().ApplyEventMethods(); currentAvailableActions.Add(new AvailableAction(PossibleAction.Action_ExitShop, KeyCode.S, _currentAction.triggerObj)); }
private IEnumerator ExitShop(AvailableAction _currentAction) { _currentAction.triggerObj.GetComponent <Building_Script> ().RemoveEventMethods(); Manager_GameTime.Instance.PauseGameTime(false); Manager_GameTime.Instance.TimeLeap(1, 20, 0); myRigidbody.velocity = Vector3.zero; currentAvailableActions.Remove(currentAvailableActions.Find(aa => aa._action == PossibleAction.Action_ExitShop)); Vector3 targetVec = _currentAction.triggerObj.transform.position + _currentAction.triggerObj.transform.forward * -0.25f; targetVec.y = transform.position.y; while (Vector3.Distance(transform.position, targetVec) > 0.15f) { transform.position = Vector3.Lerp(transform.position, targetVec, Time.deltaTime * moveSpeed * 0.45f); yield return(null); } CanMove(true); // currentAvailableActions.Add (new AvailableAction (PossibleAction.Action_ExitShop, KeyCode.S, _currentAction.triggerObj)); }
private IEnumerator CrossStreet(AvailableAction _currentAction) { myRigidbody.velocity = Vector3.zero; GameObject newCamPoint = _currentAction.triggerObj.GetComponent<CornerTrigger> ().SwitchCameraPoint (); myCamera.gameObject.GetComponent<CameraScript> ().MoveTransition (newCamPoint); transform.eulerAngles = new Vector3 (transform.eulerAngles.x, newCamPoint.transform.eulerAngles.y, newCamPoint.transform.eulerAngles.z); Vector3 targetVec = _currentAction.triggerObj.transform.position + _currentAction.triggerObj.transform.forward * _currentAction.triggerObj.GetComponent<CornerTrigger>().distanceToCross; targetVec.y = transform.position.y; while(Vector3.Distance(transform.position, targetVec) > 0.5f) { transform.position = Vector3.Lerp(transform.position, targetVec, Time.deltaTime * moveSpeed * 0.5f); if(isBeingApprehended) { yield return new WaitForSeconds(0.25f); break; } yield return null; } if(isBeingApprehended) { newCamPoint = _currentAction.triggerObj.GetComponent<CornerTrigger> ().SwitchCameraPoint (); myCamera.gameObject.GetComponent<CameraScript> ().MoveTransition (newCamPoint); transform.eulerAngles = new Vector3 (transform.eulerAngles.x, newCamPoint.transform.eulerAngles.y, newCamPoint.transform.eulerAngles.z); targetVec = _currentAction.triggerObj.transform.position; targetVec.y = transform.position.y; while(Vector3.Distance(transform.position, targetVec) > 0.5f) { transform.position = Vector3.Lerp(transform.position, targetVec, Time.deltaTime * moveSpeed * 0.5f); yield return null; } yield return new WaitForSeconds(7.5f); isBeingApprehended = false; } canMove = true; yield return null; }
public static List <AvailableAction> BuildAvailableActionsAlwaysStand() { var availableActions = new List <AvailableAction>(); for (int d = 2; d <= 11; d++) { for (int p = 3; p <= 21; p++) { var action = new AvailableAction() { DealerCard = d, PlayerValue = p, PlayerAction = PlayerAction.Stand, Key = Guid.NewGuid() }; availableActions.Add(action); } } return(availableActions); }
private void TurnCorner(AvailableAction _currentAction) { GameObject newCamPoint = _currentAction.triggerObj.GetComponent<CornerTrigger> ().SwitchCameraPoint (); myCamera.gameObject.GetComponent<CameraScript> ().MoveTransition (newCamPoint); transform.eulerAngles = new Vector3 (transform.eulerAngles.x, newCamPoint.transform.eulerAngles.y, newCamPoint.transform.eulerAngles.z); Vector3 targetPos = _currentAction.triggerObj.transform.position; targetPos.y = transform.position.y; transform.position = targetPos; }
private IEnumerator ExitShop(AvailableAction _currentAction) { _currentAction.triggerObj.GetComponent<Building_Script> ().RemoveEventMethods (); Manager_GameTime.Instance.PauseGameTime (false); Manager_GameTime.Instance.TimeLeap (1, 20, 0); myRigidbody.velocity = Vector3.zero; currentAvailableActions.Remove(currentAvailableActions.Find(aa => aa._action == PossibleAction.Action_ExitShop)); Vector3 targetVec = _currentAction.triggerObj.transform.position + _currentAction.triggerObj.transform.forward * -0.25f; targetVec.y = transform.position.y; while(Vector3.Distance(transform.position, targetVec) > 0.15f) { transform.position = Vector3.Lerp(transform.position, targetVec, Time.deltaTime * moveSpeed * 0.45f); yield return null; } CanMove (true); // currentAvailableActions.Add (new AvailableAction (PossibleAction.Action_ExitShop, KeyCode.S, _currentAction.triggerObj)); }
private void Execute(AvailableAction _currentAction) { switch(_currentAction._action) { case PossibleAction.Action_TurnCorner: { if(canMove) TurnCorner(_currentAction); break; } case PossibleAction.Action_EnterShop: { if(canMove) { CanMove(false); CanExecuteAction(false); StartCoroutine(EnterShop (_currentAction)); } break; } case PossibleAction.Action_ExitShop: { if(canExecuteAction) StartCoroutine(ExitShop (_currentAction)); break; } case PossibleAction.Action_CrossStreet: { if(canMove) { if(currentCrosswalk.currentCWState == CrossWalk.CrosswalkState.CWS_Red) { if(onJayWalking != null) onJayWalking(); } canMove = false; StartCoroutine (CrossStreet(_currentAction)); } break; } case PossibleAction.Action_Talk: { Talk(); break; } } }
private IEnumerator EnterShop(AvailableAction _currentAction) { Manager_GameTime.Instance.PauseGameTime (true); myRigidbody.velocity = Vector3.zero; currentAvailableActions.Remove(currentAvailableActions.Find(aa => aa._action == PossibleAction.Action_EnterShop)); Vector3 targetVec = _currentAction.triggerObj.transform.position + _currentAction.triggerObj.transform.forward * 3.0f; targetVec.y = transform.position.y; while(Vector3.Distance(transform.position, targetVec) > 0.15f) { transform.position = Vector3.Lerp(transform.position, targetVec, Time.deltaTime * moveSpeed * 0.45f); yield return null; } _currentAction.triggerObj.GetComponent<Building_Script> ().StartDialogue (portrait, playerName, playerLastName); _currentAction.triggerObj.GetComponent<Building_Script> ().ApplyEventMethods (); currentAvailableActions.Add (new AvailableAction (PossibleAction.Action_ExitShop, KeyCode.S, _currentAction.triggerObj)); }