public IEnumerator Fire(MovementController ctr, UtilityAction act) { act.isStoppable = false; BossController btr = ctr as BossController; BossHandController hand = btr.SelectOneHand(); hand.anim.SetBool("Aim", true); Coroutine co = StartCoroutine(this.HandFire(btr, hand)); if (Random.Range(0, 100) < this.boss.doubleAttackProbability) { BossHandController hand2 = btr.SelectOtherHand(hand); hand2.anim.SetBool("Aim", true); yield return(btr.Aim(hand2)); yield return(btr.Fire(hand2)); yield return(btr.Reset(hand2)); } yield return(co); act.isRunning = false; }
public IEnumerator Reset(BossHandController hand) { Transform tr; Vector3 fromPosition, toPosition; Quaternion fromRotation, toRotation; float step; tr = hand.transform; fromRotation = tr.rotation; fromPosition = tr.localPosition; toRotation = Quaternion.identity; toPosition = hand.baseLocalPosition; tr.localScale = new Vector3(tr.localScale.x, tr.localScale.y, (hand.isRightHand) ? -1 : 1); step = 0f; while (step < 1f) { step += Time.deltaTime * this.boss.resetSpeed; tr.localPosition = Vector3.Slerp(fromPosition, toPosition, step); tr.rotation = Quaternion.Slerp(fromRotation, toRotation, step); yield return(null); } tr.localPosition = toPosition; tr.rotation = toRotation; }
public IEnumerator Death(MovementController ctr, UtilityAction act) { act.isStoppable = false; if (this.isDead) { yield break; } BossController btr = ctr as BossController; BossHandController hand1 = btr.SelectOneHand(); BossHandController hand2 = btr.SelectOtherHand(hand1); this.TryStopCoroutine(ref this.followCoroutine); hand1.anim.SetTrigger("Death"); hand2.anim.SetTrigger("Death"); Coroutine c1 = StartCoroutine(btr.Reset(hand1)); yield return(btr.Reset(hand2)); yield return(c1); this.isDead = true; act.isRunning = false; }
private IEnumerator HandPunch(BossController btr, BossHandController hand) { yield return(btr.Aim(hand)); yield return(btr.Punch(hand)); yield return(btr.Reset(hand)); }
void Start() { bossHead.velocity = new Vector2(0f, 1f); score = GameObject.Find("GameController").GetComponent <GameController>(); bossHandController = gameObject.GetComponentInChildren <BossHandController>(); StartCoroutine(Attack(3.0f)); }
public IEnumerator Fire(BossHandController hand) { float clock; // load clock = 0f; // Debug.Log("To do !"); while (clock < this.boss.loadDuration) { clock += Time.deltaTime; } // fire clock = 0f; Weapon weapon = hand.GetOneWeapon(); if (weapon is ShotGun || weapon is ColtGun) { weapon.Shoot(); } else if (weapon is MachineGun) { while (clock < this.boss.fireDuration) { clock += Time.deltaTime; weapon.Shoot(); yield return(null); } } else { WaitForSeconds delay = new WaitForSeconds(0.1f); for (int i = 0; i < 5; i++) { weapon.Shoot(); yield return(delay); } } hand.anim.SetBool("Aim", false); this.boss.SwitchMode(); }
public IEnumerator Punch(BossHandController hand) { Vector3 dir, from, to; Transform tr; float step; hand.isPunching = true; tr = hand.transform; step = 0f; dir = this.player.position + Vector3.up * 0.5f - tr.position; from = tr.position; to = from + 2f * dir; while (step < 1f) { step += Time.deltaTime * this.boss.punchSpeedCurve.Evaluate(step); tr.position = Vector3.Slerp(from, to, step); yield return(null); } hand.isPunching = false; hand.anim.SetBool("Close", false); }
public IEnumerator Aim(BossHandController hand) { Vector3 targetPosition, reference, align; Quaternion ajust; Transform tr; float clock, horizontal, vertical; float delay; int dir; clock = 0f; reference = Vector3.zero; tr = hand.transform; dir = (hand.isRightHand) ? -1 : 1; horizontal = dir * Random.Range(this.boss.aimHorizontalRangeOffset[0], this.boss.aimHorizontalRangeOffset[1]); vertical = Random.Range(this.boss.aimVerticalRangeOffset[0], this.boss.aimVerticalRangeOffset[1]); ajust = Quaternion.Euler(0, 90, 90); tr.localScale = new Vector3(tr.localScale.x, tr.localScale.y, -tr.localScale.z); delay = Random.Range(this.boss.aimDuration + 0.75f, this.boss.aimDuration - 0.75f); while (clock < delay) { clock += Time.deltaTime; // follow targetPosition = this.player.position + Vector3.up * vertical + Vector3.right * horizontal; tr.position = Vector3.SmoothDamp(tr.position, targetPosition, ref reference, this.boss.aimSmooth); // aim align = this.player.position + Vector3.up * 0.5f - tr.position; tr.rotation = Quaternion.LookRotation(align, -dir * Vector3.up) * ajust; yield return(null); } }
public BossHandController SelectOtherHand(BossHandController h) => (h == this.hands[0]) ? this.hands[1] : this.hands[0];