protected override void OnCharacterAboutToBeDestroyed(BaseCharacter baseCharacter) { switch (baseCharacter.GetCharacterType()) { case ECharacterType.enemy_zombie: { CharacterEnemy enemy = baseCharacter as CharacterEnemy; if (null != enemy) { // // Remvoe enemy from no/aggroed array m_aEnemiesAggroed.Remove(enemy); m_aEnemiesNotAggroed.Remove(enemy); } } break; case ECharacterType.none: case ECharacterType.player: default: { Assert.IsTrue(false); } break; } }
public override void UpdateMovePattern(NavMeshAgent NavAgent, CharacterEnemy Self, Character TargetCharacter) { if (!TargetCharacter) { Self.UpdateMovePatternForMissingTarget(); return; } Vector3 targetDir = Vector3.Normalize( new Vector3(TargetCharacter.transform.position.x, 0, TargetCharacter.transform.position.z) * ViewDirection - new Vector3(Self.transform.position.x, 0, Self.transform.position.z) * ViewDirection); if (targetDir.sqrMagnitude > 0) { Self.transform.rotation = Quaternion.Slerp(Self.transform.rotation, Quaternion.LookRotation(targetDir), Time.deltaTime * RotationSpeed * 0.01f); } Vector3 targetVel = targetDir * MovementSpeedFactor * Self.GetMovementRateModifier(); //NavAgent.Move(targetVel * Time.deltaTime); NavAgent.speed = MovementSpeedFactor * Self.GetMovementRateModifier(); NavAgent.SetDestination(TargetCharacter.transform.position); Self.SwitchWalkingAnimation(true); Self.StartBodyAnimation(Self.GetMovementRateModifier()); }
protected override void OnCharacterAboutToBeSpawned(ECharacterType eType, ref BaseCharacter baseCharacter) { switch (eType) { case ECharacterType.enemy_zombie: { CharacterEnemy enemy = baseCharacter as CharacterEnemy; if (null != enemy) { m_aEnemiesNotAggroed.Add(enemy); enemy.gameObject.transform.parent = gameObject.transform; } } break; case ECharacterType.none: case ECharacterType.player: default: { Assert.IsTrue(false); } break; } }
public void CreateEnemyCharacter(CharacterEnemy enemyCharacter) { enemyCharacter.Id = _idEnemyCounter; _idEnemyCounter++; EnemyCharacters.Add(enemyCharacter); }
public void Game_Deserialize_CreatesObject() { string serialized = "Class=CharacterClass.Tank;HeldWeapon;Armor;MaxHealth=10;Health;Score"; CharacterEnemy enemy = new CharacterEnemy(CharacterClass.Tank, 10); Assert.IsTrue(serialized == enemy.Serialize()); }
private CharacterEnemy NextEnemy() { CharacterEnemy nextEnemy = null; IncrementEnemyNr(); for (int i = 0; i < enemyCharacters.Count - 1; i++) { if (!combat) { break; } if (enemyCharacters[currentEnemyNr].isAlive) { nextEnemy = enemyCharacters[currentEnemyNr]; break; } else { IncrementEnemyNr(); } } if (nextEnemy == null) { nextEnemy = enemyCharacters[0]; } return(nextEnemy); }
private void ConfirmEnemyTarget(int target) { currentCharacter.ResetAttackMode(); AbilityUseReset(); // Deactivate enemy targeting objects EventManager.Instance.AbilityIndicatorStatus(true); EventManager.Instance.TargetEnemyToggle(); CharacterEnemy tar = LookupEnemyByTargetDirection(target); if (tar == null) { print("No Enemy Target Found"); return; } // Spawn damage effect of ability SpawnVisualEffect(tar); // Confirm and use attack on target audioSource.PlayOneShot(currentAbility.sound); currentAbility.effect(tar, currentCharacter); targetingEnemy = false; }
public void Enemy_Constructor_InvalidData() { try { Character character = new CharacterEnemy(CharacterClass.Gunner, -10); Assert.Fail(); } catch { } }
private void PlayerClickedAnObject(GameObject clickedGameObject) { // Sanity check. if (clickedGameObject == null) { return; } // Check if object is on a Character. Character character = clickedGameObject.GetComponentInChildren <Character>(); if (character == null) { character = clickedGameObject.GetComponentInParent <Character>(); } if (character != null) { // Debug.Log( "Player clicked on a Character: " +character.name ); // What to do when a player has clicked on a character (NOTE: Could be self!) // Check if it was an enemy that was clicked on. CharacterEnemy enemy = character as CharacterEnemy; if (enemy != null) { Debug.Log("Player clicked on an Enemy: " + enemy.name); } return; } // Check if object is on an Item. Item item = clickedGameObject.GetComponentInChildren <Item>(); if (item == null) { item = clickedGameObject.GetComponentInParent <Item>(); } if (item != null) { Debug.Log("Player clicked on an item: " + item.itemName); // Direct the player to head to the clicked item. CharacterPlayer player = GameManager.GetPlayer(); if (player != null) { PlayerControllerARPG controller = player.GetComponent <PlayerControllerARPG>(); if (controller != null) { controller.SetNavMeshAgentDestination(item.transform.position); } } return; } Debug.Log("Player clicked on an object: " + clickedGameObject.name); }
public void addEnemyDisplay(CharacterEnemy enemy) { GameObject newDisplay = Instantiate(enemyDisplayPrefab); newDisplay.transform.parent = enemyDisplays; EnemyDisplayGUI displayGUI = newDisplay.GetComponent <EnemyDisplayGUI>(); displayGUI.initDisplay(enemy); }
public void initDisplay(CharacterEnemy enemy) { myEnemy = enemy; name.text = enemy.name; updateHealthUI(enemy.health); enemy.health.onHealthChange += updateHealthUI; enemy.health.onDeath += removeDisplay; enemy.myDisplay = this; }
public void Enemy_Hit_LessHealth() { Character character = new CharacterEnemy(CharacterClass.Gunner, 10); Bullet b = new Bullet(3); character.Hit(b); Assert.IsTrue(character.Health == 7); }
public virtual bool onApply(CharacterHealth health) { effector = health; if (effector.character is CharacterEnemy) { CharacterEnemy enemy = (CharacterEnemy)(effector.character); display = enemy.myDisplay.displayStatus(this); } return(true); }
void shuffleEnemies(List <CharacterEnemy> list) { for (int i = 0; i < list.Count; i++) { int r = Random.Range(0, list.Count); CharacterEnemy temp = list[i]; list[i] = list[r]; list[r] = temp; } }
public void Enemy_Constructor_ValidData() { Character character = new CharacterEnemy(CharacterClass.Gunner, 10); Assert.IsTrue(character.Class == CharacterClass.Gunner); Assert.IsTrue(character.HeldWeapon is WeaponKnife); Assert.IsTrue(character.Armor == false); Assert.IsTrue(character.MaxHealth == 10); Assert.IsTrue(character.Health == 10); Assert.IsTrue(character.Score == 0); }
public void Verify_Add_Should_AddTheEntityToTheContext() { // Arrange Mock<IDbSet<CharacterEnemy>> mockSetCharacterEnemies; var mockContext = CharacterEnemiesMockingSetup.DoMockingSetupForContext(false, out mockSetCharacterEnemies); var repository = new CharacterEnemiesRepository(mockContext.Object); var characterEnemies = new CharacterEnemy { Active = true, CustomKey = "SALVATORE-RAA", }; // Act repository.Add(characterEnemies); // Assert mockSetCharacterEnemies.Verify(x => x.Add(characterEnemies), Times.Once); }
// ############## // # Enemy Turn # // ############## private void EnemyTurn() { if (targetingEnemy) // reset targeting enemy { targetingEnemy = false; if (currentCharacter != null) { currentCharacter.ResetAttackMode(); currentCharacter.CharacterDeselect(); currentCharacter = null; } EventManager.Instance.TargetEnemyToggle(); } // Select attacker attacker = NextEnemy(); if (attacker == null) { CheckForGameEnding(); return; } attacker.SetAttacking(true); attacker.CharacterSelect(); EventManager.Instance.SetEnemyName(enemyCharacters[currentEnemyNr].characterName); // Set UI currentAbility = attacker.SelectAttack(); if (currentAbility.hasAttackMode) // Determine whether an Attack Mode animation must play { attacker.PlayAbilityAnimation("AttackMode"); // play animation } else { attacker.PlayAbilityAnimation("Attack"); // play animation } switch (currentAbility.targets) { case "EnemyRandom": // Instant EnemyAbilityInstant(); break; case "EnemyRhythm": // Rhythm EnemyRhythm(); break; default: break; } }
public void Enemy_Hit_DestroyArmor() { Character character = new CharacterEnemy(CharacterClass.Gunner, 10); character.Armor = true; Assert.IsTrue(character.Armor == true); Bullet b = new Bullet(1337); character.Hit(b); Assert.IsTrue(character.Health == 10); Assert.IsTrue(character.Armor == false); }
private CharacterEnemy LookupEnemyByTargetDirection(int dir) { CharacterEnemy tempEnemy = null; foreach (CharacterEnemy enemy in enemyCharacters) { if (enemy.targetingDirection == dir) { tempEnemy = enemy; break; } } return(tempEnemy); }
public override void startEncounter() { enemies = new List <CharacterEnemy>(); for (int i = 0; i < enemyPrefabs.Count; i++) { GameObject newEnemy = Instantiate(enemyPrefabs[i].gameObject); CharacterEnemy enemy = newEnemy.GetComponent <CharacterEnemy>(); //enemy.name += " 0" + (i + 1).ToString(); enemy.initEnemy(); enemies.Add(enemy); } totalEnemies = enemies.Count; TurnManager.instance.onCombatOver += endEncounter; TurnManager.instance.initCombat(PartyGUI.instance.party, enemies); }
public void Verify_Add_Should_AddTheEntityToTheContext() { // Arrange Mock <IDbSet <CharacterEnemy> > mockSetCharacterEnemies; var mockContext = CharacterEnemiesMockingSetup.DoMockingSetupForContext(false, out mockSetCharacterEnemies); var repository = new CharacterEnemiesRepository(mockContext.Object); var characterEnemies = new CharacterEnemy { Active = true, CustomKey = "SALVATORE-RAA", }; // Act repository.Add(characterEnemies); // Assert mockSetCharacterEnemies.Verify(x => x.Add(characterEnemies), Times.Once); }
// ############## // # Enemy Turn # // ############## private void EnemyTurn() { if (targetingEnemy) // reset targeting enemy { targetingEnemy = false; if (currentCharacter != null) { currentCharacter.ResetAttackMode(); currentCharacter.CharacterDeselect(); currentCharacter = null; } EventManager.Instance.TargetEnemyToggle(); } // Select attacker attacker = NextEnemy(); if (attacker == null) { CheckForGameEnding(); return; } attacker.SetAttacking(true); attacker.CharacterSelect(); EventManager.Instance.SetEnemyName(enemyCharacters[currentEnemyNr].characterName); // Set UI currentAbility = attacker.SelectAttack(); //print(currentAbility.GetName()); switch (currentAbility.targets) { case "EnemyRandom": // Instant EnemyAbilityRandom(false); break; case "EnemyRhythm": // Rhythm EnemyAbilityRhythm(); break; case "FriendlyRandom": EnemyAbilityRandom(true); break; default: break; } }
public void Verify_MapToEntity_WithExistingEntity_AssignsCharacterEnemyProperties() { // Arrange var mapper = new CharacterEnemyMapper(); var model = CharacterEnemiesMockingSetup.DoMockingSetupForCharacterEnemyModel(); // Act ICharacterEnemy existingEntity = new CharacterEnemy { Id = 1 }; mapper.MapToEntity(model.Object, ref existingEntity); // Assert // <None> // Related Objects Assert.Equal(model.Object.CharacterId, existingEntity.CharacterId); Assert.Equal(model.Object.EnemyId, existingEntity.EnemyId); // Associated Objects // <None> }
public void SpawnEnemies() // Spawns the previously generated Enemies. If no Enemies have been generated yet, it generates them. { if (GeneratedEnemies.Length == 0) { GenerateEnemies(); } CharacterEnemy CurrentlySpawningEnemy = null; for (int i = 0; i < GeneratedEnemies.Length; i++) { CurrentlySpawningEnemy = Instantiate(GeneratedEnemies[i].CharacterBase, Positions[i], Quaternion.Euler(Rotations[i])); CurrentlySpawningEnemy.InitializeEnemy(this, GeneratedEnemies[i].Weapons, GeneratedEnemies[i].WeaponLevels); SpawnedEnemies.Add(CurrentlySpawningEnemy); } }
public override void UpdateMovePattern(PhysicsController PhysCont, CharacterEnemy Self, Character TargetCharacter) { if (!TargetCharacter) { Self.UpdateMovePatternForMissingTarget(); return; } Vector3 targetDir = Vector3.Normalize( new Vector3(TargetCharacter.transform.position.x, 0, TargetCharacter.transform.position.z) * ViewDirection - new Vector3(Self.transform.position.x, 0, Self.transform.position.z) * ViewDirection); PhysCont.SetVelRot(Vector3.zero, targetDir); Self.SwitchWalkingAnimation(false); }
public void EnemyAppear(CharacterEnemy[] enemies) { CharacterEnemy first = null; foreach (CharacterEnemy enemy in enemies) { enemyCharacters.Add(enemy); enemy.gameObject.SetActive(true); if (first == null) // Play first enemy's voice clip { first = enemy; //enemy.audioSource.Play(); } } SetupCharacterList(); }
public override IEnumerator takeTurn(Character target, CharacterAbility ability) { myDisplay.setNameColor(true); AbilityManager.instance.setUpAbilityManager(this); myAbility = null; myTarget = null; // myAbility = ability01; while (myTarget == null || myAbility == null) { yield return(null); } TurnManager.instance.ability = myAbility; TurnManager.instance.target = myTarget; AbilityManager.instance.removeAbilityPanel(); myDisplay.setNameColor(false); }
public void Verify_MapToEntity_WithExistingEntity_AssignsCharacterEnemyProperties() { // Arrange var mapper = new CharacterEnemyMapper(); var model = CharacterEnemiesMockingSetup.DoMockingSetupForCharacterEnemyModel(); // Act ICharacterEnemy existingEntity = new CharacterEnemy { Id = 1 }; mapper.MapToEntity(model.Object, ref existingEntity); // Assert // <None> // Related Objects Assert.Equal(model.Object.CharacterId, existingEntity.CharacterId); Assert.Equal(model.Object.EnemyId, existingEntity.EnemyId); // Associated Objects // <None> }
public override void UpdateMovePattern(PhysicsController PhysCont, CharacterEnemy Self, Character TargetCharacter) { if (!TargetCharacter) { Self.UpdateMovePatternForMissingTarget(); return; } Vector3 targetDir = Vector3.Normalize( new Vector3(TargetCharacter.transform.position.x, 0, TargetCharacter.transform.position.z) * ViewDirection - new Vector3(Self.transform.position.x, 0, Self.transform.position.z) * ViewDirection); Vector3 targetVel = targetDir * MovementSpeedFactor * Self.GetMovementRateModifier(); PhysCont.SetVelRot(targetVel, targetDir); Self.SwitchWalkingAnimation(true); Self.StartBodyAnimation(Self.GetMovementRateModifier()); }
public override void UpdateMovePattern(NavMeshAgent NavAgent, CharacterEnemy Self, Character TargetCharacter) { if (!TargetCharacter) { Self.UpdateMovePatternForMissingTarget(); return; } Vector3 targetDir = Vector3.Normalize( new Vector3(TargetCharacter.transform.position.x, 0, TargetCharacter.transform.position.z) * ViewDirection - new Vector3(Self.transform.position.x, 0, Self.transform.position.z) * ViewDirection); if (targetDir.sqrMagnitude > 0) { Self.transform.rotation = Quaternion.Slerp(Self.transform.rotation, Quaternion.LookRotation(targetDir), Time.deltaTime * RotationSpeed * 0.01f); } Self.SwitchWalkingAnimation(false); }
public virtual void UpdateMovePattern(NavMeshAgent NavAgent, CharacterEnemy Self, Character TargetCharacter) { }
public virtual void UpdateMovePattern(PhysicsController PhysCont, CharacterEnemy Self, Character TargetCharacter) { }