Пример #1
0
 public static void CheckForExit(PossessableBase body)
 {
     if (Inst)
     {
         Inst.CheckBody(body);
     }
 }
Пример #2
0
 public void CheckBody(PossessableBase body)
 {
     if (body.Possessor && body.Possessor.realBody == body &&
         allTouching.Any((c) => c.GetComponentInParent <PossessableBase>() == body))
     {
         SceneManager.LoadScene(nextScene);
     }
 }
Пример #3
0
    void OnTriggerEnter2D(Collider2D other)
    {
        PossessableBase body = other.GetComponentInParent <PossessableBase>();

        if (body is HamsterBody)
        {
            GameOverManager.GameOver(killMessage);
        }
    }
Пример #4
0
    void OnTriggerEnter2D(Collider2D other)
    {
        PossessableBase body = other.GetComponentInParent <PossessableBase>();

        if (body.Possessor || body is HamsterBody)
        {
            GameOverManager.GameOver("SPOTTED!");
        }
    }
Пример #5
0
    void OnTriggerEnter2D(Collider2D other)
    {
        allTouching.Add(other);
        PossessableBase body = other.GetComponentInParent <PossessableBase>();

        if (body)
        {
            CheckBody(body);
        }
    }
Пример #6
0
    // 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();
    }
Пример #7
0
    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();
    }