Exemplo n.º 1
0
    public void SetupAibehave(GameObject aiPrefab)
    {
        if (aiPrefab == null)
        {
            return;
        }

        if (m_behave != null)
        {
            Destroy(m_behave.gameObject);
            m_behave = null;
        }

        GameObject go = Instantiate(aiPrefab, transform.position, transform.rotation) as GameObject;

        if (go == null)
        {
            Debug.LogError("Instantiate ai prefab failed.");
            return;
        }

        go.transform.parent = transform;

        m_behave = go.GetComponent <AiBehave>();

        if (m_behave == null)
        {
            Debug.LogError("cant find AiBehaveTree.");
            return;
        }

        AiBehaveSingle bs = m_behave as AiBehaveSingle;

        if (bs != null)
        {
            bs.RegisterAiObject(this);
        }
        else
        {
            Debug.LogWarning("ai [" + m_behave + "] is not a AiBehaveSingle");
        }
    }
Exemplo n.º 2
0
    new public void OnEnable()
    {
        base.OnEnable();

        single = script as AiBehaveSingle;
    }