Ejemplo n.º 1
0
    protected virtual void UpdateMagnet()
    {
        bool red  = false;
        bool blue = false;

        BasePlayerShip r = FindObjectOfType <AttackShip>();
        BasePlayerShip b = FindObjectOfType <DefenseShip>();

        if (Vector3.Distance(r.transform.position, transform.position) <= r.GetMagnetRange())
        {
            red = true;
        }
        if (Vector3.Distance(b.transform.position, transform.position) <= b.GetMagnetRange())
        {
            blue = true;
        }

        if (red && blue)
        {
            Vector3 playerPos = FindClosestPlayer();

            UpdatePosition(playerPos, 1);
        }
        else if (red)
        {
            UpdatePosition(r.transform.position, 1);
        }
        else if (blue)
        {
            UpdatePosition(b.transform.position, 1);
        }
    }
Ejemplo n.º 2
0
    private void OnTriggerEnter(Collider other)
    {
        //Can only be collected by the player ships
        BasePlayerShip p = other.GetComponent <BasePlayerShip>();

        if (p == null)
        {
            return;
        }

        OnCollect();
    }
Ejemplo n.º 3
0
    //Called when the player touches the coin
    private void OnCollect(BasePlayerShip p)
    {
        GetComponent <Magnet>().enabled = false;

        GetComponent <BoxCollider>().enabled = false;

        //Stop all coroutines: the duration coroutine
        StopAllCoroutines();

        GetComponent <Animator>().Play("Coin Collect");
        p.ActivateBarrier();
        //FindObjectOfType<ScoreManager>().IncreaseCoin();
    }
Ejemplo n.º 4
0
    private void OnTriggerEnter(Collider other)
    {
        //Can only be collected by the player ships
        BasePlayerShip p = other.GetComponent <BasePlayerShip>();

        if (p == null)
        {
            return;
        }

        //If the player already has a barrier, they can't pick this up
        if (p.IsBarrierActive())
        {
            return;
        }

        OnCollect(p);
    }