public static options GetOptions(this OPTIONS options_key, SccompDbf selected_comp)
        {
            try
            {
                using (LocalDbEntities db = DBX.DataSet(selected_comp))
                {
                    options opt = db.options.Where(o => o.key == options_key.ToString()).FirstOrDefault();

                    if (opt != null)
                    {
                        return(opt);
                    }
                    else
                    {
                        options o = new options {
                            key = options_key.ToString()
                        };
                        db.options.Add(o);
                        db.SaveChanges();
                        return(o);
                    }
                }
            }
            catch (Exception ex)
            {
                XMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, XMessageBoxIcon.Error);
                return(null);
            }
        }
Exemple #2
0
    void InstantiatePrimitive(OPTIONS op)
    {
        switch (op)
        {
        /// 创建资源
        case OPTIONS.CUBE:
            GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
            cube.transform.position = Vector3.zero;
            break;

        case OPTIONS.SPHERE:
            GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            sphere.transform.position = Vector3.zero;
            break;

        case OPTIONS.PLANE:
            GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane);
            plane.transform.position = Vector3.zero;
            break;

        default:
            Debug.LogError("Unrecognized Option");
            break;
        }
    }
    void OnGUI()
    {
        findType = (OPTIONS)EditorGUILayout.EnumPopup("查找目标类型", findType);

        GUILayout.Label("查找文件:");
        target = (Object)EditorGUILayout.ObjectField(target, typeof(Object), true);
        if (GUILayout.Button("查找"))
        {
            results.Clear();
            Debug.Log("开始查找.");
            FindOBJ(Application.dataPath + "/Resources/Prefabs/Bullet");

            FindOBJ(Application.dataPath + "/Resources/Prefabs/Weapon");
        }
        if (results.Count > 0)
        {
            foreach (Object t in results)
            {
                EditorGUILayout.ObjectField(t, typeof(Object), false);
            }
        }
        else
        {
            GUILayout.Label("无数据");
        }
    }
Exemple #4
0
    void OnGUI()
    {
        op = (OPTIONS)EditorGUILayout.EnumPopup("类型:", op);

        if (op == OPTIONS.Mesh)
        {
            _mesh = EditorGUILayout.ObjectField(_mesh, typeof(Mesh), true) as Mesh;
        }
        if (op == OPTIONS.Panel)
        {
            _mesh = null;
        }
        if (op == OPTIONS.MeshFilter)
        {
            _meshFilder = EditorGUILayout.ObjectField(_meshFilder, typeof(MeshFilter), true) as MeshFilter;
        }
        if (op == OPTIONS.SkinnedMeshRenderer)
        {
            _smr = EditorGUILayout.ObjectField(_smr, typeof(SkinnedMeshRenderer), true) as SkinnedMeshRenderer;
        }
        LayarCount = EditorGUILayout.IntField("层数:", LayarCount);
        if (GUILayout.Button("确定"))
        {
            buildFurMesh(_mesh, LayarCount);
            GameObject.DestroyImmediate(this, true);
        }
    }
Exemple #5
0
 public void OnInspectorGUI()
 {
     string[] sOptions = { "Cube", "Sphere", "Plane" };
     index = EditorGUILayout.Popup(index, sOptions);
     op    = (OPTIONS)EditorGUILayout.EnumPopup("EnumPopup:", op);
     EditorGUILayout.MinMaxSlider(ref fMin, ref fMax, 0.0f, 100.0f);
 }
    void Gen(OPTIONS op)
    {
        switch (op)
        {
        case OPTIONS.Billow:
            Bill();
            break;

        case OPTIONS.Perlin:
            Perlin();
            break;

        case OPTIONS.RidgedMultifractal:
            RidgedMultifractal();
            break;

        case OPTIONS.Spheres:
            Spheres();
            break;

        case OPTIONS.Voronoi:
            Vornoi();
            break;

        case OPTIONS.Cylinders:
            Cylinders();
            break;

        default:
            Debug.LogError("Unrecognized Option");
            break;
        }
    }
Exemple #7
0
        public static void ConnectionThread(object state)
        {
            OPTIONS.init();
            OPTIONS.Login.IncomingPacket += OnLoginPacket;
            OPTIONS.Chat.IncomingPacket  += OnChatPaket;

            try
            {
#if DEBUG
                OPTIONS.Connection = VaserClient.ConnectClient("localhost", 3100, OPTIONS.PColl);
                OPTIONS.Connection.Disconnecting += OnDisconnectingLink;
#else
                OPTIONS.Connection = VaserClient.ConnectClient(tb_ServerAddress.Text, 3100, OPTIONS.PColl);
                OPTIONS.Connection.Disconnecting += OnDisconnectingLink;
#endif
            }
            catch
            {
                Message msg = new Message();
                msg.command     = 2; //close
                msg.Messagedata = "Can't connect.";
                IncommingLogin.Enqueue(msg);

                ConnectingRunning = false;

                return;
            }

            SendL1.Username = Username;
            OPTIONS.Login.SendContainer(OPTIONS.Connection, SendL1, SEND_LOGIN.ContID, 0);

            ConnectingRunning = false;
        }
 void OnGUI()
 {
     op = (OPTIONS)EditorGUILayout.EnumPopup("Primitive to create:", op);
     if (GUILayout.Button("Create"))
     {
         InstantiatePrimitive(op);
     }
 }
Exemple #9
0
    void generate(OPTIONS op)
    {
        if (GameObject.Find(objectName) != null)
        {
            EditorUtility.DisplayDialog("Error", "Object " + objectName + " already exists", "Ok", "");
        }
        else
        {
            Transform level = new GameObject(objectName).transform;
            if (useRandomSeed)
            {
                seed = Time.time.ToString();
            }
            System.Random rnd = new System.Random(seed.GetHashCode());
            switch (op)
            {
            case OPTIONS.Hauberk:
                Hauberk h = GameObject.Find(objectName).AddComponent <Hauberk> ();
                h.addRooms(rooms);
                h.setSeed(rnd);
                h.setIsRandomSeed(useRandomSeed);
                h.GenerateLevel(mapSize, level, tilePrefab, outlinePercent);
                break;

            case OPTIONS.Cave:
                Cave c = GameObject.Find(objectName).AddComponent <Cave>();
                c.setSeed(rnd);
                c.setIsRandomSeed(useRandomSeed);
                //c.GenerateLevel(level, randomFillPercent, width, height);
                break;

            case OPTIONS.TEST:
                Debug.Log("Testing...");
                Debug.Log(System.IO.Directory.GetCurrentDirectory());

                SimpleProgressBar window1 = new SimpleProgressBar();
                //ProgressBarTest window1 = new ProgressBarTest();
                window1.setup();
                window1.ShowPopup();
                window1.log        = "Initialized builder... v2";
                window1.isBuilding = true;
                window1.listLength = 5;

                window1.doStep();
                window1.doStep();
                window1.doStep();
                window1.doStep();
                window1.doStep();
                break;

            default:
                Debug.LogError("Unrecognized Option");
                break;
            }
        }
    }
 internal override void FocussedLeftOnEnemy(GameObject enemy)
 {
     standardOrder = true;
     unitState     = OPTIONS.Attack;
     MoveToPoint   = enemy.transform.position;
     Target        = enemy;
     IsAttacking   = true;
     IsMoving      = true;
     standardOrder = false;
 }
    internal override void DoStart()
    {
        fabrikatNames = new string[Fabrikat.Count + 1];


        for (int i = 0; i < Fabrikat.Count; i++)
        {
            fabrikatNames[i] = Fabrikat[i].name;
        }
        fabrikatNames[Fabrikat.Count] = "StopProduction";
        UnitState = unitState = OPTIONS.StopProduction;
    }
