Exemple #1
0
    public void Collect(GameObject gameObject, AgentType agentType, ChoppedBodyType choppedBodyType)
    {
        if (gameObject == null)
        {
            return;
        }

        gameObject.SendMessage("Deactivate");

        for (int i = 0; i < choppedBodies.Count; ++i)
        {
            if (choppedBodies[i].agentType == agentType)
            {
                ChoppedBodyInfo cbi = choppedBodies[i];
                for (int ii = 0; ii < cbi.data.Count; ++ii)
                {
                    ChoppedBodyData cbd = cbi.data[ii];
                    if (cbd.choppedBodyType == choppedBodyType)
                    {
                        cbd.prefabs.Add(gameObject);
                    }
                }
            }
        }
    }
Exemple #2
0
    public GameObject Get(AgentType agentType, Transform trans, ChoppedBodyType choppedBodyType)
    {
        for (int i = 0; i < choppedBodies.Count; ++i)
        {
            if (choppedBodies[i].agentType == agentType)
            {
                ChoppedBodyInfo cbi = choppedBodies[i];
                for (int ii = 0; ii < cbi.data.Count; ++ii)
                {
                    ChoppedBodyData cbd = cbi.data[ii];
                    if (cbd.choppedBodyType == choppedBodyType)
                    {
                        if (cbd.prefabs.Count == 0)
                        {
                            return(null);
                        }

                        GameObject go = cbd.prefabs[cbd.prefabs.Count - 1];
                        if (cbd.prefabs.Count > 1)
                        {
                            go.SendMessage("Activate", trans);
                            cbd.prefabs.Remove(go);
                        }
                        else if (cbd.prefabs.Count > 0)
                        {
                            // 必须留一个用来Instantiate
                            go = GameObject.Instantiate(go);
                            go.SendMessage("Activate", trans);
                        }
                        return(go);
                    }
                }
            }
        }

        return(null);
    }