コード例 #1
0
ファイル: Tile.cs プロジェクト: OCox1991/Genome
 /// <summary>
 /// Clears the tile, sets all the variables for tile contents to null, sets isBlocked to false.
 /// </summary>
 public void clearTile()
 {
     creature = null;
     plant = null;
     remains = null;
     obstacle = null;
     isBlocked = false;
 }
コード例 #2
0
ファイル: WorldState.cs プロジェクト: OCox1991/Genome
 /// <summary>
 /// Populates the world by adding plants and obstacles
 /// </summary>
 private void populateWorld()
 {
     for (int plantNum = 0; plantNum < Simulation.getPlantPopulation(); plantNum++)
     {
         int[] xy = getRandomClearTile();
         if (xy[0] == -1 && xy[1] == -1)
         {
             throw new Exception("World is full, cannot add any further content");
         }
         else
         {
             Tile t = getTile(xy[1], xy[0]);
             Plant p = new Plant(randomNumberGenerator);
             p.setLocation(xy[0], xy[1]);
             plantList.Add(p);
             t.addPlant(p);
         }
     }
     for (int obstNum = 0; obstNum < Simulation.getNumObstacles(); obstNum++)
     {
         int[] xy = getRandomClearTile();
         if (xy[0] == -1 && xy[1] == -1)
         {
             throw new Exception("World is full, cannot add any further content");
         }
         else
         {
             Tile t = getTile(xy[1], xy[0]);
             Obstacle o = new Obstacle();
             o.setLocation(xy[0], xy[1]);
             t.addObstacle(o);
         }
     }
 }
コード例 #3
0
ファイル: Tile.cs プロジェクト: OCox1991/Genome
 /// <summary>
 /// Adds a plant to the tile, sets the plant variable to the specified plant and sets the tile to be blocked
 /// </summary>
 /// <param name="c">The plant to add to the tile</param>
 public void addPlant(Plant p)
 {
     plant = p;
     isBlocked = true;
 }
コード例 #4
0
ファイル: WorldInputHandler.cs プロジェクト: OCox1991/Genome
 /// <summary>
 /// Views a plant, sets viewing to be true and sets up the information viewing commands
 /// </summary>
 /// <param name="c">The Plant to be viewed</param>
 private void viewPlant(Plant p)
 {
     viewing = true;
     maxInfo = plantMaxInfo;
     plantView = p;
 }
コード例 #5
0
ファイル: WorldInputHandler.cs プロジェクト: OCox1991/Genome
 /// <summary>
 /// Cancels views, sets viewing to be false and all the viewing variables etc. to be null
 /// </summary>
 private void deView()
 {
     viewing = false;
     creatureView = null;
     plantView = null;
     remainsView = null;
     following = false;
     dataViewed = 0;
     buttons[3].setVisible(false);
     buttons[4].setVisible(false);
     buttons[5].setVisible(false);
 }
コード例 #6
0
ファイル: WorldInputHandler.cs プロジェクト: OCox1991/Genome
 /// <summary>
 /// Gets an array of strings that contain information about the plant
 /// </summary>
 /// <param name="c">The plant to get information about</param>
 /// <returns>An array of strings containing a set of information about the plant</returns>
 public string[] getPlantInfo(Plant p)
 {
     string[] status = new string[1];
     switch (DataViewed)
     {
         case 0: status = new string[] { "Food Units Remaining: " + p.getFoodRemaining(), "Food value: " + p.getFoodValue(), "Regrows in: " + p.getTicksRemainingBeforeAction() + " ticks" }; break;
     }
     return status;
 }
コード例 #7
0
ファイル: WorldDrawer.cs プロジェクト: OCox1991/Genome
 /// <summary>
 /// Draws the plant viewing window
 /// </summary>
 /// <param name="c">The plant to draw the viewing window for</param>
 private void drawPlantView(Plant p)
 {
     drawBack();
     Simulation.getGraphicsDeviceManager().GraphicsDevice.SamplerStates[0] = SamplerState.PointWrap;
     spriteBatch.Begin(0, null, SamplerState.PointWrap, null, null);
     Rectangle r = new Rectangle((Display.getWindowWidth() - 800) / 2 + 10, Display.getWindowHeight() - 130, 120, 120);
     Texture2D tex = null;
     if(p.isDepeleted())
     {
         tex = depletedPlantTile;
     }
     else
     {
         tex = plantTile;
     }
     spriteBatch.Draw(tex, r, Color.White);
     spriteBatch.End();
     string[] status = inputHandler.getPlantInfo(p);
     Vector2 topLeft = new Vector2((Display.getWindowWidth() - 800) / 2 + 10 + 120 + 10, Display.getWindowHeight() - 130);
     string title = "Plant";
     if(p.isDepeleted())
     {
         title += " (depleted)";
     }
     drawStrings(topLeft, title, status, 4);
 }