Exemple #12
0
    void InstantiatePrimitive(OPTIONS op)
    {
        switch (op)
        {
        case OPTIONS.CUBE:      break;

        case OPTIONS.SPHERE: break;

        case OPTIONS.PLANE: break;

        default: Debug.LogError("Unrecognized Option"); break;
        }
    }
Exemple #13
0
    void OnGUI()
    {
        op      = (OPTIONS)EditorGUILayout.EnumPopup("1. Select Button Color:", op);
        btn_txt = EditorGUILayout.TextField("2. Enter Button Text:", btn_txt);
        GUILayout.Label("3. Select Parent Canvas or Panel in Hierarchy");
        if (GUILayout.Button("4. Create Button"))
        {
            InstantiatePrimitive(op);
        }



        HorizontalLine(Color.grey);
    }
    private void OnGUI()
    {
        GUILayout.Label("Generate an object to use in game.", EditorStyles.boldLabel);

        objectName = EditorGUILayout.TextField("Object Name", objectName);

        //Use this for layermasks
        flags = EditorGUILayout.MaskField("Flags", flags, options);

        baseObject = EditorGUILayout.Toggle("Is this a Base object?", baseObject);
        meshObject = EditorGUILayout.ObjectField("New Object Model", meshObject, typeof(UnityEngine.Object), false);
        //Determines the type of pivot and snappoints set.
        objectType = (OPTIONS)EditorGUILayout.EnumPopup("Object Type", objectType);
        if (objectType == OPTIONS.Custom)
        {
            customSnapPointsNo = EditorGUILayout.IntField("Number of Snap Points", customSnapPointsNo);
        }
        isSnappable = EditorGUILayout.Toggle("Snappable", isSnappable);
        EditorGUILayout.Space(30f);
        GUILayout.Label("Assign the object's properties", EditorStyles.boldLabel);
        EditorGUILayout.PrefixLabel("Object Description");
        GUIStyle wrapText = EditorStyles.textArea;

        wrapText.wordWrap = true;
        description       = EditorGUILayout.TextArea(description, wrapText, GUILayout.Height(50f));
        thumbnail         = EditorGUILayout.ObjectField("Thumbnail", thumbnail, typeof(Image), false);
        researchTime      = EditorGUILayout.FloatField("Research Time (Float)", researchTime);
        researchCost      = EditorGUILayout.IntField("Research Cost (Integer)", researchCost);
        buildCost         = EditorGUILayout.IntField("Build Cost (Integer)", buildCost);

        isUnlocked = EditorGUILayout.Toggle("Already Unlocked?", isUnlocked);



        EditorGUILayout.PropertyField(newUnlockProperty, true);
        EditorGUILayout.PropertyField(prerequisitUnlocks, true);
        serialObj.ApplyModifiedProperties();

        if (GUILayout.Button("Generate Game Object"))
        {
            if (objectName != "")
            {
                GenerateDirectory(objectName);
            }
            else
            {
                Debug.Log("Please specify an object name");
            }
        }
    }
Exemple #15
0
    protected override EnumProvider.ORDERSLIST on_UnitStateChange(EnumProvider.ORDERSLIST stateorder)
    {
        //Debug.Log("OnUnitStateChange called!!!!!!!!!!!!!!!");
        movingUnitState = (OPTIONS)stateorder;
        if (!UNIT.Options.standardOrder)
        {
            if (System.Enum.IsDefined(typeof(OPTIONS), (int)stateorder))
            {
                switch (movingUnitState)
                {
                case OPTIONS.MoveTo:
                    SetKinematic();
                    WayPoints.Clear();
                    UNIT.InteractingUnits.Clear();
                    UNIT.Options.LockOnFocus();
                    return(stateorder);

                case OPTIONS.Patrol:
                    SetKinematic();
                    UNIT.InteractingUnits.Clear();
                    UNIT.Options.LockOnFocus();
                    return(stateorder);

                case OPTIONS.Guard:
                    SetKinematic();
                    WayPoints.Clear();
                    UNIT.InteractingUnits.Clear();
                    UNIT.Options.LockOnFocus();
                    return(stateorder);

                case OPTIONS.Hide:
                    WayPoints.Clear();
                    SetKinematic();
                    //todo:-----------------
                    return(stateorder);

                case OPTIONS.Stay:
                    SetKinematic();
                    WayPoints.Clear();
                    MoveToPoint     = gameObject.transform.position;
                    MovingDirection = MoveToPoint;
                    UNIT.InteractingUnits.Clear();

                    return(stateorder);
                }
            }
        }
        return(stateorder);
    }
Exemple #16
0
    void OnGUI()
    {
        GUILayout.Label("Pyxel Importer", EditorStyles.boldLabel);
        option = (OPTIONS)EditorGUILayout.EnumPopup("Option :", option);
        EditorGUILayout.Separator();

        switch (option)
        {
            case OPTIONS.PrefabOnly:
                TILEWIDTH = EditorGUILayout.IntField("Tile Width:", TILEWIDTH);
                TILEHEIGHT = EditorGUILayout.IntField("Tile Height:", TILEHEIGHT);
                TilesTexture = (Texture2D)EditorGUILayout.ObjectField("Texture", TilesTexture, typeof(Texture2D), false);
                break;
            case OPTIONS.LevelOnly:
                levelFile = EditorGUILayout.TextField("Level File:", levelFile);
                break;
            case OPTIONS.PrefabAndLevel:
                levelFile = EditorGUILayout.TextField("Level File:", levelFile);
                TilesTexture = (Texture2D)EditorGUILayout.ObjectField("Texture", TilesTexture, typeof(Texture2D), false);
                TILEWIDTH = EditorGUILayout.IntField("Tile Width:", TILEWIDTH);
                TILEHEIGHT = EditorGUILayout.IntField("Tile Height:", TILEHEIGHT);
                break;
            default:
                break;
        }

        // Generate Button
        Rect rect = EditorGUILayout.BeginHorizontal("Button");
        if (GUI.Button(rect, GUIContent.none))
        {
            switch (option)
            {
                case OPTIONS.PrefabOnly:
                    CreatePrefabs();
                    break;
                case OPTIONS.LevelOnly:
                    CreateLevel();
                    break;
                case OPTIONS.PrefabAndLevel:
                    CreatePrefabs();
                    CreateLevel();
                    break;
                default:
                    break;
            }
        }
        GUILayout.Label("Generate Prefabs");
        EditorGUILayout.EndHorizontal();
    }
Exemple #17
0
    void OnGUI()
    {
        GUILayout.Label("Output Settings for Map Generation", EditorStyles.boldLabel);
        objectName = EditorGUILayout.TextField("Object Name: ", objectName);
        op         = (OPTIONS)EditorGUILayout.EnumPopup("Map style:", op);
        DoGUI(op);
        useRandomSeed = EditorGUILayout.Toggle("Use random seed", useRandomSeed);
        EditorGUI.BeginDisabledGroup(useRandomSeed);
        seed = EditorGUILayout.TextField("Seed: ", seed);
        EditorGUI.EndDisabledGroup();

        if (GUILayout.Button("Generate"))
        {
            generate(op);
        }
    }
