Example #1
0
 /// <summary>
 /// Creates a new instance of the Resource class using the serialized data
 /// </summary>
 /// <param id="mt">MessageType defining the extend of deserialization which is to be performed</param>
 /// <param id="line">String array containing the serialized data</param>
 /// <param id="position">Current position in the array</param>
 /// <param id="context">Context of the serialized data, game where this INetworkSerializable object is in</param>
 /// <returns>Resource created using the provided serialized data</returns>
 public static Resource Create(MessageType mt, string[] line, ref int position, WildmenGame context)
 {
   Resource r = new Resource();
   r.Deserialize(mt, line, ref position, context);
   r.NearestTile.Assign(r);
   r.game = context;
   r.InitializeGraphics();
   return r;
 }
Example #2
0
 /// <summary>
 /// Creates a resource of given entry at given tile
 /// </summary>
 /// <param id="entry">Db entry of the resource</param>
 /// <param id="tile">Tile if the resource</param>
 /// <returns>The created resource</returns>
 public IScriptResource CreateResource(IScriptDbEntry entry, IScriptTile tile)
 {
   Resource r = new Resource();
   r.Initialize((EntryDb)entry, this, NaturePlayer, (Tile)tile);
   r.InitializeGraphics();
   SendData(Network.MakeServerMessage(MessageType.GameObjCreate, tile));
   return r;
 }
Example #3
0
    public void Generate(Random random, int players)
    {
      var terrain = new MapGenerator(random, ROUGHNESS, Width, Height, players, MAP_GEN_ATTEMPTS);
      terrain.Generate();

      if (!terrain.Valid)
      {
        Valid = false;
        return;
      }

      StartLocations = new List<Tile>();
      foreach (var position in terrain.StartLocations)
      {
        StartLocations.Add(Tiles[position.X, position.Y]);
      }

      for (int iRow = 0; iRow < Height; iRow++)
      {
        for (int iCol = 0; iCol < Width; iCol++)
        {
          Tile tile = Tiles[iCol, iRow];
          int elevation = terrain.MapElevations[iCol, iRow];
          tile.SetElevation(elevation);

          if (elevation < MapBoard.SEA_LEVEL) continue;

          foreach (var item in Db.Instance.Resources)
          {
            if (random.NextDouble() < item.Value.OccurChance)
            {
              Resource r = new Resource();
              r.Initialize(item.Value, Game, Game.NaturePlayer, tile);
              r.InitializeGraphics();
              break;
            }
          }
        }
      }

      foreach (var item in Tiles)
      {
        item.UpdateTerrainBarHeight();
      }
    }