Example #1
0
        public static void CreateMarker(SaveLua.Marker Owner, int mc)
        {
            GameObject NewMarker = Instantiate(Current.MarkerPrefab, Current.MasterChains[mc]);

            NewMarker.name = Owner.Name;
            MarkerObject NewObj = NewMarker.GetComponent <MarkerObject>();

            NewObj.Owner    = Owner;
            Owner.MarkerObj = NewObj;

            MarkerPropGraphic PropGraphic;

            if (Owner.MarkerType == SaveLua.Marker.MarkerTypes.BlankMarker && ArmyInfo.ArmyExist(Owner.Name))
            {
                PropGraphic = Current.SpawnGraphic;
            }
            else
            {
                PropGraphic = GetPropByType(Owner.MarkerType);
            }
            NewObj.Mf.sharedMesh     = PropGraphic.SharedMesh;
            NewObj.Mr.sharedMaterial = PropGraphic.SharedMaterial;
            NewObj.Bc.size           = PropGraphic.SharedMesh.bounds.size;
            NewObj.Bc.center         = PropGraphic.SharedMesh.bounds.center;

            NewObj.Tr.localPosition = ScmapEditor.ScmapPosToWorld(Owner.position);
            NewObj.Tr.localRotation = MarkerObject.ScmapRotToMarkerRot(Owner.orientation, Owner.MarkerType);

            NewMarker.SetActive(Current.MarkerLayersSettings.ActiveByType(Owner.MarkerType));
        }
Example #2
0
        public static MarkerPropGraphic GetPropByType(MapLua.SaveLua.Marker.MarkerTypes mType)
        {
            if (mType == MapLua.SaveLua.Marker.MarkerTypes.BlankMarker && ArmyInfo.ArmyExist(mType.ToString()))
            {
                return(Current.SpawnGraphic);
            }

            for (int i = 0; i < Current.MarkerPropGraphics.Length; i++)
            {
                if (Current.MarkerPropGraphics[i].mType == mType)
                {
                    return(Current.MarkerPropGraphics[i]);
                }
            }

            return(Current.MarkerPropGraphics[0]);
        }
Example #3
0
        public static void UpdateGraphics(SaveLua.Marker Owner, int mc)
        {
            bool Active = true;
            MarkerPropGraphic PropGraphic;

            if (Owner.MarkerType == SaveLua.Marker.MarkerTypes.BlankMarker && ArmyInfo.ArmyExist(Owner.Name))
            {
                PropGraphic = Current.SpawnGraphic;
                Active      = Current.MarkerLayersSettings.Spawn;
            }
            else
            {
                PropGraphic = GetPropByType(Owner.MarkerType);
                Active      = Current.MarkerLayersSettings.ActiveByType(Owner.MarkerType);
            }

            Owner.MarkerObj.Mf.sharedMesh     = PropGraphic.SharedMesh;
            Owner.MarkerObj.Mr.sharedMaterial = PropGraphic.SharedMaterial;
            Owner.MarkerObj.Bc.size           = PropGraphic.SharedMesh.bounds.size;
            Owner.MarkerObj.Bc.center         = PropGraphic.SharedMesh.bounds.center;

            Owner.MarkerObj.gameObject.SetActive(Active);
        }
Example #4
0
        public static void UpdateLayers()
        {
            for (int mc = 0; mc < MapLuaParser.Current.SaveLuaFile.Data.MasterChains.Length; mc++)
            {
                int Mcount = MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers.Count;
                for (int m = 0; m < Mcount; m++)
                {
                    if (MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers[m].MarkerObj != null)
                    {
                        bool Active = true;

                        if (MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers[m].MarkerType == SaveLua.Marker.MarkerTypes.BlankMarker &&
                            ArmyInfo.ArmyExist(MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers[m].Name))
                        {
                            Active = Current.MarkerLayersSettings.Spawn;
                        }
                        else
                        {
                            Active = Current.MarkerLayersSettings.ActiveByType(MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers[m].MarkerType);
                        }


                        if (Active && !MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers[m].MarkerObj.gameObject.activeSelf)
                        {
                            MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers[m].MarkerObj.gameObject.SetActive(true);
                        }
                        else if (!Active && MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers[m].MarkerObj.gameObject.activeSelf)
                        {
                            MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers[m].MarkerObj.gameObject.SetActive(false);
                        }
                    }
                }
            }

            RenderMarkersConnections.Current.UpdateConnections();
        }