Exemple #18
0
    protected override EnumProvider.ORDERSLIST on_UnitStateChange(EnumProvider.ORDERSLIST stateorder)
    {
        attackState = (OPTIONS)stateorder;
        if (!UNIT.Options.standardOrder)
        {
            if (System.Enum.IsDefined(typeof(OPTIONS), (int)stateorder))
            {
                switch (attackState)
                {
                case OPTIONS.Attack:
                    if (!UNIT.IsABuilding)
                    {
                        this.GetComponent <Movability>().SetKinematic();
                        this.GetComponent <Movability>().WayPoints.Clear();
                        UNIT.Options.MoveToPoint = this.gameObject.transform.position;
                        this.GetComponent <Movability>().IsMoving = false;
                    }
                    Debug.Log("ATTACKE!!!");
                    UNIT.Options.LockOnFocus();
                    return(stateorder);

                case OPTIONS.Conquer:
                    if (!GetComponent <Gunner>())
                    {
                        this.gameObject.AddComponent <Gunner>();
                    }
                    UNIT.Options.UnitState = EnumProvider.ORDERSLIST.Stay;
                    if (!UNIT.IsABuilding)
                    {
                        UNIT.Options.LockOnFocus();
                    }
                    GetComponent <Gunner>().FireAtWill = true;
                    return(stateorder);

                case OPTIONS.Seek:
                    if (!GetComponent <Gunner>())
                    {
                        this.gameObject.AddComponent <Gunner>();
                    }

                    return(stateorder);
                }
            }
        }
        return(stateorder);
    }
Exemple #19
0
    protected override EnumProvider.ORDERSLIST on_UnitStateChange(EnumProvider.ORDERSLIST stateorder)
    {
        //Debug.Log("OnUnitStateChange called!!!!!!!!!!!!!!!");
        movingUnitState = (OPTIONS)stateorder;
        if (!UNIT.Options.standardOrder)
        {
            if (System.Enum.IsDefined(typeof(OPTIONS), (int)stateorder))
            {
                switch (movingUnitState)
                {
                case OPTIONS.MoveTo:
                    SetKinematic();
                    WayPoints.Clear();
                    UNIT.InteractingUnits.Clear();
                    UNIT.Options.LockOnFocus();
                    return stateorder;
                case OPTIONS.Patrol:
                    SetKinematic();
                    UNIT.InteractingUnits.Clear();
                    UNIT.Options.LockOnFocus();
                    return stateorder;
                case OPTIONS.Guard:
                    SetKinematic();
                    WayPoints.Clear();
                    UNIT.InteractingUnits.Clear();
                    UNIT.Options.LockOnFocus();
                    return stateorder;
                case OPTIONS.Hide:
                    WayPoints.Clear();
                    SetKinematic();
                    //todo:-----------------
                    return stateorder;
                case OPTIONS.Stay:
                    SetKinematic();
                    WayPoints.Clear();
                    MoveToPoint = gameObject.transform.position;
                    MovingDirection = MoveToPoint;
                    UNIT.InteractingUnits.Clear();

                    return stateorder;
                }
            }
        }
        return stateorder;
    }
Exemple #20
0
        public static void Start()
        {
            Console.WriteLine("VaserChat Server is starting...");

            //initialize the server
            OPTIONS.init();

            OPTIONS.Login.IncomingPacket += OnLoginPacket;
            OPTIONS.Chat.IncomingPacket  += OnChatPacket;

            //start the server
            ChatServer                    = new VaserServer(System.Net.IPAddress.Any, 3100, OPTIONS.PColl);
            ChatServer.NewLink           += OnNewLink;
            ChatServer.DisconnectingLink += OnDisconnectingLink;
            ChatServer.Start();

            Console.WriteLine("VaserChat Server has started.");
        }
Exemple #21
0
    void generate(OPTIONS op)
    {
        if (GameObject.Find(objectName) != null)
        {
            EditorUtility.DisplayDialog("Error", "Object " + objectName + " already exists", "Ok", "");
        }
        else
        {
            Transform level = new GameObject(objectName).transform;
            if (useRandomSeed)
            {
                seed = Time.time.ToString();
            }
            System.Random rnd = new System.Random(seed.GetHashCode());
            switch (op)
            {
            case OPTIONS.Hauberk:
                Hauberk h = GameObject.Find(objectName).AddComponent <Hauberk> ();
                h.addRooms(rooms);
                h.setSeed(rnd);
                h.setIsRandomSeed(useRandomSeed);
                h.GenerateLevel(mapSize, level, tilePrefab, outlinePercent, true, attempts);
                break;

            case OPTIONS.Cave:
                Debug.Log(OPTIONS.Cave + " doesn't work right now...");

                /*Cave c = GameObject.Find (objectName).AddComponent<Cave>();
                 *  c.setSeed(rnd);
                 * c.setIsRandomSeed (useRandomSeed);
                 *  c.GenerateLevel(level, randomFillPercent, width, height);#*/
                break;

            case OPTIONS.TEST:
                Debug.Log("Testing...");
                Debug.Log(System.IO.Directory.GetCurrentDirectory());
                break;

            default:
                Debug.LogError("Unrecognized Option");
                break;
            }
        }
    }
Exemple #22
0
        private static T GetBase <T>(Type instance, string pName, OPTIONS opt, BindingFlags bindingFlags)
        {
            string fullName = instance.ToString() + "#" + pName;

            try
            {
                if (reflectedInfo.ContainsKey(fullName))
                {
                    if (reflectedInfo[fullName] is T)
                    {
                        return((T)reflectedInfo[fullName]);
                    }
                    else
                    {
                        throw new Exception(String.Format("{0} ({1}) was expected to be a {2}, but wasn't", fullName, reflectedInfo[fullName].ToString(), typeof(T)));
                    }
                }

                object toAdd;

                if (opt == OPTIONS.Field)
                {
                    toAdd = instance.GetField(pName, bindingFlags);
                }
                else if (opt == OPTIONS.Method)
                {
                    toAdd = instance.GetMethod(pName, bindingFlags);
                }
                else
                {
                    throw new ArgumentException(String.Format("Option {0} is not valid", opt));
                }

                reflectedInfo.Add(fullName, toAdd);
                return((T)toAdd);
            }
            // name can come from an untrusted source, so handle if it doesn't actually exist.
            catch (NullReferenceException e)
            {
                Debug.Log(String.Format("{0} {1} was not found in type {2}", typeof(T), pName, instance));
                Debug.Log(e.StackTrace);
                return(default(T));
            }
        }
Exemple #23
0
        public void Run()
        {
            OPTIONS userInput = OPTIONS.NONE;

            do
            {
                Console.Clear();
                userInput = DisplayMenu();
                Console.Clear();
                try {
                    funcs[userInput]();
                    Console.WriteLine("Press any key to return.");
                    Console.ReadKey();
                }
                catch (KeyNotFoundException ex) {
                    //Nothing to do. The option was not a valid one. Read another.
                }
            } while (userInput != OPTIONS.Exit);
        }
