示例#1
0
 public void AddHit(HitAccuracy hit)
 {
     HitList.Add(hit);
     Multiplier = CalculateEfficiency() / 2;
     scoreAdded = 0;
     if (hit.Accuracy > HeroAttack.MIN_CHARGE)
     {
         // Calculate score increase
         int baseScore;
         switch (ConvertHitRate(hit.Accuracy)) {
             case 4: case 5: baseScore = lcs.averageScore; break;
             case 6: case 7: baseScore = lcs.goodScore; break;
             case 8: case 9: baseScore = lcs.excellentScore; break;
             case 10: baseScore = lcs.perfectScore; break;
             default: baseScore = 0; break;
         }
         if (baseScore > 0)
         {
             baseScore *= hit.NumberOfHits;
             if (hit.NumberOfHits == 2)
                 baseScore += lcs.doubleScore;
             else if (hit.NumberOfHits == 3)
                 baseScore += lcs.tripleScore;
             SCORE += baseScore;
             scoreAdded = baseScore;
         }
     }
     AttackFeedback(hit);
 }
示例#2
0
    public void AttackFeedback(HitAccuracy ha)
    {
        int accuracy = ConvertHitRate(ha.Accuracy);

        switch (accuracy)
        {
            case -2: hitFeedback = "Fail"; break;
            case -1:
            case 0: hitFeedback = "Miss"; break;
            case 1:
            case 2:
            case 3: hitFeedback = "Bad"; break;
            case 4:
            case 5: hitFeedback = "Good"; lcs.averages+= ha.NumberOfHits; break;
            case 6:
            case 7: hitFeedback = "Great"; lcs.goods+= ha.NumberOfHits; break;
            case 8:
            case 9: hitFeedback = "Excellent"; lcs.excellents+= ha.NumberOfHits; break;
            case 10: hitFeedback = "Perfect"; lcs.perfects+= ha.NumberOfHits; break;
        }
        if (ha.NumberOfHits == 2)
        {
            hitFeedback += " Double Kill";
            lcs.doubleKills++;
        }
        else if (ha.NumberOfHits == 3)
        {
            hitFeedback += " Triple Kill";
            lcs.tripleKills++;
        }
        hitFeedback += "!";

        if (feedbackCountdown > 0)
        {
            if (accuracy == 0 || accuracy == -1)
                hitFeedback = "";
        }
        else
            feedbackCountdown = 0.5f;
    }
示例#3
0
    void Update()
    {
        if (Time.timeScale <= 0)
            return;

        if (hm.Charging)
        {
            charging = false;
            GUI.ResetBar();
            GUI.BarActive = false;
            anim.SetInteger("AttackState", 0);
        }

        //if (anim != null)
        //    print(anim.GetInteger("AttackState") + ", charging: " + charging);
        if (hm == null)
        {
            hm = ObstacleController.PLAYER.GetComponent<HeroMovement>();
            anim = ObstacleController.PLAYER.GetComponent<Animator>();
            anim.SetLayerWeight(1, 1);
            anim.SetLayerWeight(2, 1);
            anim.SetLayerWeight(3, 1);
        }

        if (Input.GetButtonDown("Fire1") && !hm.Charging)
        {
            //print("Fire1 down");
            // Start charging attack
            charging = true;
            chargePercent = 0;
            chargeTime = 0;
            GUI.BarActive = true;
            GUI.lastEngagePercent = 0;

            anim.SetInteger("AttackState", 1);
        }

        if (charging)
        {
            if (chargeTime > MaxCharge * 1.1f)
            {
                // Stop attacking - overcharged
                charging = false;
                GUI.ResetBar();
                GUI.BarActive = false;
                anim.SetInteger("AttackState", 0);
                return;
            }
            else
            {
                // Continue charging attack
                chargeTime += Time.deltaTime;

                //if (false)
                //{
                //    chargePercent = chargeTime;
                //}
                //else
                //{
                lastChargePercent = chargePercent;
                chargePercent = ChargeSmoothing(chargeTime);
                //}
                //print("ChargePercent: " + chargePercent);
                float percent = chargePercent * 100;
                if (lastChargePercent > chargePercent)
                {
                    percent = (1 + (1 - chargePercent)) * 100;
                }

                //print("chargePercent: " + chargePercent + ", percent: " + percent + ", time: " + chargeTime);
                GUI.engagePercent = percent;
            }
        }
        else if (anim != null && anim.GetInteger("AttackState") == 2)
        {
            if (attackAnimCountdown > 0)
                attackAnimCountdown -= Time.deltaTime;
            else
            {
                attackAnimCountdown = 0;
                anim.SetInteger("AttackState", 0);
            }
        }

        if (Input.GetButtonUp("Fire1"))
        {
            //print("Fire1 up");
            // Release attack - hit if in a collider box

            anim.SetInteger("AttackState", 2);
            attackAnimCountdown = attackAnimLength;
            GUI.ResetBar();
            GUI.BarActive = false;
            if (charging)
            {
                if (hitableEnemies.Count > 0)
                {
                    int ri = UnityEngine.Random.Range(0, 2);
                    if (ri == 1)
                        SoundKill1.Play();
                    else
                        SoundKill2.Play();

                    HitAccuracy ha = new HitAccuracy();
                    ha.Accuracy = chargePercent;
                    ha.NumberOfHits = hitableEnemies.Count;
                    ha.CurrentSpeed = hm.CurrentSpeed;

                    //print(ha.ToString());

                    hm.SpeedUp += 0.5f; //capped at 4.0f in the setter
                    if (!hm.Charging)
                    {
                        hm.Rage = Mathf.Min(hm.Rage + chargePercent / 5, 1);
                    }
                    GUI.AddHit(ha);
                    //   GUI.AttackFeedback(chargePercent);

                    if (chargePercent > MIN_CHARGE)
                    {
                        foreach (GameObject enemy in hitableEnemies)
                        {
                            KillEnemy(enemy);
                        }
                    }
                    hitableEnemies.Clear();
                }
                else
                {
                    HitAccuracy ha = new HitAccuracy();
                    ha.Accuracy = -1;
                    ha.NumberOfHits = 0;
                    ha.CurrentSpeed = hm.CurrentSpeed;
                    GUI.AddHit(ha);
                    if (!hm.complete && !hm.dead)
                        SoundMiss.Play();
                }
            }
            charging = false;
            GUI.lastEngagePercent = 0;
        }
    }
