public override void Interact(GameCharacterController interactee) { if (GetMessages() != null && GetMessages().Length > 0) { StartCoroutine(MessagesCoroutine()); } }
/// <summary> /// Returns a list of all characters on the stage except the specified character. /// </summary> /// <param name="self">The character on the stage that isn't included in the list.</param> /// <returns>A list of characters on the stage.</returns> public static List <GameCharacterController> AllCharactersExcept(GameCharacterController self) { var allExceptSelf = AllCharacters; allExceptSelf.Remove(self); return(allExceptSelf); }
public override void Interact(GameCharacterController interacter) { if (interacter is PlayerController) { StartCoroutine(PlayerInteraction()); } }
/// <summary> /// Performs an ability on a target. /// </summary> /// <param name="ability">The ability to perform.</param> /// <param name="target">The target of the ability.</param> protected void PerformAbility(Ability ability, GameCharacterController target) { HeroCombatController.AbilityCooldowns.Add(ability.name, ability.Cooldown * Mathf.Max(0, 1.0f - Attributes.CooldownReduction)); HeroCombatController.ApplyEnergyLoss(ability.EnergyCost); switch (ability.AbilityType) { case AbilityType.Area: PerformAreaAbility(ability, target); break; case AbilityType.Direct: PerformDirectAbility(ability, target); break; case AbilityType.Heal: PerformHealAbility(ability, target); break; case AbilityType.Shield: PerformShieldAbility(ability, target); break; default: break; } }
private void Awake() { GameObject parent = gameObject; while (parent != null && parent.CompareTag("Untagged")) { parent = parent.transform.parent.gameObject; } _rootParent = parent; gameCharacterController = _rootParent.GetComponent <GameCharacterController>(); if (_rootParent.CompareTag("Player")) { validTags = new [] { "Enemy", "Mechanism" } } ; else if (_rootParent.CompareTag("Enemy")) { validTags = new [] { "Player" } } ; else if (_rootParent.CompareTag("Trap")) { validTags = new [] { "Player" } } ; } }
public override void Interact(GameCharacterController interacter) { if (interacter is PlayerController && sceneController.SceneIsActive) { usingAutomaticMovement = false; if (isMoving) { CompleteMovement(); } TryTurn(GetOppositeDirection(interacter.directionFacing)); if (CanBattlePlayer) { TriggerBattle(); } else { if (trainerDetails.chatMessage != "" && trainerDetails.chatMessage != null) { StartCoroutine(SpeakChatMessage()); } } } }
//--------------------------------------------------------------------------- public void UpdateWithActiveCharacterActions(GameCharacterController characterController) { SelectingActions = true; var actions = characterController.PostMoveActions; for (var i = 0; i < actions.Length; ++i) SetupButton(actions[i].NameStatsDescription, i); }
public override void Interact(GameCharacterController interacter) { if (interacter is PlayerController) { TryTurn(GetOppositeDirection(interacter.directionFacing)); StartCoroutine(PlayerInteraction()); } }
/// <summary> /// Spawns a fireball projectile. /// </summary> /// <param name="ability">The ability to perform.</param> /// <param name="target">The target of the ability.</param> public void PerformFireball(Ability ability, GameCharacterController target) { var criticalModifier = CriticalModifier(); var damage = (int)(CharacterController.Attributes.AbilityDamage * criticalModifier); PerformLifeDrain(damage); SpawnProjectile(GameManager.GameSettings.Prefab.Effect.Fireball, transform.position, damage, target, criticalModifier); }
/// <summary> /// Spawns a storm projectile. /// </summary> /// <param name="location">The location to spawn the storm projectile.</param> /// <param name="target">The target of the storm projectile.</param> public void SpawnStorm(Vector3 location, GameCharacterController target) { var criticalModifier = CriticalModifier(); var damage = (int)(CharacterController.Attributes.AttackDamage * criticalModifier); PerformLifeDrain(damage / 2); SpawnProjectile(GameManager.GameSettings.Prefab.Effect.Storm, location, damage, target, criticalModifier); }
/// <summary> /// Gets the character and subscribes to stage change events. /// </summary> public void GetCharacterComponent() { character = GetComponent <GameCharacterController>(); if (character != null) { character.OnStateChanged += CharacterStateChanged; character.OnDirectionChanged += CharacterStateChanged; } }
/// <summary> /// Spawns a projectile that travels to and strikes the target. /// </summary> /// <param name="prefab">The projectile to spawn.</param> /// <param name="location">The location to spawn the projectile.</param> /// <param name="damage">The damage the projectile will do upon contact.</param> /// <param name="target">The target of the projectile.</param> /// <param name="criticalModifier">The critical modifier of the projectile's damage.</param> public void SpawnProjectile(GameObject prefab, Vector3 location, int damage, GameCharacterController target, float criticalModifier) { var projectile = Instantiate(prefab, location, Quaternion.identity) as GameObject; var projectileController = projectile.GetComponent <DirectAbilityController>(); projectileController.Target = target; projectileController.Damage = damage; projectileController.CriticalModifier = criticalModifier; }
/// <summary> /// Sets up the floating bar. /// </summary> protected void Start() { // Get reference to the character that this bar is attached to. character = transform.parent.gameObject.GetComponent <GameCharacterController>(); // Setup colors var backgroundImage = background.gameObject.GetComponent <Image>(); var foregroundImage = foreground.gameObject.GetComponent <Image>(); backgroundImage.color = GameManager.GameSettings.Constants.Colors.FloatingBarBackground; foregroundImage.color = GameManager.GameSettings.Constants.Colors.FloatingBarForeground; }
/// <summary> /// Moves a character according to their current movement behaviours. /// </summary> protected void Move() { // Get desired velocity var desiredVelocity = movementBehaviour.Steering().normalized *MaxSpeed *GameManager.GameSettings.Constants.Character.VelocityFactor *Time.fixedDeltaTime; // Update state and direction if (desiredVelocity != Vector2.zero) { try { // Maintain proper character state character.CharacterState = CharacterState.Walk; } catch (NullReferenceException) { character = GetComponent <GameCharacterController>(); } try { var desiredVelocityNormalized = desiredVelocity.normalized; // Maintain proper character direction if (desiredVelocityNormalized.x != 0) { var jitterVariance = 0.1f; if (desiredVelocityNormalized.x <= -jitterVariance || desiredVelocityNormalized.x >= jitterVariance) { if (desiredVelocityNormalized.x < 0) { character.LastDirection = MoveDirection.Left; } else { character.LastDirection = MoveDirection.Right; } } } } catch (NullReferenceException) { character = GetComponent <GameCharacterController>(); } } if (desiredVelocity == Vector2.zero && character.CharacterState == CharacterState.Walk) { character.CharacterState = CharacterState.Idle; } // Finally move to new position character.Rigidbody.MovePosition((Vector2)transform.position + desiredVelocity); transform.rotation = Quaternion.identity; }
/// <summary> /// Sets up the combat controller. /// </summary> protected virtual void Start() { characterControllerReference = GetComponent <GameCharacterController>(); if (characterControllerReference == null) { Debug.LogError(gameObject.name + ": Combat controller could not find a reference to the character controller."); return; } currentHealth = CharacterController.Attributes.Health; currentEnergy = CharacterController.Attributes.Energy; lastAttackTime = Time.time - (1 / CharacterController.Attributes.AttackSpeed); }
/// <summary> /// Updates the floating bar every frame. /// </summary> protected void Update() { try { var healthPercentage = (float)character.CombatController.CurrentHealth / character.Attributes.Health; healthPercentage = Mathf.Max(Mathf.Min(healthPercentage, 1), 0); var newBarScale = new Vector3(healthPercentage, 1, 1); foreground.localScale = newBarScale; } catch (NullReferenceException) { character = transform.parent.gameObject.GetComponent <GameCharacterController>(); } }
/// <summary> /// Performs a ranged area ability. /// </summary> /// <param name="ability">The ability to perform.</param> /// <param name="target">The target of the ability.</param> public void PerformRangedAreaAbility(Ability ability, GameCharacterController target) { SpawnStorm(target.Location + new Vector3(0.0f, 1.0f, 0.0f), target); var enemies = GameManager.AllEnemies; foreach (var enemy in enemies) { if (enemy == target) { continue; } if (enemy.Location.SqrDistance(target.Location) < 1.2f) { SpawnStorm(enemy.Location + new Vector3(0.0f, 1.0f, 0.0f), enemy); } } }
/// <summary> /// Returns the closest hostile from a list of characters. /// </summary> /// <param name="hostiles">List of hostile characters.</param> public void GetClosestHostile(List <GameCharacterController> hostiles) { GameCharacterController closestHostile = null; var closestSquaredDistance = Mathf.Infinity; foreach (var hostile in hostiles) { var directionToHostile = hostile.Location - CharacterController.Location; var squaredDistance = directionToHostile.sqrMagnitude; if (squaredDistance < closestSquaredDistance) { closestSquaredDistance = squaredDistance; closestHostile = hostile; } } TargetController = closestHostile; }
/// <summary> /// Performs a shield ability on a target. /// </summary> /// <param name="ability">The ability to perform.</param> /// <param name="target">The target of the ability.</param> protected void PerformShieldAbility(Ability ability, GameCharacterController target) { Debug.Log(gameObject.name + ": Performing shield ability " + ability.name + " on " + target.name); switch (ability.AbilityRange) { case AbilityRange.Melee: // Not implemented break; case AbilityRange.Ranged: // Not implemented break; case AbilityRange.Self: HeroCombatController.PerformDefendAbility(ability); break; default: break; } }
/// <summary> /// Applies the hazard's effect to a character. /// </summary> public void ApplyEffect(GameCharacterController character) { switch (type) { case HazardType.Damage: character.CombatController.ApplyDamage((int)potency); break; case HazardType.Force: character.MovementController.ApplyForce(potency, transform.position); break; case HazardType.Stun: character.CombatController.ApplyStun(potency); break; default: break; } }
/// <summary> /// Performs a heal ability on a target. Placeholder. /// </summary> /// <param name="ability">The ability to perform.</param> /// <param name="target">The target of the ability.</param> protected void PerformHealAbility(Ability ability, GameCharacterController target) { Debug.Log(gameObject.name + ": Performing heal ability " + ability.name + " on " + target.name); switch (ability.AbilityRange) { case AbilityRange.Melee: // Not implemented break; case AbilityRange.Ranged: // Not implemented break; case AbilityRange.Self: // Not implemented break; default: break; } }
/// <summary> /// Performs a direct ability on a target. /// </summary> /// <param name="ability">The ability to perform.</param> /// <param name="target">The target of the ability.</param> protected void PerformDirectAbility(Ability ability, GameCharacterController target) { Debug.Log(gameObject.name + ": Performing direct ability " + ability.name + " on " + target.name); switch (ability.AbilityRange) { case AbilityRange.Melee: HeroCombatController.PerformMeleeAttack(); break; case AbilityRange.Ranged: HeroCombatController.PerformFireball(ability, target); break; case AbilityRange.Self: // Not implemented break; default: break; } }
/// <summary> /// Performs a melee area ability. /// </summary> /// <param name="ability">The ability to perform.</param> /// <param name="target">The target of the ability.</param> public void PerformMeleeAreaAbility(Ability ability, GameCharacterController target) { var criticalModifier = CriticalModifier(); var damage = (int)(CharacterController.Attributes.AttackDamage * criticalModifier); target.CombatController.ApplyDamage(damage, criticalModifier > 1); var enemies = GameManager.AllEnemies; foreach (var enemy in enemies) { if (enemy == target) { continue; } if (enemy.Location.SqrDistance(target.Location) < 1.2f) { enemy.CombatController.ApplyDamage(damage, criticalModifier > 1); PerformLifeDrain(damage / 2); } } }
/// <summary> /// Generates movement behaviour to seek the current target. /// </summary> protected virtual void GenerateSeekBehaviour() { try { if (character.CombatController.TargetController != null) { var squareDistance = transform.position.SqrDistance(character.CombatController.TargetController.transform.position); if (squareDistance > SeekTargetDistanceSquared) { var targetLocation = character.CombatController.TargetController.transform.position; var location = targetLocation + ((transform.position - targetLocation).normalized * SeekTargetDistance); movementBehaviour = new WalkMovementBehaviour( movementBehaviour, gameObject, location, SeekTargetDistance); } } else if (character.CombatController.TargetController == null) { // Have allies walk back to hero when they don't have a target. if (character.CharacterType == CharacterType.Ally) //TODO: Make this more generic. { var squareDistance = transform.position.SqrDistance(GameManager.Hero.Location); if (squareDistance > SeekTargetDistanceSquared) { var location = GameManager.Hero.Location + ((transform.position - GameManager.Hero.Location).normalized * SeekTargetDistance); movementBehaviour = new WalkMovementBehaviour( movementBehaviour, gameObject, location, SeekTargetDistance); } } } } catch (NullReferenceException) { character = GetComponent <GameCharacterController>(); } }
protected override void ActionPerformed(GameCharacterController c) { base.ActionPerformed(c); switch (bonusType) { case BonusType.Damage: StartCoroutine(c.TemporaneousDamageBuff(bonusValue, bonusSeconds)); break; case BonusType.Armour: StartCoroutine(c.TemporaneousArmourBuff(bonusValue, bonusSeconds)); break; case BonusType.Speed: StartCoroutine(c.TemporaneousSpeedBuff(bonusValue, bonusSeconds)); break; case BonusType.Heal: c.TakeHitPoints(bonusValue); break; } }
//--------------------------------------------------------------------------- private void StartNextCharactersTurn() { if (transformationTargets.Count > 0) { Debug.Log("Waiting for Transformation to finish..."); ActionMenu.UpdateWithTransformationChoices(); return; } // Unsubscribe the old event if (activeCharacter) { activeCharacter.CharacterTurnEnded -= OnCharacterTurnEnded; activeCharacter.CharacterMovementComplete -= OnCharacterDoneMoving; } // Get a new piece started. activeCharacter = ActQueue.GetNextActiveCharacter(); activeCharacter.CharacterTurnEnded += OnCharacterTurnEnded; activeCharacter.BeginTurn(); OnCharactersTurnBegins(activeCharacter); if(PlayerCanSeePiece(activeCharacter.CharacterLink)) MainCameraController.FlyToPiece(activeCharacter.CharacterLink); }
//--------------------------------------------------------------------------- private void OnCharacterTurnEnded(GameCharacterController character) { if (character == activeCharacter) { StartNextCharactersTurn(); } }
//--------------------------------------------------------------------------- private void OnCharacterDoneMoving(GameCharacterController character) { character.CharacterMovementComplete -= OnCharacterDoneMoving; character.BeginActionSelectPhase(); // Trigger the menu ActionMenu.UpdateWithActiveCharacterActions(activeCharacter); }
public override int TakeDamage(int damage, GameCharacterController gameCharacterController) { return(base.TakeDamage(damage, gameCharacterController)); }
public override void Interact(GameCharacterController interacter) { TryTurn(GetOppositeDirection(interacter.directionFacing)); //Face player when talking StartCoroutine(InteractionCoroutine()); }
public void OnCharactersActionSelectComplete(GameCharacterController character) { if (CharacterActionSelectComplete != null) CharacterActionSelectComplete(character); }
public override void Interact(GameCharacterController interactee) { StartCoroutine(UsageCoroutine()); }
protected override void ActionPerformed(GameCharacterController gameCharacterController) { base.ActionPerformed(gameCharacterController); SceneTransitioner.GetInstance().GoToScene(3); }
public void OnCharactersMovementComplete(GameCharacterController character) { if (CharacterMovementComplete != null) CharacterMovementComplete(character); }
public void BeginSelectTransformationPhase(GameCharacterController target) { transformationTargets.Add(target); }
public void OnCharactersTurnEnds(GameCharacterController character) { if (CharactersTurnEnds != null) CharactersTurnEnds(character); }
//--------------------------------------------------------------------------- public bool IsCharacterMyEnemy(GameCharacterController other) { return other.CurrentTeam != ControllerLink.CurrentTeam; }
public abstract void Interact(GameCharacterController interacter);
protected virtual void ActionPerformed(GameCharacterController gameCharacterController) { }