Exemple #24
0
    protected override EnumProvider.ORDERSLIST on_UnitStateChange(EnumProvider.ORDERSLIST stateorder)
    {
        attackState = (OPTIONS)stateorder;
        if (!UNIT.Options.standardOrder)
        {
            if (System.Enum.IsDefined(typeof(OPTIONS), (int)stateorder))
            {

                switch (attackState)
                {
                case OPTIONS.Attack:
                    if (!UNIT.IsABuilding)
                    {

                        this.GetComponent<Movability>().SetKinematic();
                        this.GetComponent<Movability>().WayPoints.Clear();
                        UNIT.Options.MoveToPoint = this.gameObject.transform.position;
                        this.GetComponent<Movability>().IsMoving = false;

                    }
                    Debug.Log("ATTACKE!!!");
                    UNIT.Options.LockOnFocus();
                    return stateorder;
                case OPTIONS.Conquer:
                    if (!GetComponent<Gunner>())
                        this.gameObject.AddComponent<Gunner>();
                    UNIT.Options.UnitState = EnumProvider.ORDERSLIST.Stay;
                    if (!UNIT.IsABuilding)
                        UNIT.Options.LockOnFocus();
                    GetComponent<Gunner>().FireAtWill = true;
                    return stateorder;
                case OPTIONS.Seek:
                    if (!GetComponent<Gunner>())
                        this.gameObject.AddComponent<Gunner>();

                    return stateorder;
                }
            }
        }
        return stateorder;
    }
Exemple #25
0
        public OPTIONS DisplayMenu()
        {
            OPTIONS option = OPTIONS.NONE;

            try {
                Array arr = Enum.GetValues(typeof(OPTIONS));
                Console.WriteLine("Choose an option");
                for (int i = 1; i < arr.Length; i++)
                {
                    Console.WriteLine("{0} {1}. ", i, arr.GetValue(i).ToString());
                }
                Console.WriteLine();
                Console.Write("-> ");
                var result = Console.ReadLine();
                option = (OPTIONS)Enum.Parse(typeof(OPTIONS), result);
            }
            catch (ArgumentException ex) {
                //nothing to do. User press select no option and press enter.
            }
            return(option);
        }
Exemple #26
0
 private void DoGUI(OPTIONS op)
 {
     if (op == OPTIONS.Hauberk)
     {
         GUILayout.Label("Hauberk Map Generation Settings", EditorStyles.boldLabel);
         mapSize        = EditorGUILayout.Vector2Field("Size:", mapSize);
         tilePrefab     = EditorGUILayout.ObjectField("Quad Wall Prefab", tilePrefab, typeof(Transform), true) as Transform;
         rooms          = EditorGUILayout.Toggle("Add rooms", rooms);
         outlinePercent = EditorGUILayout.Slider("Outline Percent:", outlinePercent, 0, 1);
     }
     if (op == OPTIONS.Cave)
     {
         GUILayout.Label("Cave Generation Settings", EditorStyles.boldLabel);
         width             = EditorGUILayout.IntField("Width:", width);
         height            = EditorGUILayout.IntField("Height:", height);
         randomFillPercent = EditorGUILayout.IntSlider("Random Fill Percent:", randomFillPercent, 0, 100);
     }
     if (op == OPTIONS.TEST)
     {
         GUILayout.Label("Test stuff", EditorStyles.boldLabel);
         debugPhrase = EditorGUILayout.TextField("Debug Phrase: ", debugPhrase);
     }
 }
Exemple #27
0
        //************************************************************************************************
        //
        //************************************************************************************************

        static public bool Normalize(ref string path, OPTIONS options)
        {
                        #if UNITY_EDITOR
            if (string.IsNullOrEmpty(path) == false)
            {
                path.Trim(CHAR_SPACE);

                if (System.IO.Path.IsPathRooted(path) == false)
                {
                    if ((options & OPTIONS.SLASH_TERMINATED) != 0)
                    {
                        AppendMissingSlash(ref path);
                    }

                    if ((options & OPTIONS.SEPARATORS) != 0)
                    {
                        path = path.Replace(CHAR_ALT_SEP, CHAR_STD_SEP);
                    }

                    if ((options & OPTIONS.LOWER_CASE) != 0)
                    {
                        path = path.ToLower();
                    }

                    else if ((options & OPTIONS.UPPER_CASE) != 0)
                    {
                        path = path.ToUpper();
                    }

                    return(((options & OPTIONS.CREATE) != 0) ? CreateFolders(path) : true);
                }
            }
                        #endif

            return(false);
        }
