Example #1
0
 public Hazard AddHazardIntoGame(int itemID, string hazFileName)
 {
     if (!currentHazards.ContainsKey(itemID))
     {
         if (!hazardFiles.TryGetValue(hazFileName, out HazardFile hazardFile))
         {
             hazardFile = new HazardFile(Simulator.Instance.RouteFolder.HazardFile(hazFileName));
             hazardFiles.Add(hazFileName, hazardFile);
         }
         hazards[itemID].HazFile = hazardFile;
         //based on act setting for frequency
         if (Simulator.Instance.ActivityFile != null)
         {
             if (hazards[itemID].Animal && (RandomNumberGenerator.GetInt32(100) > Simulator.Instance.ActivityFile.Activity.Header.Animals))
             {
                 return(null);
             }
         }
         else //in explore mode
         {
             if (!hazards[itemID].Animal)
             {
                 return(null);//not show worker in explore mode
             }
             if (RandomNumberGenerator.GetInt32(100) > 20)
             {
                 return(null);//show 10% animals
             }
         }
         currentHazards.Add(itemID, hazards[itemID]);
         return(hazards[itemID]);//successfully added the hazard with associated haz file
     }
     return(null);
 }
Example #2
0
 //[CallOnThread("Loader")]
 public Hazard AddHazzardIntoGame(int itemID, string hazFileName)
 {
     try
     {
         if (!CurrentHazards.ContainsKey(itemID))
         {
             if (HazFiles.ContainsKey(hazFileName))
             {
                 Hazards[itemID].HazFile = HazFiles[hazFileName];
             }
             else
             {
                 var hazF = new HazardFile(Simulator.RoutePath + "\\" + hazFileName);
                 HazFiles.Add(hazFileName, hazF);
                 Hazards[itemID].HazFile = hazF;
             }
             //based on act setting for frequency
             if (Hazards[itemID].animal == true && Simulator.Activity != null)
             {
                 if (Simulator.Random.Next(100) > Simulator.Activity.Activity.Header.Animals)
                 {
                     return(null);
                 }
             }
             else if (Simulator.Activity != null)
             {
                 if (Simulator.Random.Next(100) > Simulator.Activity.Activity.Header.Animals)
                 {
                     return(null);
                 }
             }
             else                     //in explore mode
             {
                 if (Hazards[itemID].animal == false)
                 {
                     return(null);                                                        //not show worker in explore mode
                 }
                 if (Simulator.Random.Next(100) > 20)
                 {
                     return(null);                                                        //show 10% animals
                 }
             }
             CurrentHazards.Add(itemID, Hazards[itemID]);
             return(Hazards[itemID]);                   //successfully added the hazard with associated haz file
         }
     }
     catch { }
     return(null);
 }
Example #3
0
 /// <summary>
 /// Try to load the file.
 /// Possibly this might raise an exception. That exception is not caught here
 /// </summary>
 /// <param name="file">The file that needs to be loaded</param>
 public override void TryLoading(string file)
 {
     var hazF = new HazardFile(file);
 }