예제 #1
0
        public DatabaseServerModel(
            string envPath,
            string provider,
            EnvironmentTypes env,
            string envId,
            DatabaseTypes dbType,
            bool createNew = true,
            string oldID   = "")
        {
            var dbDescription = Enum.GetName(typeof(DatabaseTypes), dbType);

            if (createNew)
            {
                var dbID = GenerateID();

                _DBPath       = envPath + "/" + dbDescription + "/" + dbID + ".mdb";
                _DBFolderPath = envPath + "/" + dbDescription;
                _ID           = dbID;
                _DBType       = dbType;

                // Write to file
                Directory.CreateDirectory(envPath + "/" + dbDescription);
                var mdb = "{" +
                          "\"type\": \"" + dbDescription + "\"" +
                          "}";
                File.WriteAllText(_DBPath, mdb);
                Console.WriteLine("Successfully created database");
            }
            else
            {
                _DBPath = envPath; // + "/" + dbDescription + "/" + oldID + ".mdb";
                _ID     = oldID;
                _DBType = dbType;
            }
        }
예제 #2
0
        /// <summary>
        /// Loads existing databses
        /// </summary>
        /// <param name="basePath">Database path</param>
        /// <param name="provider">Provider name</param>
        /// <param name="env">Environment type</param>
        /// <param name="eId">Envinronment ID</param>
        /// <param name="vId">VM ID</param>
        private void LoadDatabases(
            string basePath,
            string provider,
            EnvironmentTypes env,
            string eId = "",
            string vId = "")
        {
            {
                string   environment = Enum.GetName(typeof(EnvironmentTypes), env);
                string[] names       = Directory.GetDirectories(basePath + "/" + provider + "/" + environment + "/" + eId);

                foreach (string x in names)
                {
                    string[] xArr = x.Split('/');
                    string   xf   = xArr[xArr.Length - 1];
                    if ((xf.ToLower().IndexOf("sql") > -1))
                    {
                        string   fileName  = basePath + "/" + provider + "/" + environment + "/" + eId + "/" + xf;
                        string[] fileNames = Directory.GetFiles(fileName);

                        foreach (string fn in fileNames)
                        {
                            string[]            fnArr  = fn.Split('/');
                            string              fnf    = fnArr[fnArr.Length - 1];
                            DatabaseTypes       dbType = WhichDatabase(xf);
                            DatabaseServerModel db     = new DatabaseServerModel(fn, provider, env, eId, dbType, false, fnf.Replace(".mdb", ""));

                            _Databases.Add(db);
                        }
                    }
                }
            }
        }
예제 #3
0
 public Boolean DefaultChecker(EnvironmentTypes type)
 {
     if (type.Equals(EnvironmentTypes.Default))
     {
         return(true);
     }
     return(false);
 }
예제 #4
0
 public Tile(EnvironmentTypes evType, int numberCrowns, bool fSpace, string tileImgName, int x, int y, int width, int height, int tileNum)
 {
     envType         = evType;
     numCrowns       = numberCrowns;
     filledSpace     = fSpace;
     tileName        = tileImgName;
     tileNumber      = tileNum;
     positionAndSize = new Rectangle(x, y, width, height);
 }
예제 #5
0
 public static IEnvironmentGenerator Create(EnvironmentTypes envType)
 {
     switch (envType)
     {
     case EnvironmentTypes.Future:
     // WHEN EnvironmentGeneratorFuture HAS BEEN IMPLEMENTED, UNCOMMENT THE BELOW LINE
     // return new EnvironmentGeneratorFuture();
     case EnvironmentTypes.Medieval:
     // WHEN EnvironmentGeneratorMedieval HAS BEEN IMPLEMENTED, UNCOMMENT THE BELOW LINE
     // return new EnvironmentGeneratorMedieval();;
     default:
         throw new ArgumentException($"No class corresponding to environment type {envType} is available.");
     }
 }
예제 #6
0
        /// <summary>
        /// Find the environment array based off the selected environment type
        /// </summary>
        /// <param name="environmentType"></param>
        /// <returns></returns>
        public Sprite[] BackgroundType(EnvironmentTypes environmentType)
        {
            switch (environmentType)
            {
            case EnvironmentTypes.CityNight:
                return(this.CityNightBackground);

            case EnvironmentTypes.CityDay:
                return(this.CityDayBackground);

            case EnvironmentTypes.CitySunset:
                return(this.CitySunsetBackground);

            default:
                throw new System.Exception(string.Format("Invalid: {0} has not been set properly in the BackgroundType property.", environmentType.ToString()));
            }
        }
