コード例 #1
0
    override public void FixedExecute()
    {
        timer += Time.deltaTime;
        //prepping to attack player
        if (phase == attackPhase.Charging)
        {
            enemy.selfBody.velocity = Vector2.Lerp(enemy.selfBody.velocity, Vector2.zero, Time.deltaTime * chargeLength / 2);

            Vector3    dir            = enemy.currentTarget.transform.position - enemy.transform.position;
            float      angle          = Vector2.Angle(Vector2.up, dir);
            Quaternion targetRotation = Quaternion.AngleAxis(angle, Vector3.forward);
            enemy.transform.rotation = Quaternion.RotateTowards(enemy.transform.rotation, targetRotation, 60 * Time.deltaTime);

            if (Mathf.Abs(enemy.transform.rotation.eulerAngles.z - angle) < 1.0f)
            {
                enemy.transform.rotation = targetRotation;
            }

            if (timer > chargeLength)
            {
                timer = 0.0f;
                phase = attackPhase.Attacking;
                AudioSource.PlayClipAtPoint(enemy.audio[2], enemy.transform.position);
            }
        }
        if (phase == attackPhase.Attacking)
        {
            Vector3 dir = enemy.currentTarget.transform.position - enemy.transform.position;
            enemy.selfBody.velocity = dir.normalized * swimSpeed;

            if (timer > attackLength)
            {
                timer = 0.0f;
                phase = attackPhase.Recovering;
            }
        }
        if (phase == attackPhase.Recovering)
        {
            if (timer > recoveryLength)
            {
                timer = 0.0f;
                phase = attackPhase.Charging;
                AudioSource.PlayClipAtPoint(enemy.audio[1], enemy.transform.position);
            }
        }
    }
コード例 #2
0
ファイル: Combat.cs プロジェクト: valambrian/wbcomtest
 private void AdvanceCurrentPhase()
 {
     if (CurrentPhase == attackPhase.MELEE)
     {
         CurrentPhase = (attackPhase)0;
     }
     else
     {
         CurrentPhase = (attackPhase)((int)CurrentPhase + 1);
     }
     if (PhaseChanged != null)
     {
         PhaseChanged(this, new EventArgs());
     }
 }