コード例 #1
0
    /* LoadShelter()
     * Chargement de la configuration d'abri lors du chargement de montage
     **/
    private IEnumerator LoadShelter(ArrayList CustomConf = null,ArrayList PosConf = null)
    {
        while(_isBuilding)
            yield return null;

        foreach(DynShelterModule m in _modules)
        {
            m.RemoveModule();
        }
        _modules.Clear();
        _modManager.ClearManager();
        _currentModule = null;
        _selectedIndex = 0;

        yield return null;

        _isBuilding = true;
        //Attend que le objdata soit configuré
        while(gameObject.GetComponent<ObjData>().GetObjectModel() == null)
        {
            yield return new WaitForEndOfFrame();
        }

        //Création de l'abri par default
        ArrayList stConf = CustomConf;

        if(stConf.Count > 0)
        {
            Color32 c = new Color32(255,255,255,255);
        //			SaveTransform();
            for(int i=0;i<stConf.Count-2;i=i+8)
            {
                ModuleType typ = ModuleType.bloc;
                switch ((string)stConf[i]) //TYP >0
                {
                case "facade":
                    typ = ModuleType.facade;
                    break;
                case "bloc":
                    typ = ModuleType.bloc;
                    break;
                case "extremite":
                    typ = ModuleType.extremite;
                    break;
                }

                int t = (int) stConf[i+1]; //TAILLE >1

                string styl = (string) stConf[i+2]; //STYLE >2

                _nextInsertion = true;
                _decalZ = 0.0f;
                yield return StartCoroutine(AddModule(t,styl,typ,_currentColor));

                c = (Color32)stConf[i+3]; //color > 3
                _currentModule.SetColor(c);

                _currentModule.SetNextLocks((bool)stConf[i+4]);//NLock> 4
                _currentModule.SetPrevLocks((bool)stConf[i+5]);//PLock> 5
                _currentModule.SetAnchor((bool)stConf[i+6]); //Anchor > 6

                yield return new WaitForEndOfFrame();

                _modManager.UpdateLocalMods(_currentModule.GetGameObj(),true);
                _modManager.ApplyLoadConf((string[])stConf[i+7]); //ModConf>7
            }
            ChangeModuleColor(c);
            _isBuilding = false;
        }

        _selectedIndex = 0;
        UpdateCurrentModule();

        for(int i=0;i<_modules.Count;i++)
        {
            ((DynShelterModule)_modules[i]).SetPos(false,(float)PosConf[i]);
        }

        UpdateBoxCollider();

        enabled = false;
        ShowArrows(false);
        CenterDeployAndFeetLimit();
        yield return null;
    }
コード例 #2
0
    //Mets a jours le module courant
    public void UpdateCurrentModule()
    {
        //Debug.Log("selectedIndex : "+_selectedIndex+" count : "+_modules.Count );
        if(_modules.Count > 0)
        {
            /*if(_selectedIndex==-1)
                _selectedIndex = 0;
            if(_selectedIndex>=_modules.Count)
                _selectedIndex =_modules.Count-1;*/
            if(_selectedIndex==-1)
                return;
            if(_selectedIndex>=_modules.Count)
                return;
            _currentModule = (DynShelterModule) _modules[_selectedIndex];
            _tmpStylesNames = _dsMdl.GetStylesNameOfSize(_currentModule.GetSize(),_currentModule.GetModuleType());
            _tmpStylesThumbs = _dsMdl.GetStylesThumbsOfSize(_tmpStylesNames);

            _currentType = _currentModule.GetType().ToString();//_currentModule.GetModuleType().ToString();
            for(int i=0;i<_tmpStylesNames.Length;i++)
            {
                if(_tmpStylesNames[i] == _currentModule.GetStyle())
                {
                    _currentStyle = i;
                }
            }
            UpdateRules();

            //Locks -------------------------
            _isLockedNext = _currentModule.GetNextLock();
            _isLockedPrev = _currentModule.GetPrevLock();

            //Mods
            _modManager.UpdateLocalMods(_currentModule.GetGameObj());
        }
        else
        {
            //CAS OU PLUS DE MODULES
            _currentModule = null;
        }
        UI.SetSelectedItem(_selectedIndex);
        UI.SetSelectedLocks(_isLockedPrev,_isLockedNext);

        if(szbrand == "PoolCover")
        {
            UpdateVisibility();
        }
    }