Example #5
0
    IEnumerator GenerateingList()
    {
        //Debug.Log("Regenerate");
        int mc = 0;
        //const int PauseEvery = 64;
        //int GenerateCounter = 0;

        int Mcount     = MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers.Count;
        int TypesCount = (int)MapLua.SaveLua.Marker.MarkerTypes.Count;

        MapLua.SaveLua.Marker CurrentMarker;
        GameObject            newList;
        ListObject            NewListObject;
        int t = 0;
        int i = 0;

        float Realtime = Time.realtimeSinceStartup;
        //const float MaxAllowedOverhead = 0.03334f;
        const float MaxAllowedOverhead = 0.3f;


        List <GameObject> AllObjectsList = new List <GameObject>(1024);

        for (t = 0; t < TypesCount; t++)
        {
            List <GameObject> ObjectToSort = new List <GameObject>(1024);

            for (i = 0; i < Mcount; i++)
            {
                CurrentMarker = MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers[i];
                if ((int)CurrentMarker.MarkerType != t)
                {
                    continue;
                }

                if (CurrentMarker == null || CurrentMarker.MarkerObj == null)
                {
                    continue;
                }

                newList = Instantiate(ListPrefab, Pivot.position, Quaternion.identity) as GameObject;
                newList.GetComponent <RectTransform>().SetParent(Pivot);
                newList.name = CurrentMarker.Name;
                ObjectToSort.Add(newList);

                NewListObject = newList.GetComponent <ListObject>();
                AllFields.Add(NewListObject);
                NewListObject.ObjectName.text     = CurrentMarker.Name;
                NewListObject.InstanceId          = i;
                NewListObject.ListId              = 0;
                NewListObject.ConnectedGameObject = CurrentMarker.MarkerObj.gameObject;
                NewListObject.ClickAction         = SelectListGameobject;

                if (!NewListObject.ConnectedGameObject.activeSelf)
                {
                    newList.SetActive(false);
                }

                if (Selection.SelectionManager.Current.Selection.Ids.Contains(i))
                {
                    NewListObject.SetSelection(1);
                }
                else
                {
                    NewListObject.SetSelection(0);

                    if (Selection.SelectionManager.Current.SymetrySelection.Length > 0)
                    {
                        for (int s = 0; s < Selection.SelectionManager.Current.SymetrySelection.Length; s++)
                        {
                            if (Selection.SelectionManager.Current.SymetrySelection[s].Ids.Contains(i))
                            {
                                NewListObject.SetSelection(2);
                            }
                        }
                    }
                }
                if (CurrentMarker.MarkerType == MapLua.SaveLua.Marker.MarkerTypes.BlankMarker && ArmyInfo.ArmyExist(CurrentMarker.Name))
                {
                    NewListObject.Icon.sprite = Markers.MarkersControler.Current.SpawnGraphic.Icon;
                }
                else
                {
                    NewListObject.Icon.sprite = Markers.MarkersControler.GetIconByType(CurrentMarker.MarkerType);
                }

                /*GenerateCounter++;
                 * if (GenerateCounter > PauseEvery)
                 * {
                 *      GenerateCounter = 0;
                 *      yield return null;
                 *
                 * }*/
                if (Time.realtimeSinceStartup - Realtime > MaxAllowedOverhead)
                {
                    yield return(null);

                    Realtime = Time.realtimeSinceStartup;
                }
            }

            AllObjectsList.AddRange(ObjectToSort.OrderBy(go => go.name));
        }

        int ListCount = AllObjectsList.Count;

        for (i = 0; i < ListCount; i++)
        {
            AllObjectsList[i].transform.SetSiblingIndex(i);
        }

        Generated      = true;
        GeneratedCount = AllFields.Count;


        Layout.enabled     = true;
        SizeFitter.enabled = true;

        yield return(null);

        Layout.enabled     = false;
        SizeFitter.enabled = false;
        GeneratingEnum     = null;
        if (Buffor)
        {
            Buffor = false;
            UpdateSelectionAfterGenerate = false;
            GenerateList();
        }
        else if (UpdateSelectionAfterGenerate)
        {
            UpdateSelectionAfterGenerate = false;
            UpdateSelection();
        }
    }
Example #6
0
        void GenerateMarkers()
        {
            ChainName.text = MapLuaParser.Current.SaveLuaFile.Data.Chains[ChainSelected].Name;

            int Mcount = MapLuaParser.Current.SaveLuaFile.Data.Chains[ChainSelected].ConnectedMarkers.Count;

            for (int i = 0; i < Mcount; i++)
            {
                MapLua.SaveLua.Marker CurrentMarker = MapLuaParser.Current.SaveLuaFile.Data.Chains[ChainSelected].ConnectedMarkers[i];

                GameObject newList = Instantiate(ListPrefab_Marker, Pivot.position, Quaternion.identity) as GameObject;
                newList.GetComponent <RectTransform>().SetParent(Pivot);
                ListObject NewListObject = newList.GetComponent <ListObject>();

                NewListObject.ObjectName.text = CurrentMarker.Name;
                NewListObject.InstanceId      = i;
                //NewListObject.ClickActionId = SelectMarker;
                NewListObject.DragAction = DragEnded;

                NewListObject.ConnectedGameObject = CurrentMarker.MarkerObj.gameObject;
                NewListObject.ClickAction         = Selection.SelectionManager.Current.SelectObject;

                int ObjectId = SelectionManager.Current.GetIdOfObject(NewListObject.ConnectedGameObject);

                if (Selection.SelectionManager.Current.Selection.Ids.Contains(ObjectId))
                {
                    NewListObject.SetSelection(1);
                }
                else
                {
                    NewListObject.SetSelection(0);

                    if (Selection.SelectionManager.Current.SymetrySelection.Length > 0)
                    {
                        for (int s = 0; s < Selection.SelectionManager.Current.SymetrySelection.Length; s++)
                        {
                            if (Selection.SelectionManager.Current.SymetrySelection[s].Ids.Contains(ObjectId))
                            {
                                NewListObject.SetSelection(2);
                            }
                        }
                    }
                }

                if (CurrentMarker.MarkerType == MapLua.SaveLua.Marker.MarkerTypes.BlankMarker && ArmyInfo.ArmyExist(CurrentMarker.Name))
                {
                    NewListObject.Icon.sprite = Markers.MarkersControler.Current.SpawnGraphic.Icon;
                }
                else
                {
                    NewListObject.Icon.sprite = Markers.MarkersControler.GetIconByType(CurrentMarker.MarkerType);
                }
                AllFields.Add(NewListObject);
            }
        }