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 void OnReceivePoolID(string _alimentName, AlimentState _alimentState, int _count, int[] _poolableIDArray)
    {
        //Debug.Log("i receive a pool : " + _alimentName + " / " + _alimentState + " / count : " + _count  + " nb1 ID = " + _poolableIDArray[0]);
        List <int> _poolableID = (_poolableIDArray).ToList();
        KeyValuePair <string, AlimentState> key = new KeyValuePair <string, AlimentState>(_alimentName, _alimentState);

        poolReceived.Add(key, _poolableID);
    }
Exemplo n.º 3
0
 public void Init(AlimentObject _alimentObject, AlimentState _state = AlimentState.None)
 {
     alimentName      = _alimentObject.name;
     alimentType      = _alimentObject.type;
     nutriments       = _alimentObject.nutriments;
     alimentState     = _state;
     alimentStepState = AlimentStepState.Dirty;
     expiryState      = ExpiryState.Fresh;
     t_expiry         = 9999f;
 }
Exemplo n.º 4
0
    private void FinishActionOnline(string _nameAliment, AlimentState _alimentState, int _timeInSecond, bool instantiateViewID, int _objectWasteViewID, int _objectTreatedViewID)
    {
        Aliment aliment = grabableReceived.GetComponent <Aliment>();

        aliment.alimentName  = _nameAliment;
        aliment.alimentState = _alimentState;

        TreatObject(aliment, instantiateViewID);

        ObjectWaste.GetComponent <PhotonView>().ViewID   = _objectWasteViewID;
        ObjectTreated.GetComponent <PhotonView>().ViewID = _objectTreatedViewID;
        currentStartAction = null;
    }
Exemplo n.º 5
0
    public void DisplayChoiceMenu(ColdRoom_Button _button)
    {
        AlimentState alimentState = buttons[_button].Value;

        if (alimentState == AlimentState.Box || alimentState == AlimentState.Stack)
        {
            buttonTakeOne.interactable = true;
            buttonTakeAll.interactable = true;
        }
        else
        {
            buttonTakeOne.interactable = true;
            buttonTakeAll.interactable = false;
        }
    }
Exemplo n.º 6
0
    private void FinishActionOnline(string _nameAliment, AlimentState _alimentState, int _timeInSecond, bool instantiateViewID, int _objectEmptyViewID, int _objectStackViewID)
    {
        Aliment aliment = grabableReceived.GetComponent <Aliment>();

        aliment.alimentName  = _nameAliment;
        aliment.alimentState = _alimentState;

        UnpackObject(aliment, instantiateViewID);
        smokeParticleSystem.gameObject.SetActive(false);
        endParticleSystem.Emit(50);

        ObjectEmpty.GetComponent <PhotonView>().ViewID = _objectEmptyViewID;
        ObjectStack.GetComponent <PhotonView>().ViewID = _objectStackViewID;
        currentStartAction = null;
    }
Exemplo n.º 7
0
    private void CreatePool(AlimentObject aliment, AlimentState _state)
    {
        //create pool
        GameObject go = new GameObject("Pool :" + aliment.name + " " + _state.ToString());

        go.transform.parent = transform;
        Pool newPool = go.AddComponent <Pool>();

        KeyValuePair <string, AlimentState> key = new KeyValuePair <string, AlimentState>(aliment.name, _state); // Create a new key with the NAME and the STATE of the current aliment

        GameObject tmpAliment = FoodDatabase.InstantiateAliment(aliment, _state);

        newPool.Init(tmpAliment, DefaultSizePool);

        pools[key] = newPool;
    }
Exemplo n.º 8
0
    public void GetObjectInColdRoom(string _alimentName, AlimentState _alimentState, int alimentViewID, int actorNumber, bool _Remove = false)
    {
        PlayerController ownerPlayer = InGamePhotonManager.Instance.PlayersConnected[actorNumber];

        KeyValuePair <string, AlimentState> keyFood;

        keyFood = new KeyValuePair <string, AlimentState>(_alimentName, _alimentState);
        Poolable foodToGet = null;

        if (_Remove == false)
        {
            if (keyFood.Value != AlimentState.Box && keyFood.Value != AlimentState.Stack)
            {
                foodToGet = PoolManager.Instance.Get(keyFood, alimentViewID);
                limitedFoodsStocked[keyFood] -= 1;
                if (limitedFoodsStocked[keyFood] == 0)
                {
                    limitedFoodsStocked.Remove(keyFood);
                    ui.RemoveButton(keyFood);
                }
            }
            else
            {
                keyFood   = new KeyValuePair <string, AlimentState>(_alimentName, AlimentState.InContent);
                foodToGet = PoolManager.Instance.Get(keyFood, alimentViewID);
            }
        }
        else
        {
            foodToGet = PoolManager.Instance.Get(keyFood, alimentViewID);
            foodsStocked.Remove(keyFood);
            ui.RemoveButton(keyFood);
        }

        if (foodToGet != null)
        {
            GrabableObject toGrab = foodToGet.GetComponent <GrabableObject>();
            toGrab.Init();
            toGrab.AllowGrab(true);
            ownerPlayer.pInteract.GrabObject(toGrab, false);
        }
    }
Exemplo n.º 9
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);
    }
Exemplo n.º 10
0
    void InstantiateBox(string _alimentName, AlimentState _alimentState, int posFree, int finalPos, int viewID)
    {
        //Debug.Log("Receive RPC InstantiateBox :" + _alimentName + " AlimentState:" + _alimentState + " viewID:" + viewID);
        KeyValuePair <string, AlimentState> key = new KeyValuePair <string, AlimentState>(_alimentName, _alimentState);

        Poolable           foodToInstantiate = PoolManager.Instance.Get(key, viewID);
        BoxDatasController box = foodToInstantiate.GetComponent <BoxDatasController>();

        foodToInstantiate.transform.position = PosInstantiation[posFree].position;
        foodToInstantiate.transform.rotation = PosInstantiation[posFree].rotation;

        box.Init();
        box.SetActive(false);
        box.Grabable.onGrab += OnGrabBox;

        boxInPos.Add(box, posFree);

        PosFree.Remove(posFree);

        boxInPos[box] = finalPos;
        PosFree.Remove(finalPos);

        StartCoroutine(TranslateBoxToPosition(box, posFree));
    }
Exemplo n.º 11
0
 public KeyValuePair <string, AlimentState> CreateKeyPairValue(string _name, AlimentState _state)
 {
     return(new KeyValuePair <string, AlimentState>(_name, _state));
 }