public static void CheckForExit(PossessableBase body) { if (Inst) { Inst.CheckBody(body); } }
public void CheckBody(PossessableBase body) { if (body.Possessor && body.Possessor.realBody == body && allTouching.Any((c) => c.GetComponentInParent <PossessableBase>() == body)) { SceneManager.LoadScene(nextScene); } }
void OnTriggerEnter2D(Collider2D other) { PossessableBase body = other.GetComponentInParent <PossessableBase>(); if (body is HamsterBody) { GameOverManager.GameOver(killMessage); } }
void OnTriggerEnter2D(Collider2D other) { PossessableBase body = other.GetComponentInParent <PossessableBase>(); if (body.Possessor || body is HamsterBody) { GameOverManager.GameOver("SPOTTED!"); } }
void OnTriggerEnter2D(Collider2D other) { allTouching.Add(other); PossessableBase body = other.GetComponentInParent <PossessableBase>(); if (body) { CheckBody(body); } }
// Update is called once per frame void Update() { if (transferDisplayCoroutine == null) { transferParticles.transform.position = currentBody.transform.position; } if (stopUpdates) { return; } if (currentBody == realBody) { Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); PossessableBase target = PossessableBase.allActive .Where(p => p.CanBePossessed(this)) .MinBy(clickRadius * clickRadius, (k) => ((Vector2)k.transform.position - mousePos).sqrMagnitude); if (target) { if (target != lastTargetBody) { possessHighlight.Pause(); } possessHighlight.transform.position = target.transform.position; if (!possessHighlight.isPlaying) { possessHighlight.Play(); } if (Input.GetButtonDown("Possess")) { Possess(target); } } else { possessHighlight.Stop(); } lastTargetBody = target; } else { if (Input.GetButtonDown("Possess")) { Possess(realBody); } } currentBody.PossessedUpdate(); }
public void Possess(PossessableBase body) { if (transferDisplayCoroutine != null) { StopCoroutine(transferDisplayCoroutine); transferDisplayCoroutine = null; } if (currentBody) { currentBody.DoUnpossess(); stopUpdates = true; audioSource.PlayOneShot(transferSE); transferDisplayCoroutine = StartCoroutine( ShowTransfer(currentBody.transform, body.transform, transferTime, transferAtEndTime)); } else { body.DoPossess(this); } currentBody = body; possessHighlight.Stop(); }