Beispiel #1
0
    protected override void Awake()
    {
        base.Awake();
        Transform parent = transform.parent;

        if (parent)
        {
            m_Parent = parent.GetComponentInParent <CustomScrollRect>();
        }
        m_Direction = this.horizontal ? Direction.Horizontal : Direction.Vertical;
    }
Beispiel #2
0
    private IEnumerator TankScrollRoutine()
    {
        float            velocity      = 0f;
        float            multiple      = 1f / (float)(tanks.Length - 1);
        int              lastIndex     = -1;
        float            timeSinceLast = 0f;
        CustomScrollRect sr            = tankScrollRect;

        sr.horizontalNormalizedPosition = (float)tankIndex * multiple;
        while (true)
        {
            float target = (float)tankIndex * multiple;
            int   curr   = tankIndex;
            if (!tankScrollRect.IsDragging)
            {
                sr.horizontalNormalizedPosition = Mathf.SmoothDamp(sr.horizontalNormalizedPosition, target, ref velocity, 0.1f);
            }
            else
            {
                SetTank(Mathf.RoundToInt(Mathf.Clamp01(sr.horizontalNormalizedPosition + Mathf.Sign(sr.velocity.x) * (0f - multiple) * 0.4f) / multiple));
            }
            Vector3 localPosition = tankSlider.transform.localPosition;
            localPosition.x = sr.horizontalNormalizedPosition * tankOffset * (float)(tanks.Length - 1) + tankCameraOffset;
            tankSlider.transform.localPosition = localPosition;
            if (curr != lastIndex && !MenuController.GetMenu <BundlePopup>().isActiveAndEnabled)
            {
                if (garageShootRoutine != null)
                {
                    StopCoroutine(garageShootRoutine);
                    for (int i = 0; i < tanks.Length; i++)
                    {
                        tanks[i].Shoot(val: false);
                    }
                }
                if (timeSinceLast > 0.75f)
                {
                    Tank tank = Variables.instance.GetTank(curr);
                    if (tank.bullet.type == BulletType.Missile || tank.bullet.type == BulletType.Laser)
                    {
                        garageShootRoutine = StartCoroutine(MissileShoot(tanks[curr]));
                    }
                    else if (tank.bullet.type == BulletType.Flame)
                    {
                        garageShootRoutine = StartCoroutine(FlamerShoot(tanks[curr]));
                    }
                    else if (tank.bullet.type == BulletType.Small)
                    {
                        garageShootRoutine = StartCoroutine(BulletShoot(tanks[curr]));
                    }
                    else if (tank.bullet.type == BulletType.Lightning)
                    {
                        garageShootRoutine = StartCoroutine(LightningShoot(tanks[curr]));
                    }
                    else
                    {
                        tanks[curr].Shoot();
                    }
                    lastIndex = tankIndex;
                }
                else
                {
                    timeSinceLast += Time.deltaTime;
                }
            }
            yield return(null);

            if (curr != tankIndex)
            {
                timeSinceLast = 0f;
                lastIndex     = -1;
            }
        }
    }