// Update is called once per frame void Update() { if (solvedActions_1) { // Sound // Set First Actions True EvilAction huehue = _gameState.CurrentPerson.EvilAction[0]; _gameState.CurrentPerson.SolvedActions.Add(huehue); _gameState.CurrentPerson.EvilAction.Remove(huehue); solvedActions_1 = false; } if (solvedActions_2) { // Grap // Set First Actions True EvilAction huehue = _gameState.CurrentPerson.EvilAction[1]; _gameState.CurrentPerson.SolvedActions.Add(huehue); _gameState.CurrentPerson.EvilAction.Remove(huehue); solvedActions_2 = false; } if (solvedActions_3) { // Trigger // Set First Actions True EvilAction huehue = _gameState.CurrentPerson.EvilAction[2]; _gameState.CurrentPerson.SolvedActions.Add(huehue); _gameState.CurrentPerson.EvilAction.Remove(huehue); solvedActions_3 = false; } }
/// <summary> /// Add a scratch event to the game if it is defined in the gameData /// </summary> /// <param name="scratchEvilAction"></param> public void AddScratchAction(EvilAction scratchEvilAction) { GameObject tempGo = new GameObject(); ObjectTrigger objTrigger = tempGo.AddComponent <ObjectTrigger>(); objTrigger.actionTrigger = scratchEvilAction; scratchActions.Add(objTrigger); }
/// <summary> /// Solve an action for the current level /// </summary> /// <param name="action"></param> /// <returns></returns> public bool SolveAction(EvilAction action) { if (CurrentPerson.EvilAction.Contains(action)) { CurrentPerson.SolvedActions.Add(action); CurrentPerson.EvilAction.Remove(action); return(true); } return(false); }
/// <summary> /// Add a voice event to the game if it is defined in the gameData /// </summary> /// <param name="voiceEvilAction"></param> public void AddVoiceAction(EvilAction voiceEvilAction) { GameObject tempGo = new GameObject(); ObjectTrigger objTrigger = tempGo.AddComponent <ObjectTrigger>(); objTrigger.actionTrigger = voiceEvilAction; objTrigger.holdingTimeThreshold = .1f; objTrigger.triggerCompleteTime = 2f; objTrigger.isSolved = false; voiceActionObjs.Add(objTrigger); }
/// <summary> /// Complete a solved interaction whith delay /// </summary> /// <param name="action"></param> /// <returns></returns> IEnumerator CompleteActionWithDelay(EvilAction action) { if (GameState.instance.SolveAction(action)) { Debug.Log("ACTION SOLVED: " + action.ActionType + " <> " + GameState.instance.CurrentPerson.EvilAction.Count + " left!"); if (GameState.instance.CurrentPerson.EvilAction.Count <= 0) { yield return(new WaitForSeconds(3f)); ScreenViewHandler.instance.FinalizeLevel(true); } } }
/// <summary> /// Initialize tasks from the json data /// </summary> void InitializeObjectTriggersOnRoomObjects() { var evilActions = GameState.instance.CurrentPerson.EvilAction; GameObject[] interactableGameObjects = GameObject.FindGameObjectsWithTag("EvilActionObject"); if (interactableGameObjects != null) { foreach (GameObject interactableGameObject in interactableGameObjects) { // every interactableGameObject has an ObjectTrigger script attached to it ObjectTrigger objectTrigger = interactableGameObject.GetComponent <ObjectTrigger>(); if (objectTrigger != null) { EvilAction matchingIdentifierEvilAction = evilActions.FirstOrDefault(b => b.Identifier.Equals(objectTrigger.EvilActionIdentifier)); if (matchingIdentifierEvilAction != null) { objectTrigger.actionTrigger = matchingIdentifierEvilAction; } } } } }
/// <summary> /// Callback for solved Interactions /// </summary> /// <param name="action"></param> void CompleteAction(EvilAction action) { StartCoroutine(CompleteActionWithDelay(action)); }