private void AddBoosts(DroneFormation formation) { foreach (var boost in formation.Stats) { Controller.BoosterAssembly.Multiply(boost.Type, boost.Amount); } }
public void ChangeDroneFormation(DroneFormation targetFormation) { //if ( // !baseController.CooldownStorage.Finished( // objects.world.storages.playerStorages.CooldownStorage.DRONE_FORMATION_COOLDOWN)) return; //var gameSession = World.StorageManager.GetGameSession(baseController.Player.Id); //baseController.Player.Formation = targetFormation; //gameSession.Client.Send(DroneFormationChangeCommand.write(baseController.Player.Id, (int)targetFormation)); //baseController.CooldownStorage.Setup(gameSession, objects.world.storages.playerStorages.CooldownStorage.DRONE_FORMATION_COOLDOWN); //baseController.Player.Update(); }
private void MergeBoosts(DroneFormation old, DroneFormation current) { foreach (var boost in old.Stats) { var currentBoost = current.Stats.Cast <BoostView?>().FirstOrDefault(x => x.Value.Type == boost.Type); if (currentBoost != null) { double newBoost = Controller.BoosterAssembly.Get(boost.Type) / boost.Amount; Controller.BoosterAssembly.Set(boost.Type, newBoost * currentBoost.Value.Amount); } else { Controller.BoosterAssembly.Divide(boost.Type, boost.Amount); } } foreach (var boost in current.Stats) { if (!old.Stats.Any(x => x.Type == boost.Type)) { Controller.BoosterAssembly.Multiply(boost.Type, boost.Amount); } } }
public bool ChangeFormation(DroneFormation change) { long currentTime = PlayerController.CurrentClock.ElapsedMilliseconds; if (DroneFormation.ID == change.ID || _lastFormationChangeTime.FromNow(currentTime) < FORMATION_COOLDOWN) { return(false); } ; _lastFormationChangeTime = currentTime; MergeBoosts(DroneFormation, change); DroneFormation = change; _shieldChangeTickTimeFunction.Reset(); _shieldChangePerSecond = GetShieldChangePerSecond(); ICommand formationChangedCommand = PacketBuilder.DroneFormationChangeCommand(PlayerController); PlayerController.Send(formationChangedCommand); PlayerController.EntitesInRange((x) => x.Send(formationChangedCommand)); return(true); }