// Update is called once per frame void Update() { if (GetComponent <Ghost>().spiritState == Ghost.SpiritState.Attack) { time += Time.deltaTime; colStore = spiritView.spiritsInRadius; foreach (Collider2D Spirit in colStore) { if (Spirit.CompareTag("Player")) { if (Spirit.GetComponent <PlayerValuesScript>().behaveState == PlayerValuesScript.PlayerbehavourState.Suspicious) { if (time >= timeBetweenPunches) { audio.PlayOneShot(attack); time = 0.0f; Spirit.gameObject.GetComponent <SpiritHealth>().DecreaseHealth(); } } } if (Spirit.CompareTag("Spirit")) { if (Spirit.GetComponent <Ghost>().spiritState == Ghost.SpiritState.Suspicious) { if (time >= timeBetweenPunches) { time = 0.0f; Spirit.gameObject.GetComponent <SpiritHealth>().DecreaseHealth(); } } } } } }
private void Start() { animRecord = gameObject.GetComponent <AnimationRecorder>(); curBody = Player; curCamera = pCamera; Spirit.GetComponent <BoxCollider>().enabled = false; SwitchToPlayerBody(Player); }
public void SwitchToSpiritForm(GameObject body, GameObject bodyCamera) { Spirit.GetComponent <BoxCollider>().enabled = false; Spirit.transform.position = body.transform.position; sCamera.transform.rotation = bodyCamera.transform.rotation; bodyCamera.SetActive(false); Spirit.SetActive(true); moveSpirit.enabled = true; sCamera.SetActive(true); fade.color = new Color(fade.color.r, fade.color.g, fade.color.b, 1); moveSpirit.vulnrable = true; curSpirit = true; Spirit.GetComponent <BoxCollider>().enabled = true; PlayerMove aiP = body.GetComponent <PlayerMove>(); if (aiP.hasFlashLight) { aiP.flashLightBox.enabled = true; } aiP.enabled = false; if (aiP.eye1 != null) { aiP.eye1.SetActive(true); aiP.eye2.SetActive(true); } StartCoroutine("FadeIn"); if (body == Player) { foreach (AnimationRecorder anim in allRecorders) { if (anim != null) { anim.ShouldRecord = true; anim.shouldPlay = false; anim.StartRecording(); } } timer = 0; StartCoroutine("countTimer"); } else { body.GetComponent <EnemyAI>().enabled = true; body.GetComponent <EnemyAI>().agent.isStopped = false; } }
IEnumerator FadeIn() { yield return(new WaitForSeconds(.01f)); if (fade.color.a > 0) { fade.color = new Color(fade.color.r, fade.color.g, fade.color.b, fade.color.a - .8f * Time.deltaTime); StartCoroutine("FadeIn"); } else { Spirit.GetComponent <BoxCollider>().enabled = true; } }
public void SwitchToPlayerBodyFinal(GameObject bodyToSwitch) { Spirit.GetComponent <BoxCollider>().enabled = false; if (bodyToSwitch == Player) { moveSpirit.speed = 0; sCamera.SetActive(false); moveSpirit.enabled = false; PlayerMove playMov = Player.GetComponent <PlayerMove>(); playMov.enabled = true; playMov.lockMovement = false; playMov.myCamera.SetActive(true); dot.color = Color.white; dot.color = new Color(dot.color.r, dot.color.g, dot.color.b, 0.3f); fade.color = new Color(fade.color.r, fade.color.g, fade.color.b, 1); curSpirit = false; curCamera = pCamera; curBody = Player; foreach (AnimationRecorder anim in allRecorders) { if (anim != null) { anim.ShouldRecord = false; anim.shouldPlay = true; anim.PlayRecording(); } } StopCoroutine("countTimer"); Spirit.GetComponent <BoxCollider>().enabled = false; Spirit.transform.position = Player.transform.position; StartCoroutine("FadeIn"); } else { moveSpirit.speed = 0; sCamera.SetActive(false); moveSpirit.enabled = false; EnemyAI ai = bodyToSwitch.GetComponent <EnemyAI>(); ai.GetPossesed(); curSpirit = false; curCamera = ai.controlledCamera; curBody = bodyToSwitch; dot.color = Color.white; dot.color = new Color(dot.color.r, dot.color.g, dot.color.b, 0.3f); fade.color = new Color(fade.color.r, fade.color.g, fade.color.b, 1); Spirit.GetComponent <BoxCollider>().enabled = false; StartCoroutine("FadeIn"); } }