Exemplo n.º 1
0
        public static Opreator CreateOpreator(char token)
        {
            Opreator opreator = null;

            switch (token)
            {
            case '+':
                opreator = new OpreatorAdd();
                break;

            case '-':
                opreator = new OpreatorSub();
                break;

            case 'x':
                opreator = new OpreatorMul();
                break;

            case '÷':
                opreator = new OpreatorDiv();
                break;
            }

            return(opreator);
        }
Exemplo n.º 2
0
 void Initialize()
 {
     Icon = Resources.Load <Texture> ("TexEditor_Huaji");
     this.titleContent             = new GUIContent("贴图工具v0.1b");
     this.autoRepaintOnSceneChange = true;
     this.maxSize     = new Vector2(800, 500);
     this.minSize     = new Vector2(800, 500);
     leftSideContent  = new GUIContent("");
     rightSideContent = new GUIContent("");
     this.Show(true);
     FormatOpreator            = null;
     EditorApplication.update += EditorUpdate;
 }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            //观察者模式
            Blog       xmf = new MyBlog("苏翅", $"发表了一张照片,点击链接查看!");
            SubScriber wnn = new SubScriber("王妮娜");
            SubScriber tmr = new SubScriber("唐马儒");
            SubScriber wmt = new SubScriber("王蜜桃");
            SubScriber anm = new SubScriber("敖尼玛");

            // 添加订阅者
            xmf.AddObserver(new NotifyEventHandler(wnn.Receive));
            xmf.AddObserver(new NotifyEventHandler(tmr.Receive));
            xmf.AddObserver(new NotifyEventHandler(wmt.Receive));
            xmf.AddObserver(new NotifyEventHandler(anm.Receive));

            xmf.Update();

            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();

            xmf.RemoveObserver(new NotifyEventHandler(wnn.Receive));
            Console.WriteLine($"移除订阅者{wnn.Name}");
            xmf.Update();

            Console.ReadKey();
            return;

            IOprFactory oprsub = new SubFactory();
            IOprFactory opradd = new AddFactory();
            Opreator    otsub  = oprsub.CreateOperation();

            otsub.A = 33;
            otsub.B = 22;
            Opreator otadd = opradd.CreateOperation();

            otadd.A = 8;
            otadd.B = 16;
            Trace.WriteLine($"SUB:{otsub.A}-{otsub.B}={otsub.GetResult()}");
            Trace.WriteLine($"ADD:{otadd.A}+{otadd.B}={otadd.GetResult()}");
            //A a = new A("1");
            //A aa = new A() { b = "1" };
            //Console.WriteLine(aa.b + a.b);
            //Console.ReadKey();
            //return;
            IDoctor d = new DoctorProvider();

            Trace.WriteLine($"old driver name is { d.GetDoctorName()} and {d.GetDoctorAge()} age now!!");
        }
Exemplo n.º 4
0
        public void Step(double deltaTime)
        {
            if (!_initslise)
            {
                _initslise = true;
                Reset();
            }

            Opreator.Calclate(this, deltaTime);

            if (Opreator.Finshed(this))
            {
                Opreator.Reset(this);
                ExcuteEvents();
            }
        }
Exemplo n.º 5
0
 public void Reset()
 {
     Opreator.Reset(this);
 }
