예제 #1
0
            public void Update(VehicleUpdate vehicleUpdate)
            {
                X          = vehicleUpdate.X;
                Y          = vehicleUpdate.Y;
                Durability = vehicleUpdate.Durability;

                ShiftHistory(historyX, X);
                ShiftHistory(historyY, Y);
            }
예제 #2
0
        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();
        }
예제 #3
0
 /// <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;
 }
예제 #4
0
        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));
        }
예제 #5
0
 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);
        }
예제 #7
0
        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?
        }
예제 #8
0
        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);
        }
예제 #9
0
        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);
        }
예제 #10
0
        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.");
            //}
        }