Exemple #1
0
    private void testT()
    {
        string         s = Resources.Load("a").ToString();
        RollerItemData l = JsonMapper.ToObject <RollerItemData>(s);

        Debug.Log(l);
    }
Exemple #2
0
    //展示roll结果
    private void showResault(RollData rollData)
    {
        RollerItemData rollItem = rollData.rollerItem;

        if (rollItem.type == "energy")
        {
            ShowEnergy();
        }
        else if (rollItem.type == "shield")
        {
            ShowShield(shieldCount < rollData.shields);
        }
        else if (rollItem.type == "steal")
        {
            beaver.SetActive(true);
            GameMainManager.instance.audioManager.PlaySound(AudioNameEnum.wheel_steal);
            Sequence sq = DOTween.Sequence();
            sq.AppendInterval(1.3f);
            sq.InsertCallback(0.5f, () => {
                GameMainManager.instance.audioManager.PlaySound(AudioNameEnum.wheel_steal_gone);
            });
            sq.AppendCallback(() => {
                beaver.SetActive(false);
                GameMainManager.instance.uiManager.EnableOperation();
                Dictionary <UISettings.UIWindowID, object> stateData = new Dictionary <UISettings.UIWindowID, object>();
                stateData.Add(UISettings.UIWindowID.UIStealWindow, rollData.stealIslands);
                GameMainManager.instance.uiManager.ChangeState(new UIStateChangeBase(stateData, null, 2));
            });
        }
        else if (rollItem.type == "shoot")
        {
            GameMainManager.instance.audioManager.PlaySound(AudioNameEnum.wheel_attack_prepare);
            GameMainManager.instance.uiManager.EnableOperation();
            Dictionary <UISettings.UIWindowID, object> stateData = new Dictionary <UISettings.UIWindowID, object>();
            stateData.Add(UISettings.UIWindowID.UIAttackWindow, rollData.attackTarget);
            GameMainManager.instance.uiManager.ChangeState(new UIStateChangeBase(stateData));
        }
        else if (rollItem.type == "xcrowns")
        {
            GameMainManager.instance.audioManager.PlaySound(AudioNameEnum.wheel_Star);

            int money = rollItem.code;

            getStarEffect.gameObject.SetActive(true);
            getStarEffect.Show(user.crowns, rollItem.code, () => {
                goldEffect.emission.SetBursts(new ParticleSystem.Burst[1] {
                    new ParticleSystem.Burst(0, 80, 100, 1, 0.01f)
                });
                goldEffect.Play();
                energyValue = user.energy;
                GameMainManager.instance.audioManager.PlaySound(AudioNameEnum.wheel_gold_large);
                EventDispatcher.instance.DispatchEvent(new UpdateBaseDataEvent(UpdateBaseDataEvent.UpdateType.Money, 0));
                GameMainManager.instance.uiManager.EnableOperation();
            });
        }
        else if (rollItem.type == "coin")
        {
            int money = rollItem.code;

            if (money < 10000)
            {
                goldEffect.emission.SetBursts(new ParticleSystem.Burst[1] {
                    new ParticleSystem.Burst(0, 10, 20, 1, 0.01f)
                });
                GameMainManager.instance.audioManager.PlaySound(AudioNameEnum.wheel_gold_small);
            }
            else if (money < 50000)
            {
                goldEffect.emission.SetBursts(new ParticleSystem.Burst[1] {
                    new ParticleSystem.Burst(0, 20, 50, 1, 0.01f)
                });
                GameMainManager.instance.audioManager.PlaySound(AudioNameEnum.wheel_gold_med);
            }
            else if (money < 100000)
            {
                goldEffect.emission.SetBursts(new ParticleSystem.Burst[1] {
                    new ParticleSystem.Burst(0, 50, 80, 1, 0.01f)
                });
                GameMainManager.instance.audioManager.PlaySound(AudioNameEnum.wheel_gold_large);
            }
            else
            {
                goldEffect.emission.SetBursts(new ParticleSystem.Burst[1] {
                    new ParticleSystem.Burst(0, 80, 100, 1, 0.01f)
                });
                GameMainManager.instance.audioManager.PlaySound(AudioNameEnum.wheel_gold_large);
            }
            goldEffect.Play();
            energyValue = user.energy;
            GameMainManager.instance.uiManager.EnableOperation();
            EventDispatcher.instance.DispatchEvent(new UpdateBaseDataEvent(UpdateBaseDataEvent.UpdateType.Money, 0));
        }
    }
Exemple #3
0
    private IEnumerator StartRoll()
    {
        isWorking = true;
        GameMainManager.instance.uiManager.DisableOperation();

        bool           getRes   = false;
        RollerItemData rollItem = null;
        RollData       rollData = null;
        float          timeTag  = Time.time;

        shieldCount = GameMainManager.instance.model.userData.shields;
        GameMainManager.instance.netManager.Roll((ret, data) => {
            if (data.isOK)
            {
                getRes   = true;
                rollData = data.data;
                rollItem = data.data.rollerItem;

                energyValue = user.energy - 1;
            }
            else
            {
                isWorking = false;
                getRes    = true;
                GameMainManager.instance.uiManager.EnableOperation();
            }
        });
        AudioSource audio = GetComponent <AudioSource>();

        audio.clip   = audioClips[0];
        audio.loop   = true;
        audio.volume = AudioManager.instance.soundVolume;
        audio.Play();
        reflective.DOFade(1, 0.5f);
        while (!getRes || (Time.time - timeTag) < 2)
        {
            wheel.Rotate(new Vector3(0, 0, -360 * 4) * Time.deltaTime);

            yield return(null);
        }

        reflective.DOFade(0, 1f);
        if (rollItem == null)
        {
            wheel.DOLocalRotate(new Vector3(0, 0, -(360 * 1 + 36 * 0)), 2f, RotateMode.FastBeyond360).SetEase(Ease.OutCirc);
            yield break;
        }
        audio.clip   = audioClips[1];
        audio.loop   = false;
        audio.volume = AudioManager.instance.soundVolume;
        audio.Play();
        wheel.DOLocalRotate(new Vector3(0, 0, -(360 * 1 + 36 * rollItem.index)), 2f, RotateMode.FastBeyond360).SetEase(Ease.OutCirc).OnComplete(() => {
            showResault(rollData);
            audio.Stop();
            isWorking = false;

            if (isHoldOn && (rollData.rollerItem.type == "coin" ||
                             rollData.rollerItem.type == "shield" ||
                             rollData.rollerItem.type == "xcrowns" ||
                             rollData.rollerItem.type == "energy"))
            {
                Roll();
            }
        });
    }