Exemplo n.º 6
0
        void OnContent(int windowID)
        {
            #region Filter Settings
            string count = loadedtex == null ? "" : loadedtex.Count > 0 ? loadedtex.Count.ToString() : "";
            EditorGUILayout.HelpBox("筛选素材:" + count, MessageType.None);
            GUILayout.BeginHorizontal();
            GUILayout.Box("Resources Type");
            fType         = (FilterType)EditorGUILayout.EnumPopup(fType);
            externalFiler = GUILayout.TextField(externalFiler);
            GUILayout.EndHorizontal();
            EditorGUILayout.HelpBox("反选工具,输入关键词进行反向筛选,多个关键词用空格隔开", MessageType.Info);
            GUILayout.BeginHorizontal();
            GUILayout.Box("InversSelect");
            externalFilerInvers = GUILayout.TextField(externalFilerInvers);
            if (GUILayout.Button("Search"))
            {
                currentPageID = 0;
                loadedtex     = new List <Texture> ();
                loadedtex     = FindAssetsAutoFilter <Texture> (externalFiler);
                if (!System.String.IsNullOrEmpty(externalFilerInvers))
                {
                    string inversfilterRule = externalFilerInvers.Replace(' ', ';');
                    Debug.Log(inversfilterRule);
                    string [] inversRule = inversfilterRule.Split(';');
                    if (inversRule.Length == 0)
                    {
                        inversRule = new string[] { "externalFilerInvers" };
                    }
                    List <Texture> selected = new List <Texture>();
                    for (int i = 0; i < loadedtex.Count; i++)
                    {
                        bool include = true;
                        foreach (var rule in inversRule)
                        {
                            if (loadedtex[i].name.Contains(rule))
                            {
                                include = false;
                                break;
                            }
                        }
                        if (include)
                        {
                            selected.Add(loadedtex[i]);
                        }
                    }
                    loadedtex = selected;
                    selected  = null;
                }
            }
            GUILayout.EndHorizontal();
            #endregion
            GUILayout.Space(20);
            EditorGUILayout.HelpBox("Format Texture", MessageType.None);
            #region Format Settings
            if (DrawContent)
            {
                TextureImporterPlatformSettings platformSettings  = new TextureImporterPlatformSettings();
                TextureImporterSettings         textureSettings   = new TextureImporterSettings();
                TextureImporterCompression      texImpCompression = TextureImporterCompression.Compressed;

                GUILayout.BeginHorizontal();
                GUILayout.Label("Texture Type");
                texImpType = (TextureImporterType)EditorGUILayout.Popup((int)texImpType, GetAllTextureImportType);
                texFormat  = (TextureImporterFormat)EditorGUILayout.EnumPopup(texFormat);
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Texture Alpha");
                texAlphaImportMode    = (TextureImporterAlphaSource)EditorGUILayout.EnumPopup(texAlphaImportMode);
                texAlphaIsTransparent = EditorGUILayout.Toggle("Alpha Is Transparent", texAlphaIsTransparent);
                GUILayout.EndHorizontal();

                GUILayout.Space(10);

                GUILayout.BeginHorizontal();
                texOverriden      = EditorGUILayout.ToggleLeft("Override for " + EditorUserBuildSettings.activeBuildTarget.ToString(), texOverriden);
                texImpCompression = (TextureImporterCompression)EditorGUILayout.EnumPopup(texImpCompression);
                texSizeLevel      = EditorGUILayout.Popup(texSizeLevel, new string[] { "16", "32", "64", "128", "256", "512", "1024", "2048", "4096" });
                GUILayout.EndHorizontal();
                if (texImpCompression != TextureImporterCompression.Uncompressed)
                {
                    GUILayout.BeginHorizontal();
                    texCrunchedCompression = EditorGUILayout.Toggle("Crunched Compression", texCrunchedCompression);
                    texCompressionQuality  = Mathf.CeilToInt(EditorGUILayout.Slider("Quality", texCompressionQuality, 0, 100));
                    GUILayout.EndHorizontal();
                }
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("Format"))
                {
                    FormatOpreator = new Opreator();
                    FormatOpreator.OpreatorName = "Format";
                    //					string[] path = FindAssetsPath<Texture> (externalFiler);
                    for (int i = 0; i < loadedtex.Count; i++)
                    {
                        TextureImporter texImporter = GetTextureSettings(AssetDatabase.GetAssetPath(loadedtex[i]));
                        texImporter.ReadTextureSettings(textureSettings);
                        textureSettings.ApplyTextureType(texImpType);
                        textureSettings.filterMode           = FilterMode.Bilinear;
                        textureSettings.alphaIsTransparency  = texAlphaIsTransparent;
                        platformSettings.compressionQuality  = texCompressionQuality;
                        platformSettings.crunchedCompression = texCrunchedCompression;
                        platformSettings.textureCompression  = texImpCompression;
                        Debug.Log("Overriden ?" + texOverriden);
                        platformSettings.overridden         = texOverriden;
                        platformSettings.textureCompression = texImpCompression;
                        platformSettings.format             = texFormat;
                        texImporter.SetTextureSettings(textureSettings);
                        texImporter.SetPlatformTextureSettings(platformSettings);
                        texImporter.textureType    = texImpType;
                        texImporter.maxTextureSize = GetOverrideTexSize;
                        texImporter.alphaSource    = texAlphaImportMode;
                        FormatOpreator.Ditail      = texImporter.name;
                        FormatOpreator.progress    = (float)i / (float)loadedtex.Count;
                        texImporter.SaveAndReimport();
                    }
                    FormatOpreator = null;
                }

                GUILayout.EndHorizontal();
            }
            #endregion

            #region External
            float posX = Event.current.mousePosition.x + Mathf.Sin(Time.realtimeSinceStartup) * 20;
            float posY = Mathf.Clamp(Event.current.mousePosition.y, 200, 800) + Mathf.Cos(Time.realtimeSinceStartup) * 20;
            float size = 100 + Mathf.Sin(Time.realtimeSinceStartup) * 20;
            try{
                GUI.DrawTexture(new Rect(posX, posY, size, size), Icon);
            }catch {
                GUI.Label(new Rect(posX, posY, size, size), "我插件里面的图不见了!喵喵喵???");
                Debug.Log("我插件里面的图不见了!喵喵喵???");
            }
            #endregion
        }