public void WhenEngagedNotSetShouldBattle() { // Fixture setup Config.Instance.IsEngageEnabled = false; var memory = new FakeMemoryAPI(); var player = FindPlayer(); player.Status = Status.Standing; memory.Player = player; var stateMemory = new StateMemory(memory) { Target = FindUnit(), IsFighting = true }; var sut = new BattleState(stateMemory); // Exercise system var result = sut.Check(); // Verify outcome Assert.True(result); // Teardown }
public void WithNonValidUnitShouldNotBattle() { // Fixture setup Config.Instance.IsEngageEnabled = false; var memory = new FakeMemoryAPI { Player = FindPlayer() }; var stateMemory = new StateMemory(memory) { Target = FindNonValidUnit(), IsFighting = true }; var sut = new BattleState(stateMemory); // Exercise system var result = sut.Check(); // Verify outcome Assert.False(result); // Teardown }
public void WhenInjuredShouldntBattle() { // Fixture setup var player = FindPlayer(); player.HPPCurrent = 25; Config.Instance.LowHealth = 50; Config.Instance.HighHealth = 100; Config.Instance.IsHealthEnabled = true; player.Status = Status.Standing; Config.Instance.IsEngageEnabled = false; var memory = new FakeMemoryAPI { Player = player }; var stateMemory = new StateMemory(memory) { Target = FindUnit(), IsFighting = false }; var sut = new BattleState(stateMemory); UnitService.Units = new List <IUnit>(); // Exercise system var result = sut.Check(); // Verify outcome Assert.False(result); // Teardown }
public void WithInvalidTargetShouldntBattle() { // Fixture setup var player = FindPlayer(); player.Status = Status.Standing; Config.Instance.IsEngageEnabled = false; var memory = new FakeMemoryAPI { Player = player }; var stateMemory = new StateMemory(memory) { Target = FindNonValidUnit(), IsFighting = true }; var sut = new BattleState(stateMemory); UnitService.Units = new List <IUnit>(); // Exercise system var result = sut.Check(); // Verify outcome Assert.False(result); // Teardown }
private static ZoneState CreateSut(StateMemory stateMemory, Action zoningAction = null) { var sut = new ZoneState(stateMemory); sut.ZoningAction = zoningAction ?? sut.ZoningAction; return(sut); }
public GameContext(IMemoryAPI api) { API = api; Player = new Player(api); Config = new ProxyConfig(); Memory = new StateMemory(api); Target = new NullUnit(); }
public GameContext(IMemoryAPI api) { API = api; Player = new Player(api); Config = new ProxyConfig(); Memory = new StateMemory(api); Target = new NullUnit(); NavMesh = new NavMesh(); Zone = api.Player.Zone; NavMesh.LoadZone(_zone); }
public TestContext() { Units = new List <IUnit> { new MockUnit() }; Config = new MockConfig(); Player = new MockPlayer(); Target = new NullUnit(); MockAPI = new MockEliteAPI(); API = new MockEliteAPIAdapter(MockAPI); Memory = new StateMemory(API); }
public void WhenNotFightingShouldntBattle() { // Fixture setup MockConfig.IsEngageEnabled = false; StateMemory memory = CreateStateMemory(); memory.Target = FindUnit(); memory.IsFighting = false; BattleState sut = new BattleState(memory); // Exercise system bool result = sut.Check(); // Verify outcome Assert.False(result); // Teardown }
public void WhenEngagedSetAndEngagedShouldBattle() { // Fixture setup MockConfig.IsEngageEnabled = true; MockEliteAPI.Player.Status = Status.Fighting; StateMemory memory = CreateStateMemory(); memory.Target = FindUnit(); memory.IsFighting = true; BattleState sut = new BattleState(memory); // Exercise system bool result = sut.Check(); // Verify outcome Assert.True(result); // Teardown }
public void WithInvalidTargetShouldntBattle() { // Fixture setup StateMemory memory = CreateStateMemory(targetValid: false); memory.Target = FindNonValidUnit(); memory.IsFighting = true; MockEliteAPI.Player.Status = Status.Standing; MockConfig.IsEngageEnabled = false; BattleState sut = new BattleState(memory); // Exercise system bool result = sut.Check(); // Verify outcome Assert.False(result); // Teardown }
public void WhenInjuredShouldntBattle() { // Fixture setup StateMemory memory = CreateStateMemory(); memory.Target = FindUnit(); memory.IsFighting = false; MockEliteAPI.Player.HPPCurrent = 25; MockEliteAPI.Player.Status = Status.Standing; MockConfig.LowHealth = 50; MockConfig.HighHealth = 100; MockConfig.IsHealthEnabled = true; MockConfig.IsEngageEnabled = false; BattleState sut = new BattleState(memory); // Exercise system bool result = sut.Check(); // Verify outcome Assert.False(result); // Teardown }
// Use this for initialization void Start() { List <int> scores = StateMemory.GetBestScoresFromFile(); // Add current score in list scores.Add(GameState.CurrentScore); // Sort List scores.Sort(); // Sort by Desc scores.Reverse(); // Order by Asc // Remove worst scores if (scores.Count > 5) { while (scores.Count > 5) { scores.RemoveAt(scores.Count - 1); } } // Save scores in file StateMemory.BestScores = scores; StateMemory.WriteBestScoresInFile(); // Changing the music AudioManager.Instance.PlayMusic("Death", false); // Saving money into file GainMoney(); // Print the bests scores on screen if (StateMemory.BestScores.Count > 0) { for (int i = 0; i < StateMemory.BestScores.Count; i++) { bestScoresHolders[i].gameObject.SetActive(true); bestScoresHolders[i].text = (i + 1) + " score : " + StateMemory.BestScores[i].ToString(); } } }