예제 #7
0
 /// <summary>
 /// Get to the End
 /// </summary>
 /// <param name="gameType"></param>
 /// <param name="environmentType"></param>
 /// <param name="levelLength"></param>
 public LevelConfig(int levelID,
                    GameTypes gameType,
                    EnvironmentTypes environmentType,
                    float levelLength,
                    float levelGapLength,
                    float startingTimeLength,
                    float bossHealthAmount,
                    float outRunSpeedAverage,
                    float collectAmount)
 {
     this.LevelID            = levelID;
     this.GameType           = gameType;
     this.EnvironmentType    = environmentType;
     this.LevelLength        = levelLength;
     this.LevelGapLength     = levelGapLength;
     this.StartingTimeLength = startingTimeLength;
     this.BossHealthAmount   = bossHealthAmount;
     this.OutRunSpeedAverage = outRunSpeedAverage;
     this.CollectAmount      = collectAmount;
 }
        public static IEnvironmentGenerator Create(EnvironmentTypes envType)
        {
            switch (envType)
            {
            case EnvironmentTypes.Future:
                return(new EnvironmentGeneratorFuture(
                           new BuildingFactoryFuture(),
                           new CreatureFactoryFuture(),
                           new WeaponFactoryFuture()));

            case EnvironmentTypes.Medieval:
                return(new EnvironmentGeneratorMedieval(
                           new BuildingFactoryMedieval(),
                           new CreatureFactoryMedieval(),
                           new WeaponFactoryMedieval()));

            default:
                throw new ArgumentException($"No class corresponding to environment type {envType} is available.");
            }
        }
예제 #9
0
        public EnvironmentModel(
            string basePath,
            string provider,
            EnvironmentTypes env,
            bool createNew = true,
            string eId     = "")
        {
            // Initialize resources
            _VirtualMachines = new List <VirtualMachineModel>();
            _Databases       = new List <DatabaseServerModel>();

            _Type = env;

            if (createNew)
            {
                string Enviroment = string.Empty;

                _ID        = GenerateID();
                Enviroment = Enum.GetName(typeof(EnvironmentTypes), env);
                _EnvPath   = basePath + "/" + provider + "/" + Enviroment + "/" + _ID;

                // Create folder for environment under provider directory
                _BaseEnvPath = basePath + "/" + provider + "/" + Enviroment;
                Directory.CreateDirectory(_BaseEnvPath);
                Directory.CreateDirectory(_EnvPath);
                Console.WriteLine("Successfully create environment {0:G} with ID: {1:G}.", Enviroment, _ID);
            }
            else
            {
                LoadVirtualMachines(basePath,
                                    provider,
                                    env,
                                    eId);
                LoadDatabases(basePath,
                              provider,
                              env,
                              eId);
            }
        }
예제 #10
0
        /// <summary>
        /// Loads virtual machines
        /// </summary>
        /// <param name="basePath">Database path</param>
        /// <param name="provider">Provider name</param>
        /// <param name="env">Environment type</param>
        /// <param name="eId">Envinronment ID</param>
        /// <param name="vId">VM ID</param>
        private void LoadVirtualMachines(
            string basePath,
            string provider,
            EnvironmentTypes env,
            string eId = "",
            string vId = "")
        {
            {
                string   environment = Enum.GetName(typeof(EnvironmentTypes), env);
                string[] names       = Directory.GetDirectories(basePath + "/" + provider + "/" + environment + "/" + eId);

                foreach (string x in names)
                {
                    string[] xArr = x.Split('/');
                    string   xf   = xArr[xArr.Length - 1];
                    if (!(xf.ToLower().IndexOf("sql") > 0))
                    {
                        string fileName = basePath + "/" + provider + "/" + environment + "/" + eId + "/" + xf + "/config.json";

                        if (File.Exists(fileName))
                        {
                            string              jsonString = File.ReadAllText(fileName);
                            MachineModel        mm         = ParseVM(jsonString);
                            VirtualMachineModel vm         = new VirtualMachineModel(
                                basePath + "/" + provider + "/" + environment + "/" + eId,
                                mm.OS,
                                mm.CPU,
                                mm.Memory,
                                false,
                                xf);

                            _VirtualMachines.Add(vm);
                        }
                    }
                }
            }
        }