示例#4
0
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.name.Equals("ReleaseBox"))
        {
            GameObject enemy = other.transform.parent.gameObject;
            if (!hitableEnemies.Contains(enemy))
            {
                hitableEnemies.Add(enemy);
            }
        }

        if (other.gameObject.name.Equals("AnimationBox"))
        {
            GameObject enemy = other.transform.parent.gameObject;
            enemy.GetComponent<Animator>().SetBool("Attack", true);
        }

        if (other.gameObject.name.Equals("EnemyBox"))
        {
            GameObject enemy = other.transform.parent.gameObject;
            Vector3 exppos = ObstacleController.PLAYER.transform.position;
            exppos.y += 1;

            EnemyAttack ea = other.transform.parent.GetComponent<EnemyAttack>();
            ea.AddExplosion(hm.CurrentSpeed / 4 * 400, exppos);
            //  other.transform.parent.GetComponent<EnemyAttack>().KillSelf();
            hm.SlowHero(SlowTime, SlowAmount);

            if (!hm.Charging)
            {
                HitAccuracy ha = new HitAccuracy();
                ha.Accuracy = -2;
                ha.NumberOfHits = 0;
                ha.CurrentSpeed = hm.CurrentSpeed;
                GUI.AddHit(ha);
                ea.PlaySound();
            }
            else
            {
                HitAccuracy ha = new HitAccuracy();
                ha.Accuracy = 10;
                ha.NumberOfHits = 1;
                ha.CurrentSpeed = hm.CurrentSpeed;
                GUI.AddHit(ha);
                KillEnemy(enemy);
                int ri = UnityEngine.Random.Range(0, 2);
                if (ri == 1)
                    SoundKill1.Play();
                else
                    SoundKill2.Play();
            }
            if (hitableEnemies.Contains(enemy))
            {
                hitableEnemies.Remove(enemy);
            }
        }
    }
示例#5
0
    void Update()
    {
        if (Input.GetButtonDown("Fire1"))
        {
            print("Fire1 down");
            // Start charging attack
            charging = true;
            chargePercent = 0;
            chargeTime = 0;
            GUI.BarActive = true;
        }

        if (charging)
        {
            if (chargeTime > MaxCharge)
            {
                // Stop attacking - overcharged
                charging = false;
                GUI.ResetBar();
                GUI.BarActive = false;
            }
            else
            {
                // Continue charging attack
                chargeTime += Time.deltaTime;

                //if (false)
                //{
                //    chargePercent = chargeTime;
                //}
                //else
                //{
                    chargePercent = ChargeSmoothing(chargeTime);
                //}

                float percent = chargePercent * 100;
                print("chargePercent: " + chargePercent + ", percent: " + percent + ", time: " + chargeTime);
                GUI.engagePercent = percent;
            }
        }

        if (Input.GetButtonUp("Fire1"))
        {
            print("Fire1 up");
            // Release attack - hit if in a collider box

            GUI.ResetBar();
            GUI.BarActive = false;
            if (charging)
            {
                if (hitableEnemies.Count > 0)
                {
                    HitAccuracy ha = new HitAccuracy();
                    ha.Accuracy = chargePercent;
                    ha.NumberOfHits = hitableEnemies.Count;

                    print(ha.ToString());

                    GUI.HitList.Add(ha);

                    foreach (GameObject enemy in hitableEnemies)
                    {
                        KillEnemy(enemy);
                    }
                    hitableEnemies.Clear();
                }

            }
            charging = false;
        }
    }