/// <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; }
/// <summary> /// Creates a unit of given entry at given position with given owner /// </summary> /// <param id="entry">Db entry of the unit</param> /// <param id="position">Position if the unit</param> /// <param id="owner">Owner of the unit</param> /// <returns>The created unit</returns> public IScriptUnit CreateUnit(IScriptDbEntry entry, Vector2 position, IScriptPlayer owner) { Unit u = new Unit(); u.Initialize((EntryDb)entry, this, (Player)owner, position); u.InitializeGraphics(); u.CancelOrders(); SendData(Network.MakeServerMessage(MessageType.GameObjCreate, u)); return u; }
/// <summary> /// Creates a building of given entry at given tile with given owner /// </summary> /// <param id="entry">Db entry of the building</param> /// <param id="tile">Tile if the building</param> /// <param id="owner">Owner of the building</param> /// <returns>The created building</returns> public IScriptBuilding CreateBuilding(IScriptDbEntry entry, IScriptTile tile, IScriptPlayer owner) { Building bldg = new Building(); bldg.Initialize((EntryDb)entry, this, (Player)owner, (Tile)tile); bldg.InitializeGraphics(); SendData(Network.MakeServerMessage(MessageType.GameObjCreate, bldg)); return bldg; }
/// <summary> /// Sets the DbEntry for this building /// </summary> /// <param id="newEntry">New DbEntry for this building</param> public void SetDbEntry(IScriptDbEntry newEntry) { BuildingDb newEntryCast = newEntry as BuildingDb; if (newEntryCast == null) return; entry = newEntryCast; game.SendData(Network.MakeServerMessage(MessageType.GameObjEntryUpdate, this)); }
/// <summary> /// Gets unit capacity for given class of units /// </summary> /// <param id="unitType">IScriptDbEntry the unit class will be determined from</param> /// <returns>Capacity for the unit of IScriptDbEntry class this player has</returns> public int GetUnitClassCapacity(IScriptDbEntry unitType) { if (GameObjectListModified || PopLimits == null) { UpdateUnitCounts(); } return PopLimits[((UnitDb)unitType).UnitGroup].capacity; }
/// <summary> /// Gets unit count for given type of unit /// </summary> /// <param id="unitType">IScriptDbEntry of the unit</param> /// <returns>Number of the IScriptDbEntry this player has</returns> public int GetUnitCount(IScriptDbEntry unitType) { return Units.Count(p => p.Entry == unitType); }
/// <summary> /// Sets the resource stockpile for target resource type /// </summary> /// <param id="resourceType">Resource type IScriptDbEntry</param> /// <param id="newAmount">New amount of the resource type</param> public void SetResourceAmount(IScriptDbEntry resourceType, int newAmount) { if (newAmount < 0) newAmount = 0; ResourceStockpiles[(ResourceDb)resourceType] = newAmount; }
/// <summary> /// Gets the resource stockpile for target resource type /// </summary> /// <param id="resourceType">Resource type IScriptDbEntry</param> /// <returns>Amount of available IScriptDbEntry this player has</returns> public int GetResourceAmount(IScriptDbEntry resourceType) { return ResourceStockpiles[(ResourceDb)resourceType]; }