コード例 #1
0
 public static DecorationManager getInstance()
 {
     if(instance == null){
         instance = new DecorationManagerInstance();
     }
     return instance;
 }
コード例 #2
0
    public void OnEnable()
    {
        selected      = Tools.current;
        Tools.current = Tool.None;

        if (!loaded)
        {
            string[] paths = AssetDatabase.GetAllAssetPaths();
            foreach (string path in paths)
            {
                if (path.StartsWith("Assets") || path.StartsWith("assets"))
                {
                    AssetDatabase.LoadAssetAtPath(path, typeof(IsoDecoration));
                }
            }

            IsoDecoration[] isoDecorations = DecorationManager.getInstance().textureList();
            foreach (var id in isoDecorations)
            {
                if (id.nCols * id.nRows > maxTile)
                {
                    maxTile = id.nCols * id.nRows;
                }
            }
            loaded = true;
        }

#if UNITY_EDITOR
        m_LastEditorUpdateTime    = Time.realtimeSinceStartup;
        EditorApplication.update += OnEditorUpdate;
#endif
    }
コード例 #3
0
    private void Awake()
    {
        if (_instance != null)
        {
            if (_instance != this)
            {
                Destroy(this);
            }
        }
        else
        {
            _instance = this;
        }

        if (!Application.isPlaying)
        {
            var loader = LoadShapes();
            while (loader.MoveNext())
            {
            }
            Debug.Log("Loaded shapes.");
        }
        else
        {
            ContentLoader.RegisterLoadCallback(LoadShapes);
        }
    }
コード例 #4
0
 public static DecorationManager getInstance()
 {
     if (instance == null)
     {
         instance = new DecorationManagerInstance();
     }
     return(instance);
 }
コード例 #5
0
    private void Awake()
    {
        instance = this;

        foreach (DecorationItem item in droneShop.GetComponentsInChildren <DecorationItem>()) // 상점에 있는 드론 꾸미기 아이템 리스트 만들기
        {
            droneDecorations.Add(item);
        }

        foreach (DecorationItem item in operatorShop.GetComponentsInChildren <DecorationItem>()) // 상점에 있는 오퍼레이터 꾸미기 아이템 리스트 만들기
        {
            operatorDecorations.Add(item);
        }
    }
コード例 #6
0
        private void RemoveShape(IDiagramShape diagramShape)
        {
            var diagramShapeViewModel = _diagramShapeToViewModelMap.Get(diagramShape);

            if (diagramShapeViewModel == null)
            {
                return;
            }

            if (diagramShapeViewModel is DiagramNodeViewModel)
            {
                DecorationManager.Unfocus(diagramShapeViewModel as DiagramNodeViewModel);
            }

            diagramShapeViewModel.RemoveRequested -= OnShapeRemoveRequested;

            RemoveFromViewModels(diagramShapeViewModel);
            _diagramShapeToViewModelMap.Remove(diagramShape);
        }
コード例 #7
0
 public void UnpinDecoration() => DecorationManager.UnpinDecoration();
コード例 #8
0
 public void PinDecoration() => DecorationManager.PinDecoration();
コード例 #9
0
 private void Awake()
 {
     Instance = this;
 }
コード例 #10
0
 public void setTexture(Texture2D texture)
 {
     this.realTexture = texture;
     DecorationManager.getInstance().update(this);
 }
