void OnEntityKill(WaterPump wPump) { if (wPumpList.Contains(wPump)) { wPumpList.Remove(wPump); } }
void OnEntitySpawned(WaterPump wPump) { if (!wPumpList.Contains(wPump)) { wPumpList.Add(wPump); } }
private void Start() { this.anim = GetComponent <Animator>(); this.anim.SetBool("IsOn", this.isOn); this.WaterPump = FindObjectOfType <WaterPump>(); this.WaterPump.TurnOff(); this.coreTemp = FindObjectOfType <CoreTemp>(); this.coreTemp.StopCooling(); }
private void Start() { this.drainage = FindObjectOfType <Drainage>(); this.controlRodDepth = FindObjectOfType <ControlRodDepth>(); this.controlRodTemp = FindObjectOfType <ControlRodTemperature>(); this.waterPump = FindObjectOfType <WaterPump>(); this.coreTemp = FindObjectOfType <CoreTemp>(); this.energyOutput = FindObjectOfType <EnergyOutput>(); this.sceneChange = FindObjectOfType <SceneChange>(); }
void FixedUpdate() { float moveHorizontal = -Input.GetAxis(HorizontalAxis); float moveVertical = Input.GetAxis(VerticalAxis); Vector3 movement = new Vector3(moveVertical, 0.0F, normalMask?moveHorizontal:-moveHorizontal); if (Input.GetButtonDown(UseButton)) { var playerHit = false; RaycastHit hit; if (Physics.Raycast(transform.position + (Vector3.up * 0.5f), transform.forward, out hit, 0.9f)) { if (hit.transform.gameObject.tag == "Player" && !HasKey) { Debug.Log("Player Hit"); playerHit = true; if (HasKey) { ThrowKey(); } Animator.SetTrigger("Hit"); hit.transform.gameObject.GetComponent <CharacterMovement>().Hit(transform.forward); Invoke("playPunchSound", 0.26f); } } if (!playerHit && Physics.Raycast(transform.position + (Vector3.up * 0.5f), transform.forward, out hit, 0.7f, normalMask?Mask:MirrorMask)) { Debug.Log(hit.transform.gameObject.name); if (hit.transform.gameObject.tag == "Crate" && !HasKey) { isUsingCrate = true; Debug.Log("Crate used"); direction = transform.forward; crate = hit.transform.gameObject.GetComponent <Crate>(); } else if (hit.transform.gameObject.tag == "Key" && !HasKey) { Key key = hit.transform.gameObject.GetComponent <Key>(); if (key.HasAccess(PlayerID)) { HasKey = true; KeyObject = hit.transform.gameObject; KeyObject.SetActive(false); HandHeldKey.SetActive(true); Debug.Log("found Key"); SourceOfAudio.PlayOneShot(KeySound, 1); } } else if (hit.transform.gameObject.tag == "Door") { Debug.Log("Det er en dør"); if (HasKey) { Debug.Log("Du vandt, sejt!"); if (PlayerID == 1) { scoreManager.IncreasePlayer1Score(); } else if (PlayerID == 2) { scoreManager.IncreasePlayer2Score(); } SourceOfAudio.PlayOneShot(DoorSound, 1); levelManager.NextLevel(); } } else if (hit.transform.gameObject.tag == "GateFence" && !HasKey) { Debug.Log("Der er en låge"); Animator.SetBool("OpenDoor", true); hit.transform.gameObject.GetComponent <Animator>().SetBool("Open", true); } else if (hit.transform.gameObject.CompareTag("WaterPump")) { WaterPump wp = hit.transform.gameObject.GetComponent <WaterPump>(); Animator.SetTrigger("TurnPump"); if (wp != null) { wp.Interact(); } else { Debug.LogWarning("mangler WaterPump component!"); } } else if (hit.transform.gameObject.tag == "GateFenceMirror" && !HasKey) { Debug.Log("Der er en mirror portal"); Animator.SetBool("OpenDoor", true); //mirror player with shadow if (normalMask) { gameObject.layer = MirrorLayer; Body.layer = MirrorLayer; MirrorBody.layer = NormalLayer; } else { gameObject.layer = NormalLayer; Body.layer = NormalLayer; MirrorBody.layer = MirrorLayer; } normalMask = !normalMask; } else { Taunt(); } } else if (HasKey) { ThrowKey(); } else if (!playerHit) { Taunt(); } } else if (Input.GetButtonUp(UseButton)) { isUsingCrate = false; } if (isUsingCrate) { var diff = 0f; if (Mathf.Abs(direction.x) > Mathf.Abs(direction.z)) { movement = new Vector3(movement.x, 0f, 0f); diff = movement.x; } else { movement = new Vector3(0f, 0f, movement.z); diff = movement.z; } Speed = diff / 2; crate.Move(movement * (MovementSpeed / 2)); CharacterControlerVariable.Move(movement * Time.deltaTime * (MovementSpeed / 2)); Animator.SetBool("Pushing", true); } else { Speed = movement.magnitude; //CharacterControlerVariable.Move(movement * Time.deltaTime*MovementSpeed); if (movement != Vector3.zero) { transform.rotation = Quaternion.LookRotation(movement); } CharacterControlerVariable.Move(movement * Time.deltaTime * MovementSpeed); Animator.SetBool("Pushing", false); } //Check if we touch the ground. Vector3 transformDown = transform.TransformDirection(Vector3.down); if (!Physics.Raycast(transform.position, transformDown, 0.05f)) { //print("We are falling"); Vector3 fall = new Vector3(0.0f, -0.1f, 0.0f); CharacterControlerVariable.Move(fall); } if (transform.position.y < -4f) { ResetCharacterOnLevelLoad(); } }