Exemplo n.º 1
0
    /// <summary>
    /// Instantiate an Aliment as GameObject
    /// </summary>
    public static GameObject InstantiateAliment(string _nameAliment, AlimentState _state)
    {
        if (mapAlimentObject.ContainsKey(_nameAliment))
        {
            // Create go

            Object     toInstantiate = null;
            GameObject alimentGO     = null;

            foreach (AlimentObject.InfoState infoState in mapAlimentObject[_nameAliment].listState)
            {
                if (infoState.state == _state)
                {
                    toInstantiate = infoState.prefab;
                }
            }

            if (toInstantiate != null)
            {
                alimentGO = Instantiate(toInstantiate) as GameObject;
            }

            // Set Aliment
            Aliment aliment = alimentGO.AddComponent <Aliment>();
            aliment.Init(mapAlimentObject[_nameAliment], _state);

            return(alimentGO);
        }

        return(null);
    }
Exemplo n.º 2
0
    public static GameObject InstantiateAliment(AlimentObject _alimentObject, AlimentState _state)
    {
        if (_alimentObject != null)
        {
            // Create go

            Object     toInstantiate = null;
            GameObject alimentGO     = null;

            foreach (AlimentObject.InfoState infoState in _alimentObject.listState)
            {
                if (infoState.state == _state)
                {
                    toInstantiate = infoState.prefab;
                }
            }

            if (toInstantiate != null)
            {
                alimentGO = Instantiate(toInstantiate) as GameObject;
            }
            else
            {
                Debug.Log("_alimentObject: " + _alimentObject.name + " state " + _state);
            }

            // Set Aliment
            Aliment aliment = alimentGO.AddComponent <Aliment>();
            aliment.Init(_alimentObject, _state);

            return(alimentGO);
        }

        //Debug.Log("Aliment " + _nameAliment + " doesn't exist !");
        return(null);
    }