コード例 #11
0
ファイル: DecorateModule.cs プロジェクト: juzaru18/TinyWorld
    public void OnInspectorGUI()
    {
        GUIStyle style = new GUIStyle();

        EditorGUILayout.HelpBox("Press left button to put the textures over the faces of the cell. Hold shift and press left button to copy the current texture of the hovering face.", MessageType.None);
        EditorGUILayout.Space();

        parallelDecoration = EditorGUILayout.Toggle("Draw Parallel", parallelDecoration);
        EditorGUILayout.Space();

        autoanimate = EditorGUILayout.Toggle("Auto Animate", autoanimate);

        if (autoanimate)
        {
            FrameRate = float.Parse(EditorGUILayout.TextField("Frame Rate:", FrameRate.ToString()));

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Frame Secuence:", GUIStyle.none, titleStyle);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.HelpBox("Let the frame secuence list empty if you want to use the default frame loop.", MessageType.None);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.BeginVertical();

            GUIContent btt = new GUIContent("Add Frame");
            Rect       btr = GUILayoutUtility.GetRect(btt, style);
            if (GUI.Button(btr, btt))
            {
                if (FrameSecuence == null)
                {
                    FrameSecuence = new int[0];
                }
                int[] tmpFrameSecuence = new int[FrameSecuence.Length + 1];
                for (int i = 0; i < FrameSecuence.Length; i++)
                {
                    tmpFrameSecuence[i] = FrameSecuence[i];
                }
                tmpFrameSecuence[tmpFrameSecuence.Length - 1] = 0;
                FrameSecuence = tmpFrameSecuence;
            }
            EditorGUILayout.EndVertical();
            EditorGUILayout.BeginVertical();
            btt = new GUIContent("Remove Frame");
            btr = GUILayoutUtility.GetRect(btt, style);
            if (GUI.Button(btr, btt))
            {
                if (FrameSecuence.Length > 0)
                {
                    if (FrameSecuence == null)
                    {
                        FrameSecuence = new int[0];
                    }
                    int[] tmpFrameSecuence = new int[FrameSecuence.Length - 1];
                    for (int i = 0; i < FrameSecuence.Length - 1; i++)
                    {
                        tmpFrameSecuence[i] = FrameSecuence[i];
                    }
                    FrameSecuence = tmpFrameSecuence;
                }
            }
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndHorizontal();

            if (FrameSecuence != null)
            {
                for (int i = 0; i < FrameSecuence.Length; i++)
                {
                    FrameSecuence[i] = int.Parse(EditorGUILayout.TextField(i.ToString(), FrameSecuence[i].ToString()));
                }
            }
        }
        EditorGUILayout.Space();

        EditorGUILayout.PrefixLabel("Decoration Objects", GUIStyle.none, titleStyle);

        GUI.backgroundColor = Color.Lerp(Color.black, Color.gray, 0.5f);

        EditorGUILayout.BeginVertical("Box");

        IsoDecoration[] isoDecorations = DecorationManager.getInstance().textureList();

        int   maxTextures  = 8;
        float anchoTextura = (Screen.width - 30) / maxTextures;

        if (isoDecorations.Length > maxTextures * LTSS)
        {
            scroll = EditorGUILayout.BeginScrollView(scroll, GUILayout.MaxHeight(anchoTextura * LTSS));
        }

        Event e = Event.current;

        int currentTexture = 0;

        foreach (IsoDecoration it in isoDecorations)
        {
            if (it.getTexture() == null)
            {
                continue;
            }

            if (currentTexture == 0)
            {
                EditorGUILayout.BeginHorizontal();
            }

            Rect auxRect = GUILayoutUtility.GetRect(anchoTextura, anchoTextura);
            Rect border  = new Rect(auxRect);
            auxRect.x += 2; auxRect.y += 2; auxRect.width -= 4; auxRect.height -= 4;

            if (e.isMouse && border.Contains(e.mousePosition))
            {
                if (e.type == EventType.mouseDown)
                {
                    paintingIsoDecoration = it;
                    this.Repaint          = true;
                }
            }

            if (it == paintingIsoDecoration)
            {
                EditorGUI.DrawRect(border, Color.yellow);
            }
            GUI.DrawTexture(auxRect, it.getTexture());

            currentTexture++;
            if (currentTexture == maxTextures)
            {
                EditorGUILayout.EndHorizontal(); currentTexture = 0;
            }
        }

        if (currentTexture != 0)
        {
            GUILayoutUtility.GetRect((maxTextures - currentTexture) * anchoTextura, anchoTextura);
            EditorGUILayout.EndHorizontal();
        }

        if (isoDecorations.Length > maxTextures * LTSS)
        {
            EditorGUILayout.EndScrollView();
        }


        EditorGUILayout.EndVertical();
    }
コード例 #12
0
ファイル: Map.cs プロジェクト: patrykos91/Laikos
        public static void loadMap(Texture2D _map, DecorationManager _decorations)
        {
            width = _map.Width;
            height = _map.Height;

            //Terrain
            int[] mapTexTmp = new int[width * height];
            _map.GetData<int>(mapTexTmp);

            int[,] mapTmp = new int[Width / SKALA + 1, Height / SKALA + 1];

            //Initialize map.
            for (int widthTmp = 0; widthTmp < Width / SKALA; ++widthTmp)
            {
                for (int heightTmp = 0; heightTmp < Height / SKALA; ++heightTmp)
                {
                    mapTmp[widthTmp, heightTmp] = 0;
                }
            }

            //Decorations
            foreach (Decoration _dec in _decorations.DecorationList)
            {
                Vector2 size = _dec.Size / SKALA;
                Vector3 position = _dec.Position / SKALA;

                position.X -= (int)size.X / 2 - 1;
                position.Z -= (int)size.Y / 2 - 1;

                for (int i = 0; i < size.X; ++i)
                {
                    for (int j = 0; j < size.Y; ++j)
                    {
                        mapTmp[(int)position.X + i, (int)position.Z + j] = 1;
                    }
                }
            }

            //Creating walkmesh
            int iloscDobrych = 0;
            int iloscZlych = 0;
            int licznik = 0;

            for (int widthTmp = 0; widthTmp < Width / SKALA; ++widthTmp)
            {
                for (int heightTmp = 0; heightTmp < Height / SKALA; ++heightTmp)
                {
                    for (int i = 0; i < SKALA; ++i)
                    {
                        for (int j = 0; j < SKALA; ++j)
                        {
                            System.Drawing.Color bitmapColor = System.Drawing.Color.FromArgb(mapTexTmp[(widthTmp * SKALA * width + heightTmp * SKALA) + (i * width) + j]);

                            if ((bitmapColor.R >= 15) && (bitmapColor.R < 150))
                            {
                                ++iloscDobrych;
                            }
                            else
                            {
                                ++iloscZlych;
                            }
                        }
                    }

                    if ((iloscDobrych / SKALA) <= iloscZlych)
                    {
                        mapTmp[licznik % (height / SKALA), licznik / (width / SKALA)] = 1;
                    }

                    iloscDobrych = 0;
                    iloscZlych = 0;

                    ++licznik;
                }
            }

            WalkMeshMap = mapTmp;
        }