public void CanLaunchSingleSub() { Outpost outpost1 = new Outpost("0", new RftVector(new Rft(300, 300), 0, 0)); Outpost outpost2 = new Outpost("1", new RftVector(new Rft(300, 300), 0, 0)); outpost1.SetDrillerCount(10); outpost2.SetDrillerCount(10); int outpostOneInitial = outpost1.GetDrillerCount(); int outpostTwoInitial = outpost2.GetDrillerCount(); _game.TimeMachine.GetState().GetOutposts().Add(outpost1); _game.TimeMachine.GetState().GetOutposts().Add(outpost2); LaunchEvent launch = new LaunchEvent(new GameEventModel() { EventData = new LaunchEventData() { DestinationId = outpost2.GetId(), DrillerCount = 1, SourceId = outpost1.GetId(), }.ToByteString(), EventId = "a", EventType = EventType.LaunchEvent, OccursAtTick = 1, }); Assert.AreEqual(true, launch.ForwardAction(_game.TimeMachine, _game.TimeMachine.GetState())); // Ensure the sub was launched, outpost lost drillers, etc. Assert.AreEqual(1, _game.TimeMachine.GetState().GetSubList().Count); Assert.AreEqual(outpostOneInitial - 1, outpost1.GetDrillerCount()); }
/// <summary> /// Validates an outpost /// </summary> /// <param name="outpost">The outpost to validate</param> /// <returns>If the outpost is valid</returns> public static bool ValidateOutpost(Outpost outpost) { if (outpost == null) { return(false); } if (!Game.TimeMachine.GetState().OutpostExists(outpost)) { return(false); } if (outpost.GetDrillerCount() < 0) { return(false); } if (outpost.GetSpecialistManager() == null) { return(false); } if (outpost.GetSpecialistManager().GetSpecialistCount() < 0) { return(false); } if (outpost.GetSpecialistManager().GetSpecialistCount() > outpost.GetSpecialistManager().GetCapacity()) { return(false); } if (outpost.GetOwner() != null && !Game.TimeMachine.GetState().PlayerExists(outpost.GetOwner())) { return(false); } return(true); }
public void CannotLaunchFromNonGeneratedOutposts() { Outpost outpost1 = new Outpost("0", new RftVector(new Rft(300, 300), 0, 0)); Outpost outpost2 = new Outpost("1", new RftVector(new Rft(300, 300), 0, 0)); int outpostOneInitial = outpost1.GetDrillerCount(); int outpostTwoInitial = outpost2.GetDrillerCount(); _game.TimeMachine.GetState().GetOutposts().Add(outpost1); _game.TimeMachine.GetState().GetOutposts().Add(outpost2); LaunchEvent launch = new LaunchEvent(new GameEventModel() { EventData = new LaunchEventData() { DestinationId = outpost2.GetId(), DrillerCount = 1, SourceId = outpost1.GetId(), }.ToByteString(), EventId = "a", EventType = EventType.LaunchEvent, OccursAtTick = 1, }); Assert.AreEqual(false, launch.ForwardAction(_game.TimeMachine, _game.TimeMachine.GetState())); }
public void recruiteDrones(GameEvent gameEvent, QuantumModel model, General general, double cloudRadius) { double milsForDrone = model.milsPerDronToRecruite; int amountOfDroneToRecruite = (int)((recruiteAccumulatedTime + gameEvent.deltaTime) / milsForDrone); recruiteAccumulatedTime += gameEvent.deltaTime - amountOfDroneToRecruite * milsForDrone; if (amountOfDroneToRecruite <= 0) { return; } Outpost outpost = model.findOutpostByPosition(general.Position, 1.5 * model.cloudRadius); if (outpost == null) { return; } while (amountOfDroneToRecruite > 0) { Drone drone = findDrone(outpost, general, cloudRadius); if (drone == null) { return; } drone.Order = DroneOrder.MoveToGeneral; amountOfDroneToRecruite--; } }
public void Setup() { _p = new Player("Player 1"); List <Player> playerlist = new List <Player>(); playerlist.Add(_p); GameConfiguration config = testUtils.GetDefaultGameConfiguration(playerlist); config.MapConfiguration.OutpostsPerPlayer = 12; _game = new Game(config); _tm = _game.TimeMachine; _o1 = _tm.GetState().GetPlayerOutposts(_p)[0]; _o2 = _tm.GetState().GetPlayerOutposts(_p)[1]; _model1 = new GameEventModel() { EventData = new DrillMineEventData() { SourceId = _o1.GetComponent <IdentityManager>().GetId() }.ToByteString(), Id = Guid.NewGuid().ToString(), EventType = EventType.DrillMineEvent, OccursAtTick = 10 }; _model2 = new GameEventModel() { EventData = new DrillMineEventData() { SourceId = _o2.GetComponent <IdentityManager>().GetId() }.ToByteString(), Id = Guid.NewGuid().ToString(), EventType = EventType.DrillMineEvent, OccursAtTick = 20 }; }
public void MinimumOutpostDistanceRespected() { List <Player> players = new List <Player>(); players.Add(new Player(1)); GameConfiguration config = new GameConfiguration(players); Assert.IsNotNull(config); config.Seed = 1234; config.DormantsPerPlayer = 0; config.MaxiumumOutpostDistance = 2; config.MinimumOutpostDistance = 1; config.OutpostsPerPlayer = 2; MapGenerator generator = new MapGenerator(config); List <Outpost> generatedOutposts = generator.GenerateMap(); // Ensure the distance between outposts is over 199. Assert.AreEqual(2, generatedOutposts.Count); // Ensure the distance between the two is respected. Outpost outpost1 = generatedOutposts[0]; Outpost outpost2 = generatedOutposts[1]; float distance = (outpost1.GetCurrentPosition() - outpost2.GetCurrentPosition()).Magnitude(); Assert.IsTrue(distance > config.MinimumOutpostDistance); }
void LookForOutpost() { //Create a random index integer int r = Random.Range(0, GameManager.instance.outposts.Length); currentOutpost = GameManager.instance.outposts[r]; }
public Outpost Generate_Outpost() { if (outposts.Count >= wats_pos.Count) { return(null); } GameObject prf = Resources.Load("Prefabs/Outpost") as GameObject; GameObject new_outpost_obj = Instantiate(prf) as GameObject; int index = 0; for (int i = 0; i < wats_pos.Count; i++) { index = 0; for (; index < outposts.Count; index++) { if (outposts[index].Get_OBJ().transform.position == wats_pos[i]) { break; } } if (index == outposts.Count) { index = i; break; } } new_outpost_obj.transform.position = wats_pos[index]; Outpost new_outpost = new Outpost(new_outpost_obj); outposts.Add(new_outpost); return(new_outpost); }
public override bool ForwardAction(TimeMachine timeMachine, GameState.GameState state) { Entity drillLocation = state.GetEntity(GetEventData().SourceId); if (drillLocation != null && drillLocation is Outpost && !(drillLocation is Mine) && !((Outpost)drillLocation).GetComponent <DrillerCarrier>().IsDestroyed()) { _original = (Outpost)drillLocation; var drillerCarrier = drillLocation.GetComponent <DrillerCarrier>(); if (state.GetOutposts().Contains(_original) && !drillerCarrier.GetOwner().IsEliminated() && drillerCarrier.GetDrillerCount() >= drillerCarrier.GetOwner().GetRequiredDrillersToMine()) { _drilledMine = new Mine(_original); if (state.ReplaceOutpost(_original, _drilledMine)) { drillerCarrier.RemoveDrillers(drillerCarrier.GetOwner().GetRequiredDrillersToMine()); drillerCarrier.GetOwner().AlterMinesDrilled(1); timeMachine.AddEvent(new NeptuniumProductionEvent(_drilledMine, GetOccursAt().Advance(Mine.TICKS_PER_PRODUCTION_PER_MINE / state.GetPlayerOutposts(drillerCarrier.GetOwner()).Count))); EventSuccess = true; } } } else { EventSuccess = false; } return(EventSuccess); }
public void CannotSeeLocationOutOfVision() { Outpost outpost = new Outpost("0", new RftVector(_map, 0, 0), new Player("1"), OutpostType.Mine); Outpost outpost2 = new Outpost("1", new RftVector(_map, Constants.BASE_OUTPOST_VISION_RADIUS + 1, 0), new Player("2"), OutpostType.Mine); Assert.IsFalse(outpost.isInVisionRange(new GameTick(1), outpost2)); }
public void CanSetShields() { Outpost outpost = new Outpost(new RftVector(_map, 0, 0), new Player(1), OutpostType.Mine); outpost.SetShields(1); Assert.AreEqual(1, outpost.GetShields()); }
public void CanSetDrillerCount() { Outpost outpost = new Outpost(new RftVector(_map, 0, 0), new Player(1), OutpostType.Mine); outpost.SetDrillerCount(420); Assert.AreEqual(420, outpost.GetDrillerCount()); }
public QuantumModel initializeMap(double width, double height) { QuantumModel model = new QuantumModel(width, height); General greenGeneral = createGeneral(model, new Vector(50, height / 2), Team.green); General blueGeneral = createGeneral(model, new Vector(width - 50, height / 2), Team.blue); Outpost outpostGreen = createOutpost(model, new Vector(700, 135)); Outpost outpostBlue = createOutpost(model, new Vector(width - 700, height - 135)); createOutpost(model, new Vector(width / 2, height / 2)); createOutpost(model, new Vector(width - 250, 250)); createOutpost(model, new Vector(250, height - 250)); Drone droneGreen = createDrone(model, greenGeneral, new Vector(0, 0)); Drone droneBlue = createDrone(model, blueGeneral, new Vector(width, height)); droneGreen.TargetOutpost = outpostGreen.id; droneGreen.Order = DroneOrder.MoveToOutpost; droneBlue.TargetOutpost = outpostBlue.id; droneBlue.Order = DroneOrder.MoveToOutpost; fillGeneralWithDrones(model, greenGeneral, new Vector(0, 0), 300); fillGeneralWithDrones(model, blueGeneral, new Vector(width, height), 300); return(model); }
public void MinimumOutpostDistanceRespected() { List <Player> players = new List <Player> { new Player("1") }; GameConfiguration config = _testUtils.GetDefaultGameConfiguration(players); Assert.IsNotNull(config); Random rand = new Random(DateTime.Now.Millisecond); config.MapConfiguration.Seed = rand.Next(); config.MapConfiguration.DormantsPerPlayer = 0; config.MapConfiguration.MaximumOutpostDistance = 2; config.MapConfiguration.MinimumOutpostDistance = 1; config.MapConfiguration.OutpostsPerPlayer = 2; MapGenerator generator = new MapGenerator(config.MapConfiguration, players); List <Outpost> generatedOutposts = generator.GenerateMap(); // Ensure the distance between outposts is over 199. Assert.AreEqual(2, generatedOutposts.Count); // Ensure the distance between the two is respected. Outpost outpost1 = generatedOutposts[0]; Outpost outpost2 = generatedOutposts[1]; float distance = (outpost1.GetComponent <PositionManager>().GetPositionAt(new GameTick(0)) - outpost2.GetComponent <PositionManager>().GetPositionAt(new GameTick(0))).Magnitude(); Assert.IsTrue(distance >= config.MapConfiguration.MinimumOutpostDistance); }
/// <summary> /// Validates an outpost /// </summary> /// <param name="state">The game state</param> /// <param name="outpost">The outpost to validate</param> /// <returns>If the outpost is valid</returns> public static bool ValidateOutpost(GameState.GameState state, Outpost outpost) { if (outpost == null) { return(false); } if (!state.OutpostExists(outpost)) { return(false); } if (outpost.GetComponent <DrillerCarrier>().GetDrillerCount() < 0) { return(false); } if (outpost.GetComponent <SpecialistManager>() == null) { return(false); } if (outpost.GetComponent <SpecialistManager>().GetSpecialistCount() < 0) { return(false); } if (outpost.GetComponent <SpecialistManager>().GetSpecialistCount() > outpost.GetComponent <SpecialistManager>().GetCapacity()) { return(false); } if (outpost.GetComponent <DrillerCarrier>().GetOwner() != null && !state.PlayerExists(outpost.GetComponent <DrillerCarrier>().GetOwner())) { return(false); } return(true); }
private static void SyncedTakeItems(Outpost outpost, Caravan caravan, Dictionary <ThingDef, int> itemsToTransfer) { var dummyDialog = new Dialog_TakeItems(outpost, caravan); dummyDialog.CalculateAndRecacheTransferables(); foreach (var transferable in dummyDialog.transferables) { if (transferable.HasAnyThing && itemsToTransfer.TryGetValue(transferable.ThingDef, out var count)) { transferable.ForceTo(count); } while (transferable.HasAnyThing && transferable.CountToTransfer > 0) { var thing = transferable.things.Pop(); if (thing.stackCount <= transferable.CountToTransfer) { transferable.AdjustBy(-thing.stackCount); caravan.AddPawnOrItem(thing, true); } else { caravan.AddPawnOrItem(thing.SplitOff(transferable.CountToTransfer), true); transferable.AdjustTo(0); transferable.things.Add(thing); } } } }
public void MergeFrom(ClientMapPoi other) { if (other == null) { return; } if (other.Id.Length != 0) { Id = other.Id; } if (other.Name.Length != 0) { Name = other.Name; } if (other.Latitude != 0D) { Latitude = other.Latitude; } if (other.Longitude != 0D) { Longitude = other.Longitude; } if (other.Description.Length != 0) { Description = other.Description; } if (other.PoiAccessibility != 0) { PoiAccessibility = other.PoiAccessibility; } switch (other.TypeCase) { case TypeOneofCase.Outpost: if (Outpost == null) { Outpost = new global::WUProtos.Data.Client.ClientMapOutpost(); } Outpost.MergeFrom(other.Outpost); break; case TypeOneofCase.Fortress: if (Fortress == null) { Fortress = new global::WUProtos.Data.Client.ClientMapFortress(); } Fortress.MergeFrom(other.Fortress); break; case TypeOneofCase.Greenhouse: if (Greenhouse == null) { Greenhouse = new global::WUProtos.Data.Client.ClientMapGreenhouse(); } Greenhouse.MergeFrom(other.Greenhouse); break; } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); }
public void HandleRequest(IRequest request) { Message.Builder.FromRequest(request) .WithData(new Dictionary <string, object> { { k.data, Outpost.GetOwnershipInfo() } }) .Send(); }
void LookForOutpost() { //We get an integer ranging from 0 until the total amount of outposts //Regardless of the amount of outposts we have, this can be used to select a random one int r = Random.Range(0, GameManager.instance.outposts.Length); currentOutpost = GameManager.instance.outposts[r]; }
public void Setup() { _map = new Rft(3000, 3000); _location = new RftVector(_map, 0, 0); _outpost = new Generator("0", _location, new Player("1")); _tick = new GameTick(10); _sub = new Sub("0", _outpost, _outpost, _tick, 0, new Player("1")); }
public void CanToggleSheilds() { Outpost outpost = new Outpost(new RftVector(_map, 0, 0), new Player(1), OutpostType.Mine); bool initialState = outpost.IsShieldActive(); outpost.ToggleShield(); Assert.AreEqual(!initialState, outpost.IsShieldActive()); }
public void CanAddDrillers() { Outpost outpost = new Outpost(new RftVector(_map, 0, 0), new Player(1), OutpostType.Mine); int initialDrillers = outpost.GetDrillerCount(); outpost.AddDrillers(40); Assert.AreEqual(initialDrillers + 40, outpost.GetDrillerCount()); }
public void CanRemoveDrillers() { Outpost outpost = new Outpost("0", new RftVector(_map, 0, 0), new Player("1"), OutpostType.Mine); int initialDrillers = outpost.GetDrillerCount(); outpost.RemoveDrillers(40); Assert.AreEqual(initialDrillers - 40, outpost.GetDrillerCount()); }
public void CanAddShields() { Outpost outpost = new Outpost(new RftVector(_map, 0, 0), new Player(1), OutpostType.Mine); int initialShield = outpost.GetShields(); outpost.AddShield(1); Assert.AreEqual(initialShield + 1, outpost.GetShields()); }
public void Setup() { this._map = new Rft(3000, 3000); this._outpostLocation = new RftVector(_map, 0, 0); this._outpostLocation = new RftVector(_map, 15, 15); this._outpost = new Factory("0", _outpostLocation, new Player("1")); this._outpost2 = new Factory("1", _outpostLocation, new Player("1")); }
/* TODO LIST: * - sometimes is better to not do anything */ public void Initialize(List <Line> lines, GoldController goldController, Outpost outpost) { _lines = lines; aiUnitScanner.Initialize(lines); _goldController = goldController; _outpost = outpost; _unitSpawner = GetComponent <UnitSpawner>(); }
public void CanSeeLocationInVisionRange() { RftVector currentLocation = _sub.GetCurrentPosition(new GameTick(1)); RftVector insideVisionRange = new RftVector(currentLocation.X + _sub.getVisionRange() - 1, currentLocation.Y); Outpost insideRange = new Outpost("0", insideVisionRange, new Player("1"), OutpostType.Generator); Assert.IsTrue(_sub.isInVisionRange(new GameTick(1), insideRange)); }
public void CanNotSeeLocationOutsideVisionRange() { RftVector currentLocation = _sub.GetCurrentPosition(new GameTick(1)); RftVector outsideVisionRange = new RftVector(currentLocation.X + _sub.getVisionRange() + 1, currentLocation.Y); Outpost outsideRange = new Outpost("0", outsideVisionRange, new Player("1"), OutpostType.Generator); Assert.IsFalse(_sub.isInVisionRange(new GameTick(1), outsideRange)); }
public override void Die() { base.Die(); SetState(State_Dead()); _Agent.isStopped = true; _Agent.ResetPath(); _TargetOutpost = null; Destroy(GetComponent <Collider>()); }
public void Setup() { _map = new Rft(3000, 3000); _location = new RftVector(_map, 0, 0); _outpost = new Outpost(_location, new Player(1), OutpostType.Generator); _tick = new GameTick(DateTime.Now, 10); _sub = new Sub(_outpost, _outpost, _tick, 0, new Player(1)); Game server = new Game(); }
private IEnumerator OnMovingToOutpost () { agent.SetDestination (currentOutpost.transform.position); while (!(currentOutpost.team == team && currentOutpost.currentValue == 1)) { LookForEnemies(); yield return null; } currentOutpost = null; SetState (State.Idle); }
private void LookForOutposts () { int r = Random.Range (0, GameManager.instance.outposts.Length); currentOutpost = GameManager.instance.outposts [r]; }
void OnOutpostFound(Outpost targetOutpost) { }