예제 #11
0
    public static Assets.Scripts.World.Environment CreateEnvironment(EnvironmentGameObject eg, EnvironmentTypes type)
    {
        string   jsonString      = Resources.Load <TextAsset>("JSON/Environments/" + type).text;
        JSONNode jsonEnvironment = JSON.Parse(jsonString);

        bool isWalkable = jsonEnvironment["isWalkable"].AsBool;

        JSONArray a = jsonEnvironment["unitModifiers"].AsArray;

        var modifiers = new Dictionary <UnitTypes, float>();

        foreach (UnitTypes suit in (UnitTypes[])Enum.GetValues(typeof(UnitTypes)))
        {
            foreach (JSONNode item in a)
            {
                if (item[suit.ToString()] != null && item[suit.ToString()] != "")
                {
                    modifiers.Add(suit, item[suit.ToString()].AsFloat);
                }
            }
        }

        return(new Assets.Scripts.World.Environment(eg, isWalkable, modifiers));
    }
예제 #12
0
        public void MaxDeck(ArrayList maxDeck)
        {
            int deckSize   = 48;
            int nameIndex1 = 2;
            int nameIndex2 = 3;

            for (int i = 0; i < deckSize; i++)
            {
                EnvironmentTypes envType1       = EnvironmentTypes.Default;
                int              numCrowns1     = 0;
                bool             filledSpace1   = false;
                string           tileImageName1 = "Blank";
                int              x1             = -1;
                int              y1             = -1;
                int              width1         = -1;
                int              height1        = -1;
                EnvironmentTypes envType2       = EnvironmentTypes.Default;
                int              numCrowns2     = 0;
                bool             filledSpace2   = false;
                string           tileImageName2 = "Blank";
                int              x2             = -1;
                int              y2             = -1;
                int              width2         = -1;
                int              height2        = -1;
                tileImageName1 = "T" + (nameIndex1);
                tileImageName2 = "T" + (nameIndex2);
                if (envNamesWheatField.Contains(tileImageName1))
                {
                    envType1 = EnvironmentTypes.WheatFeild;
                }
                if (envNamesWheatField.Contains(tileImageName2))
                {
                    envType2 = EnvironmentTypes.WheatFeild;
                }
                if (envNamesLakes.Contains(tileImageName1))
                {
                    envType1 = EnvironmentTypes.Lakes;
                }
                if (envNamesLakes.Contains(tileImageName2))
                {
                    envType2 = EnvironmentTypes.Lakes;
                }
                if (envNamesMountains.Contains(tileImageName1))
                {
                    envType1 = EnvironmentTypes.Mountains;
                }
                if (envNamesMountains.Contains(tileImageName2))
                {
                    envType2 = EnvironmentTypes.Mountains;
                }
                if (envNamesForests.Contains(tileImageName1))
                {
                    envType1 = EnvironmentTypes.Forests;
                }
                if (envNamesForests.Contains(tileImageName2))
                {
                    envType2 = EnvironmentTypes.Forests;
                }
                if (envNamesVillages.Contains(tileImageName1))
                {
                    envType1 = EnvironmentTypes.Villages;
                }
                if (envNamesVillages.Contains(tileImageName2))
                {
                    envType2 = EnvironmentTypes.Villages;
                }
                if (envNamesGardens.Contains(tileImageName1))
                {
                    envType1 = EnvironmentTypes.Gardens;
                }
                if (envNamesGardens.Contains(tileImageName2))
                {
                    envType2 = EnvironmentTypes.Gardens;
                }
                if (singleCrown.Contains(tileImageName1))
                {
                    numCrowns1 = 1;
                }
                if (singleCrown.Contains(tileImageName2))
                {
                    numCrowns2 = 1;
                }
                if (doubleCrown.Contains(tileImageName1))
                {
                    numCrowns1 = 2;
                }
                if (doubleCrown.Contains(tileImageName2))
                {
                    numCrowns2 = 2;
                }
                if (tripleCrown.Contains(tileImageName1))
                {
                    numCrowns1 = 3;
                }
                if (tripleCrown.Contains(tileImageName2))
                {
                    numCrowns2 = 3;
                }
                maxDeck.Add(new Domino(new Tile(envType1, numCrowns1, filledSpace1, tileImageName1, x1, y1, width1, height1, nameIndex1),
                                       new Tile(envType2, numCrowns2, filledSpace2, tileImageName2, x2, y2, width2, height2, nameIndex2)));
                nameIndex1 += 2;
                nameIndex2 += 2;
            }
        }