Exemple #28
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        Transition transition = (Transition)target;
        Vector2    BoxSize    = transition.gameObject.GetComponent <BoxCollider2D>().size;

        if (BoxSize != transition.LevelSize)
        {
            showMessage = false;
        }

        opt = (OPTIONS)EditorGUILayout.EnumPopup("Anchor:", opt);

        int operation = (int)opt;

        GUILayout.BeginHorizontal();

        if (GUILayout.Button("ApplySize"))
        {
            if (LevelSize.x >= 40 && LevelSize.y >= 22f)
            {
                transition.apply(operation);
                showMessage = true;
            }
            else
            {
                if (EditorUtility.DisplayDialog("Anomaly Detected", "Either the height or width of the level is smaller than the acceptable value. (40 x 22)", "Reset to default"))
                {
                    transition.ResetSize(BoxSize);
                }
            }
        }

        if (GUILayout.Button("FixEdges"))
        {
            transition.FixEdge();
        }

        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        Vector2 toSpawn = transition.SpawningPoint;

        if (GUILayout.Button("AddSpawn"))
        {
            if (Mathf.Abs(toSpawn.x) > (0.5f * LevelSize.x - 1) || Mathf.Abs(toSpawn.y) > (0.5f * LevelSize.y - 1))
            {
                EditorUtility.DisplayDialog("Anomaly Detected", "Spawning point is too close to or over the edges.", "Ok");
            }
            else
            {
                transition.AddSpawn(Vector2.zero);
            }
        }
        if (GUILayout.Button("RemoveSpawn"))
        {
            if (transition.Spawn.Count - 1 < transition.spawnIndex)
            {
                EditorUtility.DisplayDialog("Anomaly Detected", "Invalid index input.", "Ok");
            }
            else
            {
                transition.RemoveSpawn(transition.spawnIndex);
                transition.spawnIndex = 0;
            }
        }
        GUILayout.EndHorizontal();

        if (GUILayout.Button("ModifySpawn"))
        {
            if (transition.spawnIndex > transition.Spawn.Count - 1 || Mathf.Abs(toSpawn.x) > (0.5f * LevelSize.x - 1) || Mathf.Abs(toSpawn.y) > (0.5f * LevelSize.y - 1))
            {
                EditorUtility.DisplayDialog("Anomaly Detected", "Spawning point is too close to or over the edges.", "Ok");
            }
            else
            {
                transition.ModifySpawn(transition.spawnIndex, toSpawn);
            }
        }

        if (GUILayout.Button("StartHere"))
        {
            if (transition.spawnIndex > transition.Spawn.Count - 1)
            {
                EditorUtility.DisplayDialog("Anomaly Detected", "Invalid index input.", "Ok");
            }
            else
            {
                holder.corner             = new Vector2(transition.transform.position.x - (0.5f * (transition.LevelSize.x - 40f)), transition.transform.position.y - (0.5f * (transition.LevelSize.y - 22)));
                holder.corner2            = new Vector2(transition.transform.position.x + (0.5f * (transition.LevelSize.x - 40f)), transition.transform.position.y + (0.5f * (transition.LevelSize.y - 22)));
                player.currentLevel       = transition.LevelIndex;
                player.transform.position = new Vector3(transition.transform.position.x + transition.Spawn[transition.spawnIndex].x, transition.transform.position.y + transition.Spawn[transition.spawnIndex].y, player.transform.position.z);
                holder.transform.position = transition.CamPos(player.transform.position);
            }
        }

        if (showMessage)
        {
            EditorGUILayout.HelpBox("Success!", MessageType.Info);
        }

        if (currentIndex != transition.spawnIndex)
        {
            currentIndex = transition.spawnIndex;
            if (transition.spawnIndex <= transition.Spawn.Count() - 1)
            {
                transition.SpawningPoint = transition.Spawn[currentIndex];
            }
        }
        if (transition.spawnIndex > transition.Spawn.Count() - 1)
        {
            EditorGUILayout.HelpBox("Invalid Spawn Index.", MessageType.Warning);
        }
    }
    public void OnGUI()
    {
        op = (OPTIONS)EditorGUILayout.EnumPopup("Choose Noise:", op);


        switch (op)
        {
        case OPTIONS.Billow:
            Seed        = EditorGUILayout.IntField("Seed", Seed);
            OctaveCount = EditorGUILayout.IntField("Octaves", OctaveCount);
            Persistence = EditorGUILayout.DoubleField("Persistence", Persistence);
            Frequency   = EditorGUILayout.DoubleField("Frequency", Frequency);
            Lacunarity  = EditorGUILayout.DoubleField("Lacunarity", Lacunarity);
            break;

        case OPTIONS.Perlin:
            Seed        = EditorGUILayout.IntField("Seed", Seed);
            OctaveCount = EditorGUILayout.IntField("Octaves", OctaveCount);
            Persistence = EditorGUILayout.DoubleField("Persistence", Persistence);
            Frequency   = EditorGUILayout.DoubleField("Frequency", Frequency);
            Lacunarity  = EditorGUILayout.DoubleField("Lacunarity", Lacunarity);
            break;

        case OPTIONS.RidgedMultifractal:
            Seed        = EditorGUILayout.IntField("Seed", Seed);
            OctaveCount = EditorGUILayout.IntField("Octaves", OctaveCount);
            Frequency   = EditorGUILayout.DoubleField("Frequency", Frequency);
            Lacunarity  = EditorGUILayout.DoubleField("Lacunarity", Lacunarity);
            break;

        case OPTIONS.Spheres:
            Frequency = EditorGUILayout.DoubleField("Frequency", Frequency);
            break;

        case OPTIONS.Voronoi:
            Seed         = EditorGUILayout.IntField("Seed", Seed);
            Frequency    = EditorGUILayout.DoubleField("Frequency", Frequency);
            Displacement = EditorGUILayout.DoubleField("Displacement", Displacement);
            UseDis       = EditorGUILayout.Toggle("Use Distance", UseDis);
            break;

        case OPTIONS.Cylinders:
            Frequency = EditorGUILayout.DoubleField("Frequency", Frequency);
            break;

        default:
            Debug.LogError("Unrecognized Option");
            break;
        }

        Island = EditorGUILayout.Toggle("Is Island?", Island);
        if (Island)
        {
            EditorGUILayout.LabelField("**********-Island Settings-**********");

            a = EditorGUILayout.DoubleField("Push All Up", a);
            b = EditorGUILayout.DoubleField("Push The Edges Down", b);
            c = EditorGUILayout.DoubleField("The Drop-Off", c);
            d = EditorGUILayout.DoubleField("Distance From The Center", d);
        }

        if (GUILayout.Button("Create"))
        {
            GameObject obj = GameObject.Find("Terrain");
            if (obj != null)
            {
                terr = obj.GetComponent <Terrain>();
                Gen(op);
            }
            else
            {
                Debug.Log("Please Add Terrain Object To The Scene. Terrain Name Must Be 'Terrain'.");
                Debug.Log("PS: Uncheck 'Lightmap Static' In The Terrain Inspector For Better Performance While Editing.");
                return;
            }
        }
    }
Exemple #30
0
    void InstantiatePrimitive(OPTIONS op)
    {
        switch (op)
        {
        case OPTIONS.OSUOrange:
            GameObject orange_btn = Resources.Load("orange_btn") as GameObject;
            GameObject btn_o      = Instantiate(orange_btn);
            btn_o.GetComponentInChildren <TextMeshProUGUI>().text = btn_txt;
            btn_o.name = btn_txt.ToLower() + "_btn";
            btn_o.transform.SetParent(Selection.activeTransform, false);
            break;

        case OPTIONS.Blue:
            GameObject blue_btn = Resources.Load("blue_btn") as GameObject;
            GameObject btn_b    = Instantiate(blue_btn);
            btn_b.GetComponentInChildren <TextMeshProUGUI>().text = btn_txt;
            btn_b.name = btn_txt.ToLower() + "_btn";
            btn_b.transform.SetParent(Selection.activeTransform, false);
            break;

        case OPTIONS.Red:
            GameObject red_btn = Resources.Load("red_btn") as GameObject;
            GameObject btn_r   = Instantiate(red_btn);
            btn_r.GetComponentInChildren <TextMeshProUGUI>().text = btn_txt;
            btn_r.name = btn_txt.ToLower() + "_btn";
            btn_r.transform.SetParent(Selection.activeTransform, false);
            break;

        case OPTIONS.Yellow:
            GameObject yellow_btn = Resources.Load("yellow_btn") as GameObject;
            GameObject btn_y      = Instantiate(yellow_btn);
            btn_y.GetComponentInChildren <TextMeshProUGUI>().text = btn_txt;
            btn_y.name = btn_txt.ToLower() + "_btn";
            btn_y.transform.SetParent(Selection.activeTransform, false);
            break;

        case OPTIONS.Green:
            GameObject green_btn = Resources.Load("green_btn") as GameObject;
            GameObject btn_g     = Instantiate(green_btn);
            btn_g.GetComponentInChildren <TextMeshProUGUI>().text = btn_txt;
            btn_g.name = btn_txt.ToLower() + "_btn";
            btn_g.transform.SetParent(Selection.activeTransform, false);
            break;

        case OPTIONS.Purple:
            GameObject purple_btn = Resources.Load("purple_btn") as GameObject;
            GameObject btn_p      = Instantiate(purple_btn);
            btn_p.GetComponentInChildren <TextMeshProUGUI>().text = btn_txt;
            btn_p.name = btn_txt.ToLower() + "_btn";
            btn_p.transform.SetParent(Selection.activeTransform, false);
            break;

        case OPTIONS.Dark:
            GameObject dark_btn = Resources.Load("dark_btn") as GameObject;
            GameObject btn_d    = Instantiate(dark_btn);
            btn_d.GetComponentInChildren <TextMeshProUGUI>().text = btn_txt;
            btn_d.name = btn_txt.ToLower() + "_btn";
            btn_d.transform.SetParent(Selection.activeTransform, false);
            break;

        case OPTIONS.Light:
            GameObject light_btn = Resources.Load("light_btn") as GameObject;
            GameObject btn_l     = Instantiate(light_btn);
            btn_l.GetComponentInChildren <TextMeshProUGUI>().text = btn_txt;
            btn_l.name = btn_txt.ToLower() + "_btn";
            btn_l.transform.SetParent(Selection.activeTransform, false);
            break;

        default:
            Debug.LogError("Unrecognized Option");
            break;
        }
    }
    internal override void DoStart()
    {

        fabrikatNames = new string[Fabrikat.Count + 1];


        for (int i = 0; i < Fabrikat.Count; i++) fabrikatNames[i] = Fabrikat[i].name;
        fabrikatNames[Fabrikat.Count] = "StopProduction";
        UnitState = unitState = OPTIONS.StopProduction;
    }
