Exemplo n.º 1
0
    private void CheckIfCannonIsInReach(GameObject doctorContainer)
    {
        float      shortestDistance = int.MaxValue;
        GameObject doctor           = doctorContainer.transform.Find("Player").gameObject;

        foreach (GameObject cannon in cannonList)
        {
            float cannonDistance = Vector3.Distance(cannon.transform.position, doctor.transform.position);

            if (!(cannonDistance < shortestDistance))
            {
                continue;
            }

            shortestDistance = cannonDistance;
            selectedCannon   = cannon;
        }

        if (Vector3.Distance(selectedCannon.transform.position, doctor.transform.position) < 3)
        {
            FireCannonball cannonball = selectedCannon.GetComponent <FireCannonball>();
            cannonball.SetDoctor(doctorContainer);
            cannonball.attachDoctor();
            cannonball.animatorSettings();
        }
    }
Exemplo n.º 2
0
    public void spawnC(GameObject doctor)
    {
        sharedCannon.transform.position = doctor.transform.Find("Player").gameObject.GetComponent <NavMeshAgent>().transform.position;

        FireCannonball fireCannonball = sharedCannon.GetComponent <FireCannonball>();


        fireCannonball.SetDoctor(doctor);
        fireCannonball.resetCannonball();
        fireCannonball.attachDoctor();
        fireCannonball.animatorSettings();

        //reduce charge
    }