public static AttackTask CreateTask(string taskId, string targetId, string targetName, Dictionary <CombatUnit, int> targetUnit, Dictionary <CombatUnit, int> playerUnit, OnAttackComplete completeCallBack = null, OnTimeLeftToComplete timeLeftCallBack = null, int duration = 1) { AttackTask task = new AttackTask(); task.InitTask(taskId, targetId, targetName, targetUnit, playerUnit, completeCallBack, timeLeftCallBack, duration); return(task); }
void DetectHitReactions() { if (!isAlive) { SetToMagicCameraAngle(); if (animator.onAnimationComplete("Hit Reaction", 0.9f)) { animator.Play("Death"); } if (animator.onAnimationComplete("Critical Hit Reaction", 0.9f)) { animator.Play("Death"); } if (animator.onAnimationComplete("Death", 0.95f)) { this.gameObject.SetActive(false); OnAttackComplete.Invoke(); OnDeathComplete.Invoke(); } return; } if (animator.onAnimationComplete("Hit Reaction", 0.95f)) { timesHit += 1; OnHitReactionComplete.Invoke(); } if (animator.onAnimationComplete("Critical Hit Reaction", 0.95f)) { timesHit += 1; OnHitReactionComplete.Invoke(); } if (animator.onAnimationComplete("Dodge", 0.95f)) { OnHitReactionComplete.Invoke(); } if (animator.onAnimationComplete("Critical Hit Dodge", 0.95f)) { OnHitReactionComplete.Invoke(); } }
public void InitTask(string taskId, string targetId, string targetName, Dictionary <CombatUnit, int> targetUnit, Dictionary <CombatUnit, int> playerUnit, OnAttackComplete completeCallBack = null, OnTimeLeftToComplete timeLeftCallBack = null, int duration = 1) { base.InitTask(duration, timeLeftCallBack); _taskId = taskId; _targetPlayerId = targetId; _targetPlayerName = targetName; _targetPlayerUnit = targetUnit; _playerUnit = playerUnit; _waitDuration = duration; Evt_OnAttackComplete += completeCallBack; }
// Update is called once per frame void Update() { DetectHitReactions(); if (!isAlive) { SetToMagicCameraAngle(); if (animator.onAnimationComplete("Hit Reaction", 0.9f)) { animator.Play("Death"); } if (animator.onAnimationComplete("Critical Hit Reaction", 0.9f)) { animator.Play("Death"); } if (animator.onAnimationComplete("Death", 0.95f)) { this.gameObject.SetActive(false); OnAttackComplete.Invoke(); OnDeathComplete.Invoke(); } } if (attacking && isAlive) { Battler opposingBattler = attackTarget.GetComponent <Battler>(); if (!targetsLocked) { foreach (Transform child in opposingBattler.GetComponentsInChildren <Transform>()) { if (child.tag == "Projectile Target") { projectileTarget = child; targetsLocked = true; } } } opposingBattler.OnHitReactionComplete.AddListener(delegate { attacking = false; completedAttack = true; // enemyWeaponCollider.SetActive(false); OnAttackComplete.Invoke(); }); opposingBattler.OnDeathComplete.AddListener(delegate { attacking = false; completedAttack = true; OnAttackComplete.Invoke(); }); if (!attacked) { mainCamera.transform.position = opposingBattler.magicTargetCameraAngle.transform.position; mainCamera.transform.rotation = opposingBattler.magicTargetCameraAngle.transform.rotation; if (!windingUp) { windingUp = true; bool isAttackCritical = AttackIsCritical(); transform.LookAt(attackTarget.transform); if (isAttackCritical) { animator.Play("Critical Attack"); } else { animator.Play("Attack"); } } if (animator.onAnimationComplete("Attack", 0.19f)) { if (!spawnedArrow) { arrowInstance = bow.SpawnArrow(arrowSpawnPoint); spawnedArrow = true; } } if (animator.onAnimationComplete("Attack", 0.7f)) { arrowInstance.OnArrowFired.AddListener(delegate { attacked = true; }); arrowInstance.HalfwayToTarget.AddListener(delegate { SetToMagicTargetCameraAngle(); opposingBattler.OnDodgeComplete.AddListener(delegate { arrowInstance.Reset(); attacking = false; completedAttack = true; OnAttackComplete.Invoke(); }); // dodgedArrow = opposingBattler.AttemptDodgeArrow(arrowInstance); }); arrowInstance.ReachedTarget.AddListener(delegate { reachedEnemy = true; }); if (!firedArrow) { arrowInstance.Shoot(projectileTarget, projectileLaunchPoint); firedArrow = true; } } if (animator.onAnimationComplete("Critical Attack", 0.3f)) { if (!spawnedArrow) { arrowInstance = bow.SpawnArrow(arrowSpawnPoint); spawnedArrow = true; } } if (animator.onAnimationComplete("Shoot Arrow", 0.3f)) { arrowInstance.OnArrowFired.AddListener(delegate { attacked = true; }); arrowInstance.HalfwayToTarget.AddListener(delegate { SetToMagicTargetCameraAngle(); opposingBattler.OnDodgeComplete.AddListener(delegate { arrowInstance.Reset(); attacking = false; completedAttack = true; OnAttackComplete.Invoke(); }); // dodgedArrow = opposingBattler.AttemptDodgeArrow(arrowInstance); }); arrowInstance.ReachedTarget.AddListener(delegate { reachedEnemy = true; }); if (!firedArrow) { arrowInstance.Shoot(projectileTarget, projectileLaunchPoint); firedArrow = true; } } return; } if (!reachedEnemy) { bool finishedAttacking = animator.onAnimationComplete("Attack", 1f) || animator.onAnimationComplete("Shoot Arrow", 1f); if (finishedAttacking) { animator.Play("Idle"); } } else { if (!dodgedArrow) { SetCameraToDefault(); } } } }
void AttackComplete() { OnAttackComplete?.Invoke(); }
// Update is called once per frame void Update() { DetectHitReactions(); if (attacking) { if (!reachedEnemy) { if (Vector3.Distance(transform.position, attackTarget.transform.position) < 3.2f) { reachedEnemy = true; SetCameraToBattler(); } else { animator.Play("Run"); transform.LookAt(attackTarget.transform, Vector3.up); transform.position = Vector3.MoveTowards(transform.position, attackTarget.transform.position, moveSpeed * Time.deltaTime); } return; } if (!attacked) { weaponColliderObject.SetActive(true); animator.Play("Great Sword Slash"); if (animator.onAnimationComplete("Great Sword Slash", .35f)) { weaponColliderObject.SetActive(false); attacked = true; } return; } if (!turned) { animator.Play("Great Sword 180 Turn"); if (animator.onAnimationComplete("Great Sword 180 Turn", .25f)) { transform.LookAt(standTarget.transform); turned = true; animator.Play("Run"); } } else { MoveToStandTarget(); if (Vector3.Distance(transform.position, standTarget.transform.position) < 3.0f) { SetToStandTarget(); SetCameraToDefault(); attacking = false; completedAttack = true; transform.LookAt(attackTarget.transform); animator.Play("Idle"); OnAttackComplete.Invoke(); } } } }
// Update is called once per frame void Update() { DetectHitReactions(); if (!isAlive) { SetToMagicCameraAngle(); if (animator.onAnimationComplete("Hit Reaction", 0.9f)) { animator.Play("Death"); } if (animator.onAnimationComplete("Critical Hit Reaction", 0.9f)) { animator.Play("Death"); } if (animator.onAnimationComplete("Death", 0.95f)) { this.gameObject.SetActive(false); OnAttackComplete.Invoke(); OnDeathComplete.Invoke(); } } if (attacking && isAlive) { Battler opposingBattler = attackTarget.GetComponent <Battler>(); GameObject enemyWeaponCollider = null; if (opposingBattler.BattlerType == "Swordsman") { enemyWeaponCollider = attackTarget.GetComponent <SwordsmanBattler>().weaponColliderObject; } opposingBattler.OnHitReactionComplete.AddListener(delegate { attacking = false; completedAttack = true; if (enemyWeaponCollider != null) { enemyWeaponCollider.SetActive(false); } OnAttackComplete.Invoke(); }); opposingBattler.OnDeathComplete.AddListener(delegate { attacking = false; completedAttack = true; OnAttackComplete.Invoke(); }); if (!attacked) { SetToMagicCameraAngle(); transform.LookAt(attackTarget.transform); animator.Play("Standing 2H Magic Attack 3"); if (animator.onAnimationComplete("Standing 2H Magic Attack 3", .3f) && !circleSpawned) { grimiore.OnCastingCircleSpawn.AddListener(delegate { circleSpawned = true; }); grimiore.SpawnCastingCircle(castingCircleTarget); } if (animator.onAnimationComplete("Standing 2H Magic Attack 3", .8f)) { grimiore.OnParticleEffectSpawn.AddListener(delegate { attacked = true; }); grimiore.OnParticleEffectHalfway.AddListener(delegate { if (!reachedEnemy) { grimiore.DestroyCastingCircle(); SetToMagicTargetCameraAngle(); opposingBattler.OnDodgeComplete.AddListener(delegate { projectileInstance.Reset(); attacking = false; completedAttack = true; entity.HasMoved = true; if (enemyWeaponCollider != null) { enemyWeaponCollider.SetActive(false); } OnAttackComplete.Invoke(); }); dodgedAttack = opposingBattler.AttemptMagicDodge(projectileInstance); if (enemyWeaponCollider != null) { enemyWeaponCollider.SetActive(true); // Prevent bouncing off weapon's mesh... } } }); grimiore.OnParticleEffectLanded.AddListener(delegate { reachedEnemy = true; }); if (grimiore.magicEffect.particleType == "Magic Projectile") { LaunchMagicProjectile(); } } return; } if (!reachedEnemy) { if (animator.onAnimationComplete("Standing 2H Magic Attack 3", 1f)) { animator.Play("Idle"); } } else { if (!dodgedAttack) { SetCameraToDefault(); } } } }