Exemple #32
0
    void OnGUI()
    {
        this.mObj.Update();

        //Select Icon
        GUILayout.BeginHorizontal();       //水平
        this.properties["icons"].GetArrayElementAtIndex(0).objectReferenceValue = EditorGUILayout.ObjectField(new GUIContent("Default Icon"), this.properties["icons"].GetArrayElementAtIndex(0).objectReferenceValue, typeof(Texture2D));
        GUILayout.FlexibleSpace();         //加空
        GUILayout.EndHorizontal();
        //Text Filed
        GUILayout.BeginVertical("box");
        EditorGUILayout.PropertyField(this.properties["bundleVersion"], new GUIContent("Bundle Version*", "設定 Android 平台的 Version Name"));
        EditorGUILayout.PropertyField(this.properties["bundleVersionCode"], new GUIContent("Bundle Version Code", "設定 Android 平台的 Version Code"));
        EditorGUILayout.PropertyField(this.properties["defSym_ZhiweiDebug"], new GUIContent("開發測試GUI", "顯示『開發期』模擬特殊功能的測試用 GUI 介面"));
        GUILayout.EndVertical();
        //Text Filed + box
        GUILayout.BeginVertical("button");        //("box");
        EditorGUILayout.PropertyField(this.properties["defSym_DYGAME_DEBUGMODE"], new GUIContent("測試版", "在畫面左上角顯示測試訊息及 Web API 路徑"));
        EditorGUILayout.PropertyField(this.properties["defSym_LOBBY_2_5"], new GUIContent("2.5版功能", "指定輸出包含2.5版功能及場景資源"));
        EditorGUILayout.PropertyField(this.properties["defSym_LOBBY_2_5_MOON"], new GUIContent("2.5版功能 月亮版", "指定輸出包含2.5版功能及場景資源(含月亮主題特效的版本"));
        GUILayout.EndVertical();
        //button
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("確定"))
        {
            PlayerSettings.SetIconsForTargetGroup(BuildTargetGroup.Unknown, this.icons);
            PlayerSettings.bundleVersion             = this.bundleVersion;
            PlayerSettings.Android.bundleVersionCode = this.bundleVersionCode;
            EditorUserBuildSettings.development      = true;
            ShowNotification(new GUIContent("設定完成"));
        }
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        //Text Field
        GUILayout.Label("Base Settings", EditorStyles.boldLabel);
        myString = EditorGUILayout.TextField("Text Field", myString);
        //toggle settings
        groupEnabled = EditorGUILayout.BeginToggleGroup("Optional Settings", groupEnabled);
        myBool       = EditorGUILayout.Toggle("Toggle", myBool);         //checkbox
        myFloat      = EditorGUILayout.Slider("Slider", myFloat, -3, 3); //slider
        EditorGUILayout.EndToggleGroup();
        //Multi Text Field
        EditorGUILayout.TextArea("TextArea");
        //int Field
        EditorGUILayout.IntField(1);
        EditorGUILayout.LabelField("Min Val:", fMin.ToString());
        EditorGUILayout.LabelField("Max Val:", fMax.ToString());
        //Min-Max Slider
        EditorGUILayout.MinMaxSlider(ref fMin, ref fMax, 0.0f, 100.0f);
        EditorGUILayout.LabelField("Popup Index:", index.ToString());
        //combox
        string[] sOptions = { "Cube", "Sphere", "Plane" };
        index = EditorGUILayout.Popup(index, sOptions);
        //Enum combox
        EditorGUILayout.LabelField("EnumPopup Index:", ((int)op).ToString());
        op = (OPTIONS)EditorGUILayout.EnumPopup("EnumPopup:", op);
        //Multi Checkbox
        iMaskIndex = EditorGUILayout.MaskField("Mask Flags", iMaskIndex, sOptions);
        //Foldout Bar
        bState = EditorGUILayout.Foldout(bState, "Attribate");
        if (bState)
        {
            GUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Click Here!");
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Destory Self!"))
            {
                this.Close();
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }
        //
        Vector2 p2 = new Vector2(0.0f, 0.0f);
        Vector3 p3 = new Vector3(0.0f, 0.0f, 0.0f);
        Vector4 p4 = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);

        p2 = EditorGUILayout.Vector2Field("Point:", p2);
        p3 = EditorGUILayout.Vector3Field("Point:", p3);
        p4 = EditorGUILayout.Vector4Field("Point:", p4);
        //set OemCode + VersionCode
        bShowOemVersionCode = EditorGUILayout.Foldout(bShowOemVersionCode, "OemCode");
        string str = "";

        if (bShowOemVersionCode)
        {
            for (int i = 0; i < ENUM_OEM_LIST_MAX; i++)
            {
                GUILayout.BeginHorizontal("box");
                //enum oem
                enumOem[i] = (ENUM_OEM_LIST)EditorGUILayout.EnumPopup("", enumOem[i]);
                //oem int field
                FieldInfo EnumInfo = enumOem[i].GetType().GetField(enumOem[i].ToString());
                DescriptionAttribute[] EnumAttributes = (DescriptionAttribute[])EnumInfo.GetCustomAttributes(typeof(DescriptionAttribute), false);
                str = "" + EnumAttributes.Length;
                if (EnumAttributes.Length > 0)
                {
                    if (string.IsNullOrEmpty(sOemCodeString[i]) == true)
                    {
                        sOemCodeString[i] = string.Copy(EnumAttributes[0].Description);
                    }
                }
                sOemCodeString[i] = EditorGUILayout.TextField("", sOemCodeString[i]);
                //
                iVersionCode[i] = EditorGUILayout.IntField(iVersionCode[i]);
                //
                IsReleaseVersion[i] = EditorGUILayout.Toggle("正式版", IsReleaseVersion[i]);
                IsDebugVersion[i]   = EditorGUILayout.Toggle("測試版", IsDebugVersion[i]);
                GUILayout.EndHorizontal();
            }
            //keystore file location
            GUILayout.BeginHorizontal("box");
            if (GUILayout.Button("Browse Keystore"))
            {
                sKeystoreFile = EditorUtility.OpenFilePanel("Browse Keystore", "", "keystore");
            }
            GUILayout.Label(sKeystoreFile, EditorStyles.boldLabel);
            GUILayout.EndHorizontal();
            //build apk
            if (GUILayout.Button("產生APK"))
            {
                bool b = (EditorUtility.DisplayDialog("Infomation", " build APK?", "YES", "cancel"));
                if (b == false)
                {
                    return;                             //cancel
                }
                //keystore is null
                if (string.IsNullOrEmpty(sKeystoreFile) == true)
                {
                    EditorUtility.DisplayDialog("Keystore?", "Keystore is NULL", "QUIT", "");
                    return;
                }
                //copy keystore and aliasKey
                PlayerSettings.Android.keystoreName = sKeystoreFile;              //依人而異
                PlayerSettings.Android.keystorePass = "******";            //上面的keystore的密碼
                PlayerSettings.Android.keyaliasName = "aiwi_key";                 //固定,依附aiwi.keystore
                PlayerSettings.Android.keyaliasPass = "******";            //上面的keyalias的密碼
                //build apk file
                int iTotalFiles = 0;
                int iCountFiles = 0;
                for (int i = 0; i < ENUM_OEM_LIST_MAX; i++)
                {
                    if (IsReleaseVersion[i])
                    {
                        iTotalFiles++;
                    }
                    if (IsDebugVersion[i])
                    {
                        iTotalFiles++;
                    }
                }
                //Ex:Dygame_3.0.1024_49_121221_1_T_B2_051.apk
                string sProjectName      = "Dygame_";                                 //Dygame_
                string sOriginalBundle   = string.Copy(PlayerSettings.bundleVersion); //Ex:"3.0.1024_49_121221_1"
                string sVersionName      = "";                                        //3.0.1024
                string sVersionCode      = "";                                        //_49_, this need be replace , one apk per version code
                string sDateString       = "";                                        //121221
                string sBuildCount       = "";                                        //_1_
                int    iBuildCount       = 1;                                         //
                string sReleaseVersion   = "_R_B2_";                                  //B1=Android 4.4.2 SDK 22.3 ApiLevel 19 Unity4.3.3
                string sDebugVersion     = "_T_B2_";                                  //B2=Android 4.1.2 SDK 20.0.3 ApiLevel 16 Unity4.1.3
                string sBuildVersion     = "";                                        //use sDebugVersion or sReleaseVersion
                string sAPKFilename      = "";
                bool   IsDebugVersionApk = false;
                //split token
                bool     IsErrorHappen = false;
                string[] sToken        = sOriginalBundle.Split("_"[0]);
                if (string.IsNullOrEmpty(sToken[0]) == false)
                {
                    sVersionName = string.Copy(sToken[0]);
                }
                else
                {
                    IsErrorHappen = true;
                }
                if (string.IsNullOrEmpty(sToken[1]) == true)
                {
                    IsErrorHappen = true;                                                           //oem
                }
                if (string.IsNullOrEmpty(sToken[2]) == false)
                {
                    sDateString = string.Copy(sToken[2]);
                }
                else
                {
                    IsErrorHappen = true;
                }
                if (string.IsNullOrEmpty(sToken[3]) == false)
                {
                    sBuildCount = string.Copy(sToken[3]); int.TryParse(sBuildCount, out iBuildCount);
                }
                else
                {
                    IsErrorHappen = true;
                }
                if (IsErrorHappen == true)
                {
                    EditorUtility.DisplayDialog("Bundle Version error?", "Bundle Version format is Error. Ex: 3.0.1024_49_121221_1", "QUIT", "");
                }
                //build debug.apk then release.apk
                if (IsErrorHappen == false)
                {
                    for (int j = 0; j < 2; j++)                      //debug then release
                    {
                        //build test path
                        if (j == 0)
                        {
                            sBuildVersion     = sDebugVersion;
                            IsDebugVersionApk = true;
                        }
                        //build release path
                        else
                        {
                            sBuildVersion     = sReleaseVersion;
                            IsDebugVersionApk = false;
                        }
                        //build apk
                        for (int i = 0; i < ENUM_OEM_LIST_MAX; i++)
                        {
                            //skip false(未勾選)
                            if ((IsDebugVersionApk) && (IsDebugVersion[i] == false))
                            {
                                continue;
                            }
                            else if ((!IsDebugVersionApk) && (IsReleaseVersion[i] == false))
                            {
                                continue;
                            }
                            //replaced VersionCode
                            sVersionCode = "_" + iVersionCode[i] + "_";
                            //incoming BuildCount
                            if (iBuildCount <= 0)
                            {
                                iBuildCount = 1;                                               //min from 1
                            }
                            sBuildCount = "_" + iBuildCount + "_";
                            //target file name
                            sAPKFilename = sProjectName + sVersionName + sVersionCode + sDateString + sBuildCount + sBuildVersion + sOemCodeString[i] + ".apk";
                            EditorUtility.DisplayProgressBar("Auto Build " + iCountFiles + " - " + iTotalFiles, sAPKFilename, (float)(iCountFiles) / iTotalFiles);
                            //	BuildPipeline.BuildPlayer(sSelectedScene , sAPKFilename , BuildTarget.Android ,opt);
                            EditorUtility.DisplayDialog("Test?", "This is create a apk..", "Yes", "");
                            //
                            iCountFiles++;
                            iBuildCount++;
                        }
                    }
                }
                //
                ShowNotification(new GUIContent("完成"));
                EditorUtility.ClearProgressBar();
            }
        }
        //
        this.mObj.ApplyModifiedProperties();

        base.Repaint();
    }
 internal override void FocussedLeftOnEnemy(GameObject enemy)
 {
     standardOrder = true;
     unitState = OPTIONS.Attack;
     MoveToPoint = enemy.transform.position;
     Target = enemy;
     IsAttacking = true;
     IsMoving = true;
     standardOrder = false;
 }
    void OnGUI()
    {
        InitStyles();

        GUILayout.BeginVertical(styleHelpboxInner);
        GUILayout.Label("Master Tools version 0.2", normalLabel);
        GUILayout.Label(" Other Tools ", titleLabel);
        GUILayout.Space(20);
        GUILayout.Label("  Total size of Images in project folder ", subtitleLabel);
        GUILayout.BeginHorizontal(styleHelpboxInner);
        // Get All the
        if (GUILayout.Button(" Refresh ", GUILayout.MinWidth(80), GUILayout.MaxWidth(100), GUILayout.MinHeight(30)))
        {
            totalSize = 0;
            GetCompressedFileSize("Texture");
            _allTextureSizeInAsset = GetFormattedSize(totalSize);
            GetCompressedFileSize("Texture");
            _allAudioSizeInAsset = GetFormattedSize(totalSize);
            scriptIcon           = EditorGUIUtility.ObjectContent(null, typeof(Texture)).image as Texture2D;
            audioIcon            = EditorGUIUtility.ObjectContent(null, typeof(AudioClip)).image as Texture2D;
        }
        GUILayout.Space(200);
        GUILayout.BeginVertical();
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Box(scriptIcon, GUILayout.MinWidth(30), GUILayout.MinHeight(30));
        GUILayout.Label(" : " + _allTextureSizeInAsset, normalLabel);
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        GUILayout.Space(10);
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Box(audioIcon, GUILayout.MinWidth(30), GUILayout.MinHeight(30));
        GUILayout.Label(" : " + _allAudioSizeInAsset, normalLabel);
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Space(10);
        GUILayout.EndVertical();
        GUILayout.EndHorizontal();
        GUILayout.Space(20);
        GUILayout.Label(" Edit any player prefs ", subtitleLabel);
        GUILayout.BeginVertical();
        GUILayout.BeginHorizontal(styleHelpboxInner);

        _playerPrefsKey = EditorGUILayout.TextField(_playerPrefsKey, GUILayout.MinHeight(20));

        switch (op)
        {
        default:
            _playerPrefsValue = EditorGUILayout.TextField(_playerPrefsValue, GUILayout.MinHeight(20));
            break;

        case OPTIONS.Float:
            _playerPrefsFloatValue = EditorGUILayout.FloatField(_playerPrefsFloatValue, GUILayout.MinHeight(20));
            break;

        case OPTIONS.Int:
            _playerPrefsIntValue = EditorGUILayout.IntField(_playerPrefsIntValue, GUILayout.MinHeight(20));
            break;
        }
        op = (OPTIONS)EditorGUILayout.EnumPopup(op, GUILayout.MaxWidth(80));

        GUI.SetNextControlName("clearButton");
        if (GUILayout.Button("X", GUILayout.MaxWidth(20), GUILayout.Height(20)))
        {
            _playerPrefsKey               = "Key";
            _playerPrefsValue             = "Value";
            _playerPrefsNotificationLabel = "";
            GUI.FocusControl("clearButton");
        }

        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();

        if (GUILayout.Button("Save", GUILayout.MinWidth(100), GUILayout.MaxWidth(150), GUILayout.MinHeight(25)))
        {
            if (!string.IsNullOrEmpty(_playerPrefsKey))
            {
                if (op == OPTIONS.String)
                {
                    PlayerPrefs.SetString(_playerPrefsKey, _playerPrefsValue.ToString());
                }
                else if (op == OPTIONS.Int)
                {
                    PlayerPrefs.SetInt(_playerPrefsKey, _playerPrefsIntValue);
                }
                else if (op == OPTIONS.Float)
                {
                    PlayerPrefs.SetFloat(_playerPrefsKey, _playerPrefsFloatValue);
                }
                _playerPrefsNotificationLabel = "Data saved";
            }
            else
            {
                _playerPrefsNotificationLabel = "Enter the PlayerPrefs Key";
            }
        }
        if (GUILayout.Button("Get", GUILayout.MinWidth(100), GUILayout.MaxWidth(150), GUILayout.MinHeight(25)))
        {
            if (!string.IsNullOrEmpty(_playerPrefsKey))
            {
                if (op == OPTIONS.String)
                {
                    _playerPrefsValue = PlayerPrefs.GetString(_playerPrefsKey, _playerPrefsValue.ToString());
                }
                else if (op == OPTIONS.Int)
                {
                    _playerPrefsIntValue = PlayerPrefs.GetInt(_playerPrefsKey, _playerPrefsIntValue);
                }
                else if (op == OPTIONS.Float)
                {
                    _playerPrefsFloatValue = PlayerPrefs.GetFloat(_playerPrefsKey, _playerPrefsFloatValue);
                }
                _playerPrefsNotificationLabel = "Data loaded";
            }
            else
            {
                _playerPrefsNotificationLabel = "Enter the PlayerPrefs Key";
            }
        }

        if (GUILayout.Button("Delete this key", GUILayout.MinWidth(100), GUILayout.MaxWidth(150), GUILayout.MinHeight(25)))
        {
            if (!string.IsNullOrEmpty(_playerPrefsKey))
            {
                bool option = EditorUtility.DisplayDialog("Do you really want to Delete " + _playerPrefsKey + "'s data???",
                                                          "Gotta confirm it bro!",
                                                          "I know what I'm doing.",
                                                          "No bro, I swear I didn't do anything."
                                                          );
                if (option)
                {
                    PlayerPrefs.DeleteAll();
                    _playerPrefsNotificationLabel = "Deleted current key's data";
                }
            }
            else
            {
                _playerPrefsNotificationLabel = "Enter the PlayerPrefs Key";
            }
        }
        if (GUILayout.Button("Delete All", GUILayout.MinWidth(100), GUILayout.MaxWidth(150), GUILayout.MinHeight(25)))
        {
            bool option = EditorUtility.DisplayDialog("Do you really want to Delete all the Data ???? ",
                                                      "Gotta confirm it bro!",
                                                      "I know what I'm doing.",
                                                      "Noooooo!"
                                                      );
            if (option)
            {
                PlayerPrefs.DeleteAll();
                _playerPrefsNotificationLabel = "All data deleted";
            }
            else
            {
//				Debug.LogError(" Na bolta hai sala");
            }
        }

        GUILayout.EndHorizontal();
        GUILayout.Label(_playerPrefsNotificationLabel, normalLabel);
        GUILayout.EndVertical();

        GUILayout.Space(20);
        GUILayout.Label(" No more losing your changes ", subtitleLabel);
        GUILayout.BeginVertical();

        GUILayout.BeginHorizontal(styleHelpboxInner);
        isAutoSaveBeforePlay = GUILayout.Toggle(isAutoSaveBeforePlay, "Auto save scene before playing");
        if (GUILayout.Button("Save settings", GUILayout.MaxWidth(100), GUILayout.MaxHeight(30)))
        {
            EditorPrefs.SetBool("autoSaveOnPlay", isAutoSaveBeforePlay);
        }
//		isAutoSaveWithinTime = GUILayout.Toggle(isAutoSaveWithinTime,"Auto save within some time");
        GUILayout.EndHorizontal();
        GUILayout.EndVertical();
        GUILayout.EndVertical();
    }
