Esempio n. 1
0
    public void enableUnit(GameObject unit)
    {
        //enable all the components
        unit.GetComponent <NavMeshAgent>().enabled = true;
        unit.GetComponent <Collider>().enabled     = true;
        unit.GetComponent <AudioSource>().Play();
        if (inspector.setScriptsFrom(unit))
        {
            inspector.setEnable(true);
        }
        if (inspector.getScriptType() == "AgentScript")
        {
            inspector.setInitAgent(brain);
        }
        if (unit.GetComponent <Archer>())
        {
            unit.GetComponent <Archer>().enabled = true;
        }

        unit.transform.Find("Health").gameObject.SetActive(true);

        //show particles
        foreach (ParticleSystem particles in unit.GetComponentsInChildren <ParticleSystem>())
        {
            particles.gameObject.SetActive(true);
        }

        //start the animators
        foreach (Animator animator in unit.GetComponentsInChildren <Animator>())
        {
            animator.SetBool("Start", true);
        }
    }