public IEnumerator DoLogic() { while (!damageable.IsDead) { yield return(Patrol.PatrolUntilSight(movement, patrolParameters, sight)); movement.LockRotation(); Collider2D target = sight.GetVisibleObject(); if (target != null) { yield return(LineUpShot.LineUp(target.transform, shootFrom.transform, movement, sight, targetOffset, lineUpSpeed)); if (sight.canSeeObject(target.gameObject)) { shootFrom.Fire(gunStats); gunStats.SetShotsLeft(variableStore, gunStats.GetShotsLeft(variableStore) - 1); yield return(AsyncUtil.Pause(postFireDelay)); if (gunStats.GetShotsLeft(variableStore) <= 0) { var possibleCover = pathfinder.GetPathFinding().FindCover(target.transform.position, 0.5f); pathfinder.PathToNearest(possibleCover); movement.UnlockRotation(); var previousLocation = transform.position; yield return(pathfinder.FollowPath()); movement.TargetVelocity = Vector2.zero; yield return(ReloadGun.ReloadAnimation(gunStats, reloadLocation, variableStore)); pathfinder.PathTo(previousLocation); yield return(pathfinder.FollowPath()); movement.LockRotation(); } } } movement.UnlockRotation(); } }
IEnumerator SwingSword() { if (!swingingSword) { movement.TargetVelocity = Vector2.zero; movement.LockRotation(); DamageSource source = new DamageSource(swordDamage, direction.TransformDirection(Vector3.right), transform.position); swingingSword = true; IEnumerator swordSwing = sword.Swing(hit => { Projectile projectile = hit.gameObject.GetComponent <Projectile>(); if (projectile != null) { Vector2 normal = projectile.transform.position - transform.position; projectile.Redirect(Vector2.Reflect(projectile.Velocity, (normal - projectile.Velocity.normalized * 3.0f).normalized), LayerMask.NameToLayer("L1: Player Weapon")); } else { Damageable target = hit.gameObject.GetComponent <Damageable>(); if (target != null) { target.Damage(source); } } }); while (swordSwing.MoveNext()) { yield return(swordSwing.Current); } swingingSword = false; movement.UnlockRotation(); } }
public IEnumerator DoLogic() { while (!damageable.IsDead) { yield return(Patrol.PatrolUntilSight(movement, patrolParameters, sight)); movement.LockRotation(); Collider2D target = sight.GetVisibleObject(); if (target != null) { yield return(LineUpShot.LineUp(target.transform, shootFrom.transform, movement, sight, targetOffset, lineUpSpeed)); if (sight.canSeeObject(target.gameObject)) { if (animation != null) { animation.SetTigger("Firing"); } yield return(AsyncUtil.Pause(preFireDelay)); shootFrom.Fire(gunStats); gunStats.SetShotsLeft(variableStore, gunStats.GetShotsLeft(variableStore) - 1); yield return(AsyncUtil.Pause(postFireDelay)); if (gunStats.GetShotsLeft(variableStore) <= 0) { yield return(ReloadGun.ReloadAnimation(gunStats, reloadLocation, variableStore)); } } } movement.UnlockRotation(); } }
public override void StateEnd() { animator.SetBool("IsAiming", false); movement.UnlockRotation(); cameraTarget.targetOffset = Vector3.zero; }
public override void StateEnd() { movement.UnlockRotation(); }