Exemple #35
0
    private void Activate_Option(int i_option_num, int i_button_level)
    {
        if (i_option_num >= 0)
        {
            selected_int = i_option_num;
        }

        if (i_button_level == menu_level)
        {
            if (menu_level == 0) // Main menu actions
            {
                OPTIONS option = (OPTIONS)selected_int;
                switch (option)
                {
                case OPTIONS.PLAY:
                {
                    if (seed_text.text == "")
                    {
                        ds.world_seed = UnityEngine.Random.Range(0, 99999);
                    }
                    else
                    {
                        ds.world_seed = seed_text.text.GetHashCode();
                    }

                    SceneManager.LoadScene("Main_Game");
                    break;
                }

                case OPTIONS.OPTIONS:
                {
                    menu_level = 1;
                    break;
                }

                case OPTIONS.QUIT:
                {
                    Application.Quit();
                    break;
                }
                }
            }
            else if (menu_level == 1) // Options menu actions
            {
                CONFIG option = (CONFIG)selected_int;
                switch (option)
                {
                case CONFIG.BACK:
                {
                    menu_level = 0;
                    break;
                }

                case CONFIG.WORLDTYPE:
                {
                    selected_world_type_id++;

                    if (selected_world_type_id > world_gen_presets.Length - 1)
                    {
                        selected_world_type_id = 0;
                    }
                    options_text_strings[1] = world_type_display_string_default + ": " + world_gen_presets[selected_world_type_id].name;
                    ds.world_size           = world_gen_presets[selected_world_type_id].size;
                    ds.world_gen_type       = world_gen_presets[selected_world_type_id].world_gen_type;
                    Debug.Log(options_text_strings[1]);
                    break;
                }

                case CONFIG.REACH:
                {
                    selected_reach_type_id++;

                    if (selected_reach_type_id > reach_presets.Length - 1)
                    {
                        selected_reach_type_id = 0;
                    }
                    options_text_strings[2] = reach_type_display_string_default + ": " + reach_presets[selected_reach_type_id].name;
                    ds.max_interact_reach   = reach_presets[selected_reach_type_id].reach;
                    Debug.Log(options_text_strings[2]);
                    break;
                }

                case CONFIG.SCORES:
                {
                    PlayerPrefs.DeleteAll();
                    break;
                }
                }
            }
        }
        else
        {
            menu_level = i_button_level;
        }
    }