public void Attack_WhenAttackingOwnArmy_ShouldThrow() { // Arrange var mockedFactory = new Mock <ICreaturesFactory>(); var mockedLogger = new Mock <ILogger>(); var mockedCreaturesInBattle = new Mock <ICreaturesInBattle>(); var battleManager = new MockedBattleManager(mockedFactory.Object, mockedLogger.Object); // The code itself should be refactored. Think about sealed class to be changed or the static method itself // You could use an unconstrained Mocking framework var identifierAttacker = CreatureIdentifier.CreatureIdentifierFromString("Angel(1)"); var identifierDefender = CreatureIdentifier.CreatureIdentifierFromString("Angel(1)"); var creature = new Angel(); mockedFactory.Setup(x => x.CreateCreature(It.IsAny <string>())).Returns(creature); mockedLogger.Setup(x => x.WriteLine(It.IsAny <string>())); battleManager.AddCreatures(identifierAttacker, 1); battleManager.AddCreatures(identifierDefender, 1); // Act and Assert Assert.Throws <ArgumentException>(() => battleManager.Attack(identifierAttacker, identifierDefender)); }
static void Main(string[] args) { Angel angel = new Angel(); Devil devil = new Devil(); Arbalester arbalester = new Arbalester(); Lich lich = new Lich(); UnitsStack stack1 = new UnitsStack(angel, 3); UnitsStack stack2 = new UnitsStack(devil, 3); UnitsStack stack3 = new UnitsStack(arbalester, 3); UnitsStack stack4 = new UnitsStack(lich, 3); List <UnitsStack> unitsStacks = new List <UnitsStack>() { stack1, stack2, stack3, stack4 }; Army usArmy = new Army(unitsStacks); List <BattleUnitsStack> battleUnitsStacks = new List <BattleUnitsStack>(); foreach (var stack in usArmy.StacksList) { battleUnitsStacks.Add(new BattleUnitsStack(stack)); } BattleArmy fbusArmy = new BattleArmy(battleUnitsStacks, "first"); BattleArmy sbusArmy = new BattleArmy(battleUnitsStacks, "second"); Battle game = new Battle(fbusArmy, sbusArmy); }
public void Attack_WhenAttackIsSucessful_ShouldCallWriteline6Times() { // Arrange var mockedFactory = new Mock <CreaturesFactory>(); var mockedLogger = new Mock <ILogger>(); var battleManager = new MockedBattleManager(mockedFactory.Object, mockedLogger.Object); // The code itself should be refactored. Think about sealed class to be changed or the static method itself // You could use an unconstrained Mocking framework var identifierAttacker = CreatureIdentifier.CreatureIdentifierFromString("Angel(1)"); var identifierDefender = CreatureIdentifier.CreatureIdentifierFromString("Angel(2)"); var creature = new Angel(); mockedFactory.Setup(x => x.CreateCreature(It.IsAny <string>())).Returns(creature); mockedLogger.Setup(x => x.WriteLine(It.IsAny <string>())); battleManager.AddCreatures(identifierAttacker, 1); battleManager.AddCreatures(identifierDefender, 1); // Act battleManager.Attack(identifierAttacker, identifierDefender); // Assert mockedLogger.Verify(x => x.WriteLine(It.IsAny <string>()), Times.Exactly(6)); }
public void AddCreature_WhenValidIdentifierIsPassed_WriteLineShouldBeCalled() { //Arrange var mockedFactory = new Mock <ICreaturesFactory>(); var mockedLogger = new Mock <ILogger>(); var battleManager = new BattleManager(mockedFactory.Object, mockedLogger.Object); //var fixture = new Fixture(); //fixture.Customizations.Add( // new TypeRelay( // typeof(Creature), // typeof(Angel))); //var cerature = fixture.Create<Creature>(); var creature = new Angel(); mockedFactory.Setup(x => x.CreateCreature(It.IsAny <string>())).Returns(creature); mockedLogger.Setup(x => x.WriteLine(It.IsAny <string>())); var identifier = CreatureIdentifier.CreatureIdentifierFromString("Angel(1)"); //Act battleManager.AddCreatures(identifier, 1); //Assert mockedLogger.Verify(x => x.WriteLine(It.IsAny <string>()), Times.Exactly(1)); }
public void Attack_WhenAttackIsSucessful_ShouldCallWriteline4Times() { // Arrange var mockedFactory = new Mock <CreaturesFactory>(); var mockedLogger = new Mock <ILogger>(); var battleManager = new MockedBattleManager(mockedFactory.Object, mockedLogger.Object); var identifierAttacker = CreatureIdentifier.CreatureIdentifierFromString("Angel(1)"); var identifierDefender = CreatureIdentifier.CreatureIdentifierFromString("Angel(2)"); var creature = new Angel(); mockedFactory.Setup(x => x.CreateCreature(It.IsAny <string>())).Returns(creature); mockedLogger.Setup(x => x.WriteLine(It.IsAny <string>())); battleManager.AddCreatures(identifierAttacker, 1); battleManager.AddCreatures(identifierDefender, 1); // Act battleManager.Attack(identifierAttacker, identifierDefender); mockedLogger.Verify(x => x.WriteLine(It.IsAny <string>()), Times.Exactly(4)); }
public void AddCreatures_WhenValidIdentifierIsPassed_WritelinShouldBeColled() { var mockedFactory = new Mock <ICreaturesFactory>(); var mockedLogger = new Mock <ILogger>(); var battleManager = new BattleManager(mockedFactory.Object, mockedLogger.Object); //var fixture = new Fixture(); // Test For abstract class //fixture.Customizations.Add( // new TypeRelay( // typeof(Creature), // typeof(Angel))); //var creature = fixture.Create<Angel>(); var creature = new Angel(); mockedFactory.Setup(x => x.CreateCreature(It.IsAny <string>())).Returns(creature); mockedLogger.Setup(x => x.WriteLine(It.IsAny <string>())); //var identifier = fixture.Create<CreatureIdentifier>(); var identifier = CreatureIdentifier.CreatureIdentifierFromString("Angel(1)"); battleManager.AddCreatures(identifier, 1); mockedLogger.Verify(x => x.WriteLine(It.IsAny <string>()), Times.Once); }
public void AddCreatures_WhenValidIdentifierPassed_FactoryShouldCallCreateCreature() { //Arrange var mockedFactory = new Mock <ICreaturesFactory>(); var mockedLogger = new Mock <ILogger>(); var battleManager = new BattleManager(mockedFactory.Object, mockedLogger.Object); // VARANT S FIXTURE - SYZDAVA INSTANCIQ NA ABSTRAKTEN KLAS ! //var fixture = new Fixture(); //fixture.Customizations.Add( // new TypeRelay( // typeof(Creature), // typeof(Angel))); // var creature = fixture.Create<Creature>(); var creature = new Angel(); mockedFactory.Setup(x => x.CreateCreature(It.IsAny <string>())).Returns(creature); var identifier = CreatureIdentifier.CreatureIdentifierFromString("Angel(1)"); //Act battleManager.AddCreatures(identifier, 1); //Assert mockedFactory.Verify(x => x.CreateCreature(It.IsAny <string>()), Times.Exactly(1)); }
public void ReturnCorrectCreature_WhenConstructed() { var ang = new Angel(); var creatureInBattle = new CreaturesInBattle(ang, 2); Assert.AreEqual(ang, creatureInBattle.Creature); }
public void CreaturePermanentDefense_WhenConstructed() { var ang = new Angel(); var creatureInBattle = new CreaturesInBattle(ang, 2); Assert.AreEqual(20, creatureInBattle.PermanentDefense); }
public void CreaturesTotalHitPoints_WhenConstructed() { var ang = new Angel(); var creatureInBattle = new CreaturesInBattle(ang, 2); Assert.AreEqual(400, creatureInBattle.TotalHitPoints); }
// Use this for initialization void Start() { _agent = GetComponent <NavMeshAgent>(); _animator = GetComponentInChildren <Animator>(); _angel = GetComponent <Angel>(); _originalSpeed = _agent.speed; StartCoroutine(ITestNavMesh()); }
public void AddCorrectPermanentDeffenseBonus_WhenSkipCommandIsCalled() { var ang = new Angel(); var creatureInBattle = new CreaturesInBattle(ang, 1); creatureInBattle.Skip(); Assert.AreEqual(23, creatureInBattle.PermanentDefense); }
public Spider game() { creator angel = new Angel(); glas nev_spider = new glas(angel); nev_spider.Construct(); Spider spider = angel.GetResult(); return(spider); }
private List <Lightable> fusionOfThreeList(List <Lightable> list1, List <Lightable> list2, List <Lightable> list3) { List <Lightable> fusion = new List <Lightable>(); foreach (Lightable elt in list1) { // Check if this is an unactivated angel if (elt.name.ToLower().Contains("angel")) { Angel angel = elt.GetComponent <Angel>(); if (angel != null && !angel.Activated) { continue; } } fusion.Add(elt); } foreach (Lightable elt in list2) { if (!fusion.Contains(elt)) { // Check if this is an unactivated angel if (elt.name.ToLower().Contains("angel")) { Angel angel = elt.GetComponent <Angel>(); if (angel != null && !angel.Activated) { continue; } } fusion.Add(elt); } } foreach (Lightable elt in list3) { if (!fusion.Contains(elt)) { // Check if this is an unactivated angel if (elt.name.ToLower().Contains("angel")) { Angel angel = elt.GetComponent <Angel>(); if (angel != null && !angel.Activated) { continue; } } fusion.Add(elt); } } return(fusion); }
public void ReturnCorrectTotalHitPoints_WhenApplyAfterDefendingIsCalled() { var resurrection = new Resurrection(); var angel = new Angel(); var creaturesInBattle = new CreaturesInBattle(angel, 1); resurrection.ApplyAfterDefending(creaturesInBattle); Assert.AreEqual(200, creaturesInBattle.TotalHitPoints); }
public void AddCorrectValue_SkipCreatureIsPassed() { var attackWhenSkip = new AddAttackWhenSkip(9); var creature = new Angel(); var creaturesInBattle = new CreaturesInBattle(creature, 1); attackWhenSkip.ApplyOnSkip(creaturesInBattle); Assert.AreEqual(29, creaturesInBattle.PermanentAttack); }
static void Main() { try { Angel angel = new Angel(); Devil devil = new Devil(); Arbalester arbalester = new Arbalester(); Lich lich = new Lich(); UnitsStack stack1 = new UnitsStack(angel, 3); UnitsStack stack2 = new UnitsStack(devil, 3); UnitsStack stack3 = new UnitsStack(arbalester, 3); UnitsStack stack4 = new UnitsStack(lich, 3); List <UnitsStack> unitsStacks = new List <UnitsStack>() { stack1, stack2, stack3, stack4 }; Console.WriteLine("list before editing:"); foreach (var stack in unitsStacks) { Console.WriteLine(stack); } Console.WriteLine("\n\n"); Army gg = new Army(unitsStacks); Console.WriteLine(gg); Console.WriteLine("\n\n"); unitsStacks.Add(new UnitsStack(angel, 9)); Console.WriteLine("list after editing:"); foreach (var stack in unitsStacks) { Console.WriteLine(stack); } Console.WriteLine("\n\n"); Console.WriteLine("army after editing list:"); Console.WriteLine(gg); var ex = gg.StacksList; ex.Add(new UnitsStack(angel, 3)); Console.WriteLine("army after editing got list:"); Console.WriteLine(gg); } catch (Exception e) { Console.WriteLine(e.Message); } }
/*public GameObject model_ninja; * * * public static void GetModel(Player Customer,string s) * { * //string model_name = s + "_Model"; * //GameObject model = Resources.Load(model_name) as GameObject; * var g = GameObject.Instantiate(model_ninja) as GameObject; * * g.transform.parent = Customer.gameObject.transform; * g.transform.localPosition = new Vector3(0,-26.60f,1.76f); * g.transform.localScale = new Vector3(14.63f,14.64f,14.64f); * }*/ public static List <Spell> GetAllActiveSkillsByClass(Player Customer, string @class) { switch (@class) { case "Ninja": return(Ninja.GetSpellList(Customer)); case "Angel": return(Angel.GetSpellList(Customer)); default: return(null); } }
IEnumerator RevivirTotem() { Debug.Log("Revivir totem"); Debug.Log(Time.time); yield return(new WaitForSeconds(2)); Angel angel = gameObject.GetComponentInChildren <Angel>(); ResetHealth(); this.transform.position = angel.GetPosicionValidaTotem(); angel.ActivarAnimacion(); angel.IncNumeroUsos(); Debug.Log(Time.time); }
public void SpwanAngel(Angel angel) { foreach (Angel temp_angel in prefab_angel) { if (temp_angel._head.angelType == angel._head.angelType) { Angel temp_angel_instance = Instantiate(temp_angel, SpawnPositionAngel, Quaternion.identity); temp_angel_instance.transform.SetParent(transform); copy_angel(temp_angel_instance, angel); angel_on_map.Add(temp_angel_instance); AudioSource.PlayClipAtPoint(victorySound, Camera.main.transform.position, volume); } } }
public void Only_one_character_alive_after_battle_encounter_1() { Satan satan = new Satan(10, 9000, 0); Dragon dragon = new Dragon(56, 52, 34); Orc orc = new Orc(23, 34, 4); ShadowHunter shadowHunter = new ShadowHunter(1, 10, 10); Angel angel = new Angel(231, 223, 343); Archer archer = new Archer(2323, 323, 32); Knight knight = new Knight(23, 3334, 132); BattleEncounter encounter = new BattleEncounter(new List <AbstractHero>() { shadowHunter, angel, archer, knight }, new List <AbstractVillain>() { satan, dragon, orc }); encounter.RunEncounter(); int heroesAlive = 0; int villainsAlive = 0; foreach (var hero in encounter.Heroes) { if (hero.IsAlive()) { heroesAlive++; } } foreach (var villain in encounter.Villains) { if (villain.IsAlive()) { villainsAlive++; } } Assert.IsTrue(heroesAlive == 0 || villainsAlive == 0); }
public IEnumerator Summon_Angle(Vector3 position) { for (int i = -1; i < 2; i++) { GameObject obj = GameManager.Instance.objectPooler.GetPooledObject((int)GameManager.OBJECTPOOLER.nAngel); if (obj == null) { yield return(null); } Angel angle = obj.GetComponent <Angel>(); angle.m_Target = m_Target; obj.transform.position = position + new Vector3(3.0f * (float)i, 3.0f, 0.0f); obj.SetActive(true); yield return(new WaitForSeconds(0.5f)); } m_Animator.SetBool("IsAttack", false); }
public void CallCreateCreature_WhenValidIdentifierIsPassed() { var mockedFactory = new Mock <ICreaturesFactory>(); var mockedLogger = new Mock <ILogger>(); var bmanager = new BattleManager(mockedFactory.Object, mockedLogger.Object); var identifier = CreatureIdentifier.CreatureIdentifierFromString("Angel(1)"); var creature = new Angel(); mockedFactory.Setup(x => x.CreateCreature(It.IsAny <string>())).Returns(creature); bmanager.AddCreatures(identifier, 1); mockedFactory.Verify(x => x.CreateCreature(It.IsAny <string>()), Times.Exactly(1)); }
public void Attack_ShouldCallLoggerWriteLineMethodFourTimes_WhenAttackIsSuccessfull() { var mockedFactory = new Mock <ICreaturesFactory>(); var mockedLogger = new Mock <ILogger>(); var battleManager = new MockedBattleManager(mockedFactory.Object, mockedLogger.Object); var identifierAttacker = CreatureIdentifier.CreatureIdentifierFromString("Angel(1)"); var identifierDefender = CreatureIdentifier.CreatureIdentifierFromString("Angel(2)"); var creature = new Angel(); mockedFactory.Setup(x => x.CreateCreature(It.IsAny <string>())).Returns(creature); battleManager.AddCreatures(identifierAttacker, 3); battleManager.AddCreatures(identifierDefender, 3); battleManager.Attack(identifierAttacker, identifierDefender); mockedLogger.Verify(x => x.WriteLine(It.IsAny <string>()), Times.Exactly(6)); }
public void AssembleAngel() { //Debug.Log("Try to assemble angel..."); if (addedBody.Count != 3) { return; } Angel newAngel = gameObject.AddComponent <Angel>(); BodyPart CurrentHead = gameObject.AddComponent <BodyPart>(); BodyPart CurrentTorso = gameObject.AddComponent <BodyPart>(); BodyPart CurrentLeg = gameObject.AddComponent <BodyPart>(); foreach (BodyPart part in addedBody) { if (part.partType == BodyPartType.Head) { CurrentHead = part; } if (part.partType == BodyPartType.Body) { CurrentTorso = part; } if (part.partType == BodyPartType.Foot) { CurrentLeg = part; } } newAngel.SetBodyParts(CurrentHead, CurrentTorso, CurrentLeg); worldManager.SpwanAngel(newAngel); //Debug.Log("create angel "); addedBody.Clear(); foreach (BodyPart temp_part in gameObject.GetComponents <BodyPart>()) { Destroy(temp_part); } Destroy(newAngel); hide_part_body(); hide_help_angel(); }
public void AddCreaturesInThirdArmy_WhenCorrectDataIsPassed() { var logger = new Mock <ILogger>(); var factory = new Mock <ICreaturesFactory>(); var creature = new Angel(); factory.Setup(x => x.CreateCreature(It.IsAny <string>())).Returns(creature); var battleManager = new MockedBattleManager(factory.Object, logger.Object); var creatureIdentifier = CreatureIdentifier.CreatureIdentifierFromString("Angel(3)"); battleManager.AddCreatures(creatureIdentifier, 1); var result = battleManager.ThirdArmyCreatures.FirstOrDefault(); Assert.IsInstanceOf(typeof(CreaturesInBattle), result); }
private void copy_angel(Angel first, Angel second) { first._head.angelType = second._head.angelType; first._head.partType = second._head.partType; first._head.actionsList = second._head.actionsList; first._head.ui = second._head.ui; first._head.change_ui(); first._torso.angelType = second._torso.angelType; first._torso.partType = second._torso.partType; first._torso.actionsList = second._torso.actionsList; first._torso.ui = second._torso.ui; first._torso.change_ui(); first._legs.angelType = second._legs.angelType; first._legs.partType = second._legs.partType; first._legs.actionsList = second._legs.actionsList; first._legs.ui = second._legs.ui; first._legs.change_ui(); }
static void Main(string[] args) { Console.WriteLine($"Loading mods from {Environment.CurrentDirectory}"); var unitsMod = UnitLoader.LoadUnits(); Console.WriteLine($"Loaded {unitsMod.Count()} units: {unitsMod}"); var devil = unitsMod.First(); var angel = new Angel(); var lich = new Lich(); var shaman = new Shaman(); var fury = new Fury(); var cyclops = new Cyclops(); var menu = new Menu(new List <Unit>() { devil, angel, lich, shaman, fury, cyclops }); menu.Start(); }
public void AddCreatures_ShouldThrowArgumentException_IfCreatureIsAddedToNonexistentArmy() { int count = 5; var creatureIdentifier = CreatureIdentifier.CreatureIdentifierFromString("AncientBehemoth(3)"); var creature = new Angel(); //var fixture = new Fixture(); //var creature = fixture.Create<Angel>(); var creaturesFactoryMock = new Mock <ICreaturesFactory>(); creaturesFactoryMock.Setup(x => x .CreateCreature(It.IsAny <string>())) .Returns(() => creature); var loggerMock = new Mock <ILogger>(); var battleManager = new BattleManager(creaturesFactoryMock.Object, loggerMock.Object); Assert.Throws <ArgumentException>(() => battleManager.AddCreatures(creatureIdentifier, count)); }
public void Attack_WhenAttackingOwnArmy_ShouldThrowArgumentException() { // Arrange var mockedFactory = new Mock <ICreaturesFactory>(); var mockedLogger = new Mock <ILogger>(); var battleManager = new MockedBattleManager(mockedFactory.Object, mockedLogger.Object); var identifierAttacker = CreatureIdentifier.CreatureIdentifierFromString("Angel(1)"); var identifierDefender = CreatureIdentifier.CreatureIdentifierFromString("Angel(1)"); var creature = new Angel(); mockedFactory.Setup(x => x.CreateCreature(It.IsAny <string>())).Returns(creature); mockedLogger.Setup(x => x.WriteLine(It.IsAny <string>())); battleManager.AddCreatures(identifierAttacker, 1); battleManager.AddCreatures(identifierDefender, 1); // Act and Assert Assert.Throws <ArgumentException>(() => battleManager.Attack(identifierAttacker, identifierDefender)); }
void Update() { //Set opponent - Can't do it in start because your opponent might not be in the game yet if(opponent == null) { if(gameObject.tag == "Player1") { opponent = GameObject.FindGameObjectWithTag("Player2"); if(opponent != null) opponentScript = opponent.GetComponent<Angel>() as Angel; } else if (gameObject.tag == "Player2") { opponent = GameObject.FindGameObjectWithTag("Player1"); if(opponent != null) opponentScript = opponent.GetComponent<Angel>() as Angel; } } if(networkView.isMine) { //Input SpellInput(); Vector3 oldPosition = transform.position; FlightInput(); HandleCollision(oldPosition); MouseInput(); CheckGameover(); //Spell Cooldowns HandleCooldowns(); //Firing projectiles mySpellHandler.UpdateSpells(); if (stealthOnCooldown && time_Stealth < duration_Stealth && !breakStealth) networkView.RPC("Stealth", RPCMode.All, networkView.viewID); else networkView.RPC("Unstealth", RPCMode.All, networkView.viewID); //Debug.Log("Stun on cool down " + stunOnCooldown.ToString() + " miunions stunned " + minionsAreStunned.ToString()); if (stunOnCooldown && time_Stun > duraction_Stun) { networkView.RPC("AwakeMinions", RPCMode.All, opponent.networkView.viewID); } } }
public void DrawColliderLines(Angel angel) { Vector2 max = Vector2.zero, min = Vector2.zero; if (Edits == null) { return; } switch (angel) { case Angel.Horizontal: for (int i = 0; i < Edits.Length; i++) { if (Edits[i] == null) continue; if (Edits[i].CurrentCollider.bounds.center.x > max.x || max == Vector2.zero) { max = Edits[i].CurrentCollider.bounds.center; } if (Edits[i].CurrentCollider.bounds.center.x < min.x || min == Vector2.zero) { min = Edits[i].CurrentCollider.bounds.center; } } Debug.DrawLine(max, min, Color.cyan); break; case Angel.Vertical: for (int i = 0; i < Edits.Length; i++) { if (Edits[i] == null) continue; if (Edits[i].CurrentCollider.bounds.center.y > max.y || max == Vector2.zero) { max = Edits[i].CurrentCollider.bounds.center; } if (Edits[i].CurrentCollider.bounds.center.y < min.y || min == Vector2.zero) { min = Edits[i].CurrentCollider.bounds.center; } } Debug.DrawLine(max, min, Color.cyan); break; } Vector3 sum = Vector3.zero; for (int i = 0; i < Edits.Length; i++) { sum += Edits[i].CurrentCollider.bounds.center; } sum /= Edits.Length; Ray2D ray; //RaycastHit2D[] hits; for (int i = 0; i < Edits.Length; i++) for (float x = 0; x <= Mathf.PI * 2; x += Mathf.PI / 2) { ray = new Ray2D(sum, new Vector2(Mathf.Cos(x), Mathf.Sin(x))); Debug.DrawRay(ray.origin, ray.direction * Edits[i].CurrentCollider.bounds.extents.x/2, Color.red); } }