Пример #1
0
        public void CreatePressetsFromFile()
        {
            char[] archDelim      = { '\n' };
            char[] semicolonDelim = { ';' };
            char[] guionDelim     = { '-' };
            char[] comaDelim      = { ',' };

            //Get File from Class FileReader
            string[] dataRooms = FileTextEditor.ReadFileText().Split(archDelim, System.StringSplitOptions.RemoveEmptyEntries);

            for (int i = 0; i < dataRooms.Length; i++)
            {
                string[]    row         = dataRooms[i].Split(semicolonDelim, System.StringSplitOptions.RemoveEmptyEntries);
                RoomPresset RoomPresset = ScriptableObject.CreateInstance <RoomPresset>();

                int.TryParse(row[0], out RoomPresset.RoomImage);
                int.TryParse(row[1], out RoomPresset.RoomStars);
                RoomPresset.RoomName  = row[2];
                RoomPresset.UsserName = row[3];

                int.TryParse(row[4], out RoomPresset.ItemsInRoom);

                // WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
                RoomPresset.ItemsRoom = new GameObject[RoomPresset.ItemsInRoom];

                string[] _items = row[5].Split(comaDelim, System.StringSplitOptions.RemoveEmptyEntries);


                for (int j = 0; j < RoomPresset.ItemsInRoom; j++)
                {
                    string[] _itemsArray = _items[j].Split(guionDelim, System.StringSplitOptions.RemoveEmptyEntries);

                    RoomPresset.ItemsRoom[j] = GameItems(_itemsArray[0])[int.Parse(_itemsArray[1])];
                }

                // WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
                RoomPresset.ItemsPosition = new Vector2[RoomPresset.ItemsInRoom];
                string[] _itemsPositionSeparation = row[6].Split(comaDelim, System.StringSplitOptions.RemoveEmptyEntries);
                for (int j = 0; j < RoomPresset.ItemsInRoom; j++)
                {
                    string[] _itemsPosition = _itemsPositionSeparation[j].Split(guionDelim, System.StringSplitOptions.RemoveEmptyEntries);
                    RoomPresset.ItemsPosition[j].x = float.Parse(_itemsPosition[0]);
                    RoomPresset.ItemsPosition[j].y = float.Parse(_itemsPosition[1]);
                }

                // WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
                RoomPresset.ItemsRotation = new int[RoomPresset.ItemsInRoom];
                string[] _itemsRotationSeparation = row[7].Split(comaDelim, System.StringSplitOptions.RemoveEmptyEntries);
                for (int j = 0; j < RoomPresset.ItemsInRoom; j++)
                {
                    int.TryParse(_itemsRotationSeparation[j], out RoomPresset.ItemsRotation[j]);
                }

                RoomPresset.RoomPassword = row[8];
                GameController.RoomPressetList.Add(RoomPresset);
            }
        }
Пример #2
0
        public void CreateInstanceScriptable()
        {
            RoomPresset RoomPresset = ScriptableObject.CreateInstance <RoomPresset>();

            RoomPresset.RoomName              = RoomName.text;
            RoomPresset.RoomPassword          = RoomPassword.text;
            RoomPresset.UsserName             = GameController.UsserID;
            RoomPresset.RoomWidth             = ConvertSizeRoom(Mathf.RoundToInt(RoomWidth.value));
            RoomPresset.RoomHeigh             = ConvertSizeRoom(Mathf.RoundToInt(RoomHeigh.value));
            GameController.CreatorRoomPresset = RoomPresset;
        }
Пример #3
0
 public void DeleteButtons(RoomPresset _roomPresset)
 {
     for (int i = 0; i < GameController.RoomPressetList.Count; i++)
     {
         if (GameController.RoomPressetList[i] == _roomPresset)
         {
             GameController.RoomPressetList.RemoveAt(i);
             break;
         }
     }
     ResetButtons();
 }