public void StepBehavior() { //check to make sure shit hasn't just gone completely south if (behaviorStep + 1 >= behavior.Length || behaviorStep < 0) { //if it has, reset behaviorStep = 0; } else { //otherwise, business as normal. behaviorStep++; //loop behavior if (behaviorStep > behavior.Length) { behaviorStep = 0; } } preparedAction = behavior[behaviorStep]; if (preparedAction == PreparedAction.Attack) { RollDamage(); } EnemyUIUpdate?.Invoke(); }
//do all of the enemy actions, then shift to discard state public void OnEnemyTurn(CombatState state) { if (state == CombatState.EnemyTurn) { foreach (EnemyDisplay enemyDisplay in enemies) { //clear any remaining enemy shield enemyDisplay.enemy.RemoveShield(); //then do all the enemy actions PreparedAction action = enemyDisplay.enemy.preparedAction; if (action == PreparedAction.Attack) { enemyDisplay.enemy.DealDamage(PlayerStats.instance); } else if (action == PreparedAction.Defend) { enemyDisplay.enemy.Shield(enemyDisplay.enemy.shielding); } else { //Debug.Log("Not Implemented or doing nothing"); } //go to next action in the pool enemyDisplay.enemy.StepBehavior(); } if (PlayerStats.instance.playerClass.currentHealth > 0) { //go to discard state EnemyState.Invoke(3); } } }
public void ExecuteActions() { PreparedAction act = actions; actions = null; StartCoroutine(ActionRunner(act)); CanAdvance = false; coroutinecount++; }
private IEnumerator DelayedActionRunner() { yield return(null); if (this.delayedActions != null) { this.delayedActions(); } this.delayedActions = null; this.WaitOnDelayedAction = false; yield break; }
public override PreparedAction ReturnPreparedAction(CharacterValueContainer container) { float actionDuration = ModifedValue(_preparedbehaviour.actionDuration, Stats.SkillDuration.ToString(), container).TotalValue; float actionSpeed = ModifedValue(_preparedbehaviour.actionSpeed, Stats.ProjectileSpeed.ToString(), container).TotalValue; NumAffectedTargets numTargets = _preparedbehaviour.targetsHitToDestroy; PreparedActionBehaviour behaviour = new PreparedActionBehaviour(actionDuration, actionSpeed, numTargets); PreparedAction action = new PreparedAction(behaviour); DamageAction dam = CreateDamageAction(); action.AddAction(dam); return(action); }
public void SetUp() { currentHP = maxHP; currentShield = startingShield; behaviorStep = startingStep; preparedAction = behavior[behaviorStep]; if (preparedAction == PreparedAction.Attack) { RollDamage(); } EnemyUIUpdate?.Invoke(); }
private IEnumerator ActionRunner() { Resources.UnloadUnusedAssets(); yield return((object)null); yield return((object)null); if (actions != null) { actions(); } actions = null; CanAdvance = true; }
private IEnumerator ActionRunner(PreparedAction act) { Resources.UnloadUnusedAssets(); yield return(null); yield return(null); if (act != null) { act(); } this.coroutinecount--; if (this.coroutinecount == 0) { this.CanAdvance = true; } yield break; }
public void FinishAction(Entity parent) { // * check if we can currently cast a skill (enough mana etc.) // * check if we can cast THAT skill on THAT target // note: we don't check the distance again. the skill will be cast even // if the target walked a bit while we casted it (it's simply better // gameplay and less frustrating) GameObject action = Instantiate(currentData.Obj); if (!action.GetComponent <PreparedAction>()) { action.AddComponent <PreparedAction>(); } StartCoroutine(parent.LockDuringAction(currentBehaviour.actionLock)); //time spent "casting" the skill (locked in place) whereas action duration is how long it sticks around PreparedAction defaultAction = builder.ReturnPreparedAction(parent.unitData.ValueContainer); defaultAction.Initialize(parent, currentDirection); //get components and set info from Players passives }
public void RegisterAction(PreparedAction action) { actions = (PreparedAction)Delegate.Combine(actions, action); }
public void RegisterDelayedAction(PreparedAction action) { delayedActions = (PreparedAction)Delegate.Combine(delayedActions, action); }
public void ClearActions() { actions = null; }