public void Update(VehicleUpdate vehicleUpdate) { X = vehicleUpdate.X; Y = vehicleUpdate.Y; Durability = vehicleUpdate.Durability; ShiftHistory(historyX, X); ShiftHistory(historyY, Y); }
public void Update(VehicleUpdate vehicleUpdate) { X = vehicleUpdate.X; Y = vehicleUpdate.Y; Groups = vehicleUpdate.Groups ?? new int[0]; Durability = vehicleUpdate.Durability; IsSelected = vehicleUpdate.IsSelected; RemainingAttackCooldownTicks = vehicleUpdate.RemainingAttackCooldownTicks; Update(); }
/// <summary> /// Обновление изменяемых данных юнита /// </summary> /// <param name="vehicleUpdate"></param> public void Update(VehicleUpdate vehicleUpdate) { Direction = new Point(vehicleUpdate.X, vehicleUpdate.Y) - new Point(X, Y); X = vehicleUpdate.X; Y = vehicleUpdate.Y; Position.X = X; Position.Y = Y; TerrainType = Global.World.TerrainByCellXY[(int)Math.Floor(X / 32)][(int)Math.Floor(Y / 32)]; WeatherType = Global.World.WeatherByCellXY[(int)Math.Floor(X / 32)][(int)Math.Floor(Y / 32)]; Durability = vehicleUpdate.Durability; }
public async Task <HttpResponseMessage> PutVehicle(int vehicleId) { var streamProvider = new MultipartFormDataStreamProvider(Path.GetTempPath()); await Request.Content.ReadAsMultipartAsync(streamProvider); using (var update = new VehicleUpdate(vehicleId, streamProvider)) { updateVehicle.Execute(1, update, update.Photo); } return(Request.CreateResponse(HttpStatusCode.OK)); }
internal void Update(VehicleUpdate update) { if (Position.X != update.X && Position.Y != update.Y) { visionFactor = MyStrategy.TerranTypes[MyStrategy.Terrains[(int)update.X / 32][(int)update.Y / 32]]; VisionRange = visionRange * visionFactor; } Position = new Vector(update.X, update.Y); Durability = update.Durability; Groups = update.Groups; IsSelected = update.IsSelected; }
public async Task<HttpResponseMessage> PutVehicle(int vehicleId) { var streamProvider = new MultipartFormDataStreamProvider(Path.GetTempPath()); await Request.Content.ReadAsMultipartAsync(streamProvider); using (var update = new VehicleUpdate(vehicleId, streamProvider)) { updateVehicle.Execute(1, update, update.Photo); } return Request.CreateResponse(HttpStatusCode.OK); }
private static void ReplaceWithUpdate(List <Vehicle> units, Vehicle unit, VehicleUpdate update) { var newUnit = new Vehicle(unit, update); units.Remove(unit); if (update.Durability != 0) //Note: Dead or not visible units are removed from the list! { units.Add(newUnit); } // TODO if (UnitAliveButNotVisible) units.Add(newUnit); // TODO For dead units position is 0, for for the hidden ones? }
private VehicleUpdate[] ReadVehicleUpdates() { int vehicleUpdateCount = ReadInt(); if (vehicleUpdateCount < 0) { return(null); } VehicleUpdate[] vehicleUpdates = new VehicleUpdate[vehicleUpdateCount]; for (int vehicleUpdateIndex = 0; vehicleUpdateIndex < vehicleUpdateCount; ++vehicleUpdateIndex) { vehicleUpdates[vehicleUpdateIndex] = ReadVehicleUpdate(); } return(vehicleUpdates); }
private void WriteVehicleUpdate(VehicleUpdate vehicleUpdate) { if (vehicleUpdate == null) { WriteBoolean(false); return; } WriteBoolean(true); WriteLong(vehicleUpdate.Id); WriteDouble(vehicleUpdate.X); WriteDouble(vehicleUpdate.Y); WriteInt(vehicleUpdate.Durability); WriteInt(vehicleUpdate.RemainingAttackCooldownTicks); WriteBoolean(vehicleUpdate.IsSelected); WriteInts(vehicleUpdate.Groups); }
private void UpdateUnitsStatus(World world) { var playerMy = world.GetMyPlayer(); var playerOpp = world.GetOpponentPlayer(); foreach (var venicle in world.NewVehicles) { var currentVenicleUpdate = world.VehicleUpdates.FirstOrDefault(u => u.Id == venicle.Id); if (currentVenicleUpdate == null) { currentVenicleUpdate = new VehicleUpdate( venicle.PlayerId, venicle.X, venicle.Y, venicle.Durability, venicle.RemainingAttackCooldownTicks, venicle.IsSelected, venicle.Groups); } if (venicle.PlayerId == playerMy.Id) { UnitsMy.Add(new Vehicle(venicle, currentVenicleUpdate)); } if (venicle.PlayerId == playerOpp.Id) { UnitsOpp.Add(new Vehicle(venicle, currentVenicleUpdate)); } } ReplaceUnitWithUpdate(world, UnitsMy); //foreach (var unit in UnitsMy) //{ // if (unit.X < 0.1) throw new Exception("0 coordinate! Dead warrior!"); //} ReplaceUnitWithUpdate(world, UnitsOpp); //foreach (var unit in UnitsOpp) //{ // if (unit.X < 0.1) throw new Exception("0 coordinate! Dead enemy in the list."); //} }