protected override void Update() { //DEBUG KEY: Simulates keyDoor chuck if (Input.GetKeyDown(KeyCode.X)) resetItem(); // Gets all the needed network components once only if (!networkInitialized) { network = GameObject.FindWithTag("Player").GetComponent<spt_NetworkPuzzleLogic>(); if (network != null) { for (int i = 0; i < network.PuzzleStates.Count; i++) { if (network.PuzzleStates[i].name == "keyDoorThrowable") doorThrownIndex = i; if (network.PuzzleStates[i].name == "keyDoorThrowableNoise") doorThrownNoiseIndex = i; } networkInitialized = true; } } //Check to see if audio needs to be played else { if (network.PuzzleStates[doorThrownNoiseIndex].state == true) { //play some audio (make sure it's a Oneshot) aSource.PlayOneShot(keyDoorThrown); Debug.LogWarning("Door Throw Sound"); network.Cmd_UpdatePuzzleLogic("keyDoorThrowableNoise", false, "mdl_cabinetDoor"); } } }
// Update is called once per frame void Update() { if (network == null) { GameObject player = GameObject.FindGameObjectWithTag("Player"); if (player != null) network = player.GetComponent<spt_NetworkPuzzleLogic>(); } else { if (network.loaded && network.loaded == true) { if (!indexInitialized) { for (int index = 0; index < network.PuzzleStates.Count; ++index) { if (network.PuzzleStates[index].itemName == gameObject.name) { i = index; indexInitialized = true; break; } } } else { if (network.PuzzleStates[i].state == true && triggered == false) { triggered = true; angerObject.toggleVisibility(); } } } } }
// Update is called once per frame void Update() { if (network == null) { GameObject player = GameObject.FindGameObjectWithTag("Player"); if (player == null) return; network = GameObject.FindGameObjectWithTag("Player").GetComponent<spt_NetworkPuzzleLogic>(); for (int i = 0; i < network.PuzzleStates.Count; i++) { /*if (network.PuzzleStates[i].name == "leverAPressed") playerATNT = i; if (network.PuzzleStates[i].name == "leverBPressed") playerBTNT = i;*/ if (network.PuzzleStates[i].name == "explosionTime") explosionTimeIndex = i; } } else { //if ((network.PuzzleStates[playerATNT].state == true) && (network.PuzzleStates[playerBTNT].state == true)) if (network.PuzzleStates[explosionTimeIndex].state == true) { if (!once) { GameObject go = (GameObject)Instantiate(Resources.Load("Explosion"), GameObject.Find("mdl_TNTLeverA").transform.position, Quaternion.Euler(0, 0, 0)); GameObject go2 = (GameObject)Instantiate(Resources.Load("Explosion"), GameObject.Find("mdl_TNTLeverB").transform.position, Quaternion.Euler(0, 0, 0)); once = true; } } } }
// Update is called once per frame void Update() { if (!networkInitialized) { network = GameObject.FindWithTag("Player").GetComponent<spt_NetworkPuzzleLogic>(); if (network != null) { for (int i = 0; i < network.PuzzleStates.Count; i++) { if (network.PuzzleStates[i].name == "isBucketOnShelf") bucketFlingIndex = i; if (network.PuzzleStates[i].name == "playBucketCollisionNoise") bucketCollisionIndex = i; } networkInitialized = true; } } }
// Update is called once per frame void Update() { if (!networkInitialized) { network = GameObject.FindWithTag("Player").GetComponent<spt_NetworkPuzzleLogic>(); if (network != null) { for (int i = 0; i < network.PuzzleStates.Count; i++) { if (network.PuzzleStates[i].name == "keyDoorThrowable") doorThrownIndex = i; if (network.PuzzleStates[i].name == "keyDoorThrowableNoise") doorThrownNoiseIndex = i; } networkInitialized = true; Invoke("enableCollision", 5); } } }
protected override void Update() { base.Update(); if (moveOnLocalZ == true) transform.Translate(new Vector3(0, 0, spt_playerControls.leftThumb("Horizontal")) * Time.deltaTime * moveSpeed * HaydenIdea); //DEBUG KEY: Simulates bucket chuck if (Input.GetKeyDown(KeyCode.X)) resetItem(); // Gets all the needed network components once only if (!networkInitialized) { network = GameObject.FindWithTag("Player").GetComponent<spt_NetworkPuzzleLogic>(); if (network != null) { for (int i = 0; i < network.PuzzleStates.Count; i++) { if (network.PuzzleStates[i].name == "isBucketOnShelf") bucketFlingIndex = i; if (network.PuzzleStates[i].name == "playBucketCollisionNoise") bucketCollisionIndex = i; } networkInitialized = true; //network.updatePuzzleState("isBucketOnShelf", true, "mdl_bucket"); local_bucketOnShelf = true; spt_WorldState.worldStateChanged = true; } } //Check to see if audio needs to be played else { if (network.PuzzleStates[bucketCollisionIndex].state == true) { //play some audio (make sure it's a Oneshot) aSource.PlayOneShot(throwSound); Debug.LogWarning("Bucket Throw Sound"); //network.Cmd_UpdatePuzzleLogic("playBucketCollisionNoise", false, "mdl_bucket"); spt_bucketCollision.local_bucketCollision = false; spt_WorldState.worldStateChanged = true; } } }
// Update is called once per frame void Update() { if (network == null) { network = GameObject.FindGameObjectWithTag("Player").GetComponent<spt_NetworkPuzzleLogic>(); for (int i = 0; i < network.PuzzleStates.Count; i++) { if (network.PuzzleStates[i].name == "isLaserOn") puzzleStateIndex = i; } } else { if (network.PuzzleStates[puzzleStateIndex].state == true) { gameObject.GetComponent<ParticleSystem>().enableEmission = true; } else gameObject.GetComponent<ParticleSystem>().enableEmission = false; } }
// Update is called once per frame void Update() { if (network == null || monster == null) { network = GameObject.FindGameObjectWithTag("Player").GetComponent<spt_NetworkPuzzleLogic>(); monster = GameObject.FindObjectOfType<spt_monsterMotivation>(); } else { if (network.loaded && network.loaded == true) { if (!indexInitialized) { for (int index = 0; index < network.PuzzleStates.Count; ++index) { if (network.PuzzleStates[index].itemName == gameObject.name) { i = index; indexInitialized = true; break; } } } else { if (network.PuzzleStates[i].state == true && triggered == false) { triggered = true; gameObject.GetComponentInChildren<ParticleSystem>().enableEmission = true; monster.updateAnger(monster.lowerThreshold - monster.angerLevel, gameObject.transform); monster.angerUpdateDisabled = true; Invoke("enableAnger", 1); } } } } }
void Update() { if (network == null) network = GameObject.FindGameObjectWithTag("Player").GetComponent<spt_NetworkPuzzleLogic>(); if (isServer) { if (soundPlayed) { ambSoundInd = -1; wngSoundInd = -1; } } if (ambSoundInd != -1 && !once) playAmbientNoise(); else if (wngSoundInd != -1 && !once) playWarningNoise(); else if (warningVibration && !once) playWarningVibration(); if (soundPlayed) soundPlayed = false; }
// Update is called once per frame void Update() { animationScript = GameObject.FindObjectOfType(typeof(spt_monsterAnimations)) as spt_monsterAnimations; if (animIndex != lastAnimIndex) { animationScript.animator.SetInteger("animation", animIndex); lastAnimIndex = animIndex; } if (!isServer) return; if (!navMeshInitialized || !waypointInitialized) { //Gets the waypoint graph from another script, then sets the first waypoint to the center of the room. if (garageScript != null) waypointGraph = garageScript.getWaypointGraph(); else if (rangerOutpostScript != null) waypointGraph = rangerOutpostScript.getWaypointGraph(); else waypointGraph = opticsLabScript.getWaypointGraph(); agent = GetComponent<NavMeshAgent>(); agent.enabled = true; agent.SetDestination(waypoints[0].position); currentWaypoint = 0; if (agent != null) navMeshInitialized = true; if (waypointGraph != null) waypointInitialized = true; } networkScript = GameObject.FindGameObjectWithTag("Player").GetComponent<spt_NetworkPuzzleLogic>(); if (monsterPuzzleCompletionIndex == -1) { for (int i = 0; i < networkScript.PuzzleStates.Count; i++) { if (networkScript.PuzzleStates[i].name == "puzzleCompletionMonster" ) { monsterPuzzleCompletionIndex = i; } } } //Either Attack or Drag. if (agent.remainingDistance <= 5 && agent.remainingDistance > 2 && currentWaypoint == 999) { animIndex = 1; if (opticsLabScript != null && monsterPuzzleCompletionIndex != -1 && networkScript.PuzzleStates[monsterPuzzleCompletionIndex].state == true) { animIndex = 2; networkScript.updatePuzzleState("explosionTime", true, "MonsterStandin"); } //animationScript.animator.SetInteger("animation", 1); } // If the monster is attacking, or the players have just won... else if (agent.remainingDistance <= 2 && currentWaypoint == 999 && currentWaypoint != 888) { // If loss needs to happen if (networkScript.PuzzleStates[monsterPuzzleCompletionIndex].state == false) { Debug.LogWarning("attempting to alter playerLoss in puzzleStates..."); networkScript.updatePuzzleState("playerLoss", true, "MonsterStandin"); pLoss = true; } // If win needs to happen else { Debug.LogWarning("attempting to alter puzzleCompletion in puzzleStates..."); networkScript.updatePuzzleState("puzzleCompletion", true, networkScript.PuzzleStates[0].itemName); } } // If the monster is interacting with an item... else if (agent.remainingDistance <= 2 && currentWaypoint == 888) { if (!disengageActivated) { animIndex = 3; Invoke("disengageInteraction", 1.5f); disengageActivated = true; } //animationScript = GameObject.FindObjectOfType(typeof(spt_monsterAnimations)) as spt_monsterAnimations; //interactionScript = GameObject.FindObjectOfType(typeof(spt_monsterInteraction)) as spt_monsterInteraction; //animationScript.disengageInteraction(); //interactionScript.interactWithObject(interactionScript.getInteractionName(), interactionScript.getInteractionItemName()); } else if (agent.remainingDistance <= 2 && currentWaypoint != 999 && currentWaypoint != 888 && currentWaypoint != 777) chooseDestination(); }
// Update is called once per frame void Update() { if (network == null) { network = GameObject.FindGameObjectWithTag("Player").GetComponent<spt_NetworkPuzzleLogic>(); if (network != null) { indecies = new int[network.PuzzleStates.Count]; weights = new double[network.PuzzleStates.Count]; //network.Cmd_UpdatePuzzleLogic("extCordPlugged", true, "mdl_extCord"); } } else { //network = GameObject.FindObjectOfType(typeof(spt_NetworkPuzzleLogic)) as spt_NetworkPuzzleLogic; //Debug.Log(network.loaded); if (loadedTheNetwork == false) { // Iterates through the puzzle logic communicator, gets all necessary data for item interaction (populates the above arrays) int j = 0; for (int i = 0; i < network.PuzzleStates.Count; i++) { if (network.PuzzleStates[i].isMonsterInteractable) { indecies[j] = i; weights[j] = 0.5; j++; } } InvokeRepeating("updateTime", 1, 1); loadedTheNetwork = true; } else if (loadedTheNetwork == true) { // If the monster is not in a downtime period... if ((currentTime - lastInteractionTime) > interactionDowntime) { // Cycle through the possible interactable objects. for (int i = 0; i < indecies.Length; i++) { // If the monster is within interaction range... if (Vector3.Distance(new Vector3(GameObject.Find(network.PuzzleStates[indecies[i]].itemName).transform.position.x, 1, GameObject.Find(network.PuzzleStates[indecies[i]].itemName).transform.position.z), gameObject.transform.position) < 2 && checkIfInteractableYet(network.PuzzleStates[indecies[i]].itemName)) { // Perform interaction some of the time, dependent on a random number. float decision = Random.Range(0, 1); if (decision < weights[i]) { animationScript = GameObject.FindObjectOfType(typeof(spt_monsterAnimations)) as spt_monsterAnimations; interactionName = network.PuzzleStates[indecies[i]].name; interactionItemName = network.PuzzleStates[indecies[i]].itemName; Debug.LogWarning("Interacting with: " + network.PuzzleStates[indecies[i]].itemName); animationScript.interactWithObject(interactionItemName); //interactWithObject(network.PuzzleStates[indecies[i]].name, network.PuzzleStates[indecies[i]].itemName); } } } } } } }