예제 #1
0
 public LocationContainer(Scripting.IMover mover, World.NavMeshes.NavMesh navMesh)
 {
     this.mover   = mover;
     this.navMesh = navMesh;
     bugAI        = new Input.BugAI(mover, navMesh, this);
     locations    = new List <Location>(Globals.LocationCount);
     for (int i = 0; i < Globals.LocationCount; i++)
     {
         locations.Add(new Location(false, false, false, false));
     }
     playerLocationId   = 0;
     bugLocations       = new Dictionary <int, int>();
     waveConfigurations = WaveBuilder.DefaultWaves();
     ResetGame();
 }
예제 #2
0
        public void Feed(int[] configuration)
        {
            // load in 30 locations from a file, memory array, stream, etc.
            // Can store each location in a byte, or in a word, integer, etc.
            // Using int for now, even though it might waste space.  Will make adding new object
            // types easy in the future.
            bugAI = null;
            bugAI = new Input.BugAI(mover, navMesh, this);
            int bugsAdded = 0;

            bugLocations = null;
            bugLocations = new Dictionary <int, int>();
            // do NOT reset the player location!
            if (configuration.Length == Globals.LocationCount)
            {
                for (int i = 0; i < Globals.LocationCount; i++)
                {
                    int  locationConfig = configuration[i];
                    bool isPlayer;
                    bool isBug;
                    if (i != playerLocationId)
                    {
                        // avoid teleporting the player or obliterating him completely:
                        isPlayer = (0 != (locationConfig & (int)GameObjectTypes.Player));
                        // avoid spawn-killing the player with a newly spawned bug:
                        isBug = (0 != (locationConfig & (int)GameObjectTypes.Bug));
                    }
                    else
                    {
                        isPlayer = true;
                        isBug    = false;
                    }
                    bool     isBerry    = (0 != (locationConfig & (int)GameObjectTypes.Berry));
                    bool     isSunblock = (0 != (locationConfig & (int)GameObjectTypes.Sunblock));
                    Location loc        = new Location(isPlayer, isBerry, isSunblock, isBug);
                    if (isBug)
                    {
                        bugsAdded++;
                        bugLocations.Add(bugsAdded, i);
                        bugAI.AddBug(bugsAdded);
                    }
                    locations[i] = loc;
                }
            }
        }