void SpawnRock() { lastRockThrowTime = Time.time; Vector3 dir = new Vector3(0.2f, -1); float lerp = (float)currentRockThrowCount / (float)rockThrowCount; Vector3 spawnPos = Camera.main.ScreenToWorldPoint(new Vector3(Mathf.Lerp(-Screen.width * 0.05f, Screen.width, lerp), Screen.height)); spawnPos.z = 0; GameObject g = (GameObject)Instantiate(throwableRock, spawnPos, Quaternion.identity); g.GetComponent <bouncingProjectile>().Initialize(dir.normalized * rockSpeed); currentRockThrowCount++; if (currentRockThrowCount >= rockThrowCount) { anim.SetBool("rockstorm", false); currentRockThrowCount = 0; cycle = AttackCycle.OnePunch; ChangePhase(AttackPhase.Punch); } }
public void ChangePhase(AttackPhase phase) { if (this.enabled == false) { return; } this.phase = phase; if (this.phase == AttackPhase.Idle) { anim.CrossFadeInFixedTime("Idle", 0.5f); } else if (this.phase == AttackPhase.RockStorm) { cycle = AttackCycle.RockStorm; anim.SetBool("punching", false); anim.SetBool("rockstorm", true); } else if (this.phase == AttackPhase.ThrowRocks) { anim.CrossFadeInFixedTime("throwDebris", 0.5f); } }
//Start attack cycle void StartAttacking() { cycle = AttackCycle.OnePunch; ChangePhase(AttackPhase.Punch); }