private Player GetPlayerWithHighestUnitCountInZone(MapZoneInfo ActiveZone) { List<UnitMap> ListReturnUnit = new List<UnitMap>(); Player FinalPlayer = null; for (int P = ListPlayer.Count - 1; P >= 0; --P) { List<UnitMap> ListCurrentPlayerUnitInZone = ActiveZone.UpdateZoneForPlayer(ListPlayer[P]); if (ListCurrentPlayerUnitInZone.Count > ListReturnUnit.Count) { ListReturnUnit = ListCurrentPlayerUnitInZone; FinalPlayer = ListPlayer[P]; } } return FinalPlayer; }
private void LoadMap(bool BackgroundOnly = false) { ListTileSet = new List <Texture2D>(); FileStream FS = new FileStream("Content/Maps/World Maps/" + BattleMapPath + ".pem", FileMode.Open, FileAccess.Read); BinaryReader BR = new BinaryReader(FS, Encoding.UTF8); BR.BaseStream.Seek(0, SeekOrigin.Begin); //Map parameters. MapName = Path.GetFileNameWithoutExtension(BattleMapPath); LoadProperties(BR); ListMapScript = MapScript.LoadMapScripts(BR, DicMapEvent, DicMapCondition, DicMapTrigger, out ListMapEvent); LoadTilesets(BR); LoadMapGrid(BR); int MapZoneCount = BR.ReadInt32(); for (int Z = 0; Z < MapZoneCount; Z++) { MapZoneInfo ActiveZone = new MapZoneInfo(); ListZone.Add(ActiveZone); ActiveZone.Name = BR.ReadString(); ActiveZone.NumberOfUnitsRequired = BR.ReadInt32(); byte ColorRed = BR.ReadByte(); byte ColorGreen = BR.ReadByte(); byte ColorBlue = BR.ReadByte(); ActiveZone.Color = System.Drawing.Color.FromArgb(255, ColorRed, ColorGreen, ColorBlue); int ListZoneTileCount = BR.ReadInt32(); for (int T = 0; T < ListZoneTileCount; T++) { float PointX = BR.ReadSingle(); float PointY = BR.ReadSingle(); float PointZ = BR.ReadSingle(); ActiveZone.ListZoneTile.Add(new Vector3(PointX, PointY, PointZ)); } } FS.Close(); BR.Close(); }
public override void Save(string FilePath) { //Create the Part file. FileStream FS = new FileStream(FilePath, FileMode.Create, FileAccess.Write); BinaryWriter BW = new BinaryWriter(FS); SaveProperties(BW); SaveSpawns(BW); MapScript.SaveMapScripts(BW, ListMapScript); SaveTilesets(BW); BW.Write(ListLayer.Count); foreach (MapLayer ActiveLayer in ListLayer) { ActiveLayer.Save(BW); } BW.Write(ListZone.Count); for (int Z = 0; Z < ListZone.Count; Z++) { MapZoneInfo ActiveZone = ListZone[Z]; BW.Write(ActiveZone.Name); BW.Write(ActiveZone.NumberOfUnitsRequired); BW.Write(ActiveZone.Color.R); BW.Write(ActiveZone.Color.G); BW.Write(ActiveZone.Color.B); BW.Write(ActiveZone.ListZoneTile.Count); for (int T = 0; T < ActiveZone.ListZoneTile.Count; T++) { BW.Write(ActiveZone.ListZoneTile[T].X); BW.Write(ActiveZone.ListZoneTile[T].Y); BW.Write(ActiveZone.ListZoneTile[T].Z); } } FS.Close(); BW.Close(); }