Exemplo n.º 1
0
    override protected void Update()
    {
        if (paused)
        {
            return;
        }
        base.Update();

        if (isDragging || isOnBench)
        {
            if (isDragging)
            {
                anim.SetInteger("State", DRAGGING);
            }
            else if (isOnBench)
            {
                idle(false);
            }

            fireTimer = fireRatePerSecond;
            return;
        }

        bool enemyAhead = isEnemyAhead();

        idle(enemyAhead);

        if (enemyAhead)
        {
            List <HeroType> powerList = PowerManagement.getPowerList((uint)colPos, (uint)rowPos);

            fireTimer -= Time.deltaTime;

            bool quickShot = false;
            if (powerList.Contains(HeroType.SPEED_POWER_CONVERTER))
            {
                fireTimer -= Time.deltaTime;                 // subtract it again to double the speed
                quickShot  = true;
            }

            if (fireTimer <= 0.0f)
            {
                fireTimer = fireRatePerSecond;
                anim.SetInteger("State", SHOOT);
                StartCoroutine(waitToIdle());

                GameObject bullet;

                // The problem here is that it can be both heavy and ice
                // need to find a way to make this scale better
                if (powerList.Contains(HeroType.DAMAGE_POWER_CONVERTER))
                {
                    if (powerList.Contains(HeroType.ICE_POWER_CONVERTER))
                    {
                        bullet = fireHeavyIceBullet();
                    }
                    else
                    {
                        bullet = fireSniperBullet();
                    }
                }
                else if (powerList.Contains(HeroType.ICE_POWER_CONVERTER))
                {
                    bullet = fireIceBullet();
                }
                else
                {
                    bullet = fireSimpleBullet();
                }

                bullet.GetComponent <BulletScript> ().setWasQuickShot(quickShot);
            }

            return;
        }
    }