Пример #1
0
    void HandleTouch(TouchSide touchSide, TouchType touchType)
    {
        if (touchSide == TouchSide.Left)
        {
            if (touchType == TouchType.OnDown)
            {
                shooter.TurnOnShield();
            }
            else if (touchType == TouchType.OnRelease)
            {
                shooter.TurnOffShield();
            }
        }

        else if (touchSide == TouchSide.Right)
        {
            if (touchType == TouchType.OnDown)
            {
                if (!shooter.shield.isOn)
                {
                    if (shooter.CanFire())
                    {
                        if (shooter.gun.isAutomatic)
                        {
                            shooter.StartAutoFiring();
                        }
                        else
                        {
                            shooter.Fire(true);
                        }
                    }
                    else if (shooter.CanReload())
                    {
                        shooter.StartReloading();
                    }
                }
            }
            else if (touchType == TouchType.OnRelease)
            {
                if (shooter.isAutoFiring)
                {
                    shooter.StopAutoFiring();
                }
                if (shooter.isReloading)
                {
                    shooter.StopReloading();
                }
            }
        }
    }