Beispiel #1
0
    protected UIAgent CreateDynamicAgent <T>(string nameFilter)
    {
        UIAgent result    = null;
        UIAgent candidate = RetrieveDynamicAgentPrefab <T>(nameFilter);

        if (candidate != null)
        {
            result = Instantiate(candidate.gameObject).GetComponent <UIAgent>();
        }

        return(result);
    }
Beispiel #2
0
    protected void RemoveDynamicAgent(UIAgent agent, bool instant)
    {
        if (instant)
        {
            Destroy(agent.gameObject);
        }
        else
        {
            agent.State = UIState.DISABLING;
        }

        dynamicAgents.Remove(agent);
    }
Beispiel #3
0
    protected UIAgent RetrieveDynamicAgentPrefab <T>(string nameFilter)
    {
        UIAgent prefab = null;

        for (int i = 0; i < dynamicAgentPrefabs.Length; i++)
        {
            UIAgent candidate = dynamicAgentPrefabs[i].GetComponent <UIAgent>();
            bool    typeMatch = candidate is T;
            bool    nameMatch = candidate.name.Contains(nameFilter);

            if (typeMatch && nameMatch)
            {
                prefab = candidate;
                break;
            }
        }

        return(prefab);
    }
Beispiel #4
0
    protected virtual void SetState(UIState state)
    {
        this.state = state;
        if (!changeStateCausedByUpdate)
        {
            allAgents.ForEach(x => { if (x.State != state && !x.parentStateIndependent)
                                     {
                                         x.State = state;
                                     }
                              });
            for (int i = 0; i < remoteAgents.Length; i++)
            {
                UIAgent x = remoteAgents[i];
                if (x.State != state)
                {
                    x.State = state;
                }
            }
        }

        gameObject.SetActive(state != UIState.DISABLED);
    }