예제 #1
0
        //true = success
        bool SetDialog(bool addCallback)
        {
            if (texts != null && texts.Length > 0)
            {
                UIModalCharacterDialog dlg;

                dlg = UIModalCharacterDialog.Open(
                    isLocalize.Value,
                    GetModalRef(),
                    texts[mCurIndex],
                    name.Value,
                    portrait.Value,
                    mCurIndex == texts.Length - 1 ? choices : null);

                if (dlg != null)
                {
                    if (addCallback)
                    {
                        dlg.actionCallback += OnAction;
                    }

                    return(true);
                }
            }

            return(false);
        }
예제 #2
0
        void OnAction(UIModalCharacterDialog dlg, int choiceIndex)
        {
            if (mCurIndex == textIndexEnd.Value)
            {
                //save to variable
                if (!choiceOutput.IsNone)
                {
                    choiceOutput.Value = choiceIndex;
                }

                //close?
                if (closeOnAction.Value && UIModalManager.instance.ModalGetTop() == GetModalRef())
                {
                    UIModalManager.instance.ModalCloseTop();
                }

                //envoke event
                if (!FsmEvent.IsNullOrEmpty(actionEvent))
                {
                    Fsm.Event(actionEvent);
                }

                Finish();
            }
            else
            {
                //go to next
                mCurIndex++;

                if (!SetDialog(false))
                {
                    Finish();
                }
            }
        }
예제 #3
0
 void OnDialogAction(UIModalCharacterDialog dlg, int choiceInd)
 {
     mCurDialogTextInd++;
     if(mCurDialogTextInd == dialogTextRefs.Length) {
         Release();
         dlg.actionCallback -= OnDialogAction;
         UIModalManager.instance.ModalCloseTop(); //assume dialog is top
     }
     else {
         dlg.Apply(true, dialogTextRefs[mCurDialogTextInd], HUD.gitgirlNameRef, HUD.gitgirlPortraitRef, null);
     }
 }
예제 #4
0
        // Code that runs when exiting the state.
        public override void OnExit()
        {
            if (UIModalManager.instance != null)
            {
                UIModalCharacterDialog dlg = UIModalManager.instance.ModalGetController <UIModalCharacterDialog>(
                    GetModalRef());

                if (dlg != null)
                {
                    dlg.actionCallback -= OnAction;
                }
            }
        }
        // Code that runs on entering the state.
        public override void OnEnter()
        {
            UIModalCharacterDialog dlg;

            dlg = UIModalCharacterDialog.Open(
                isLocalize.Value,
                GetModalRef(),
                text.Value,
                name.Value,
                portrait.Value,
                choices);

            if (dlg != null)
            {
                dlg.actionCallback += OnAction;
            }
            else
            {
                Finish();
            }
        }
        void OnAction(UIModalCharacterDialog dlg, int choiceIndex)
        {
            //save to variable
            if (!choiceOutput.IsNone)
            {
                choiceOutput.Value = choiceIndex;
            }

            //close?
            if (closeOnAction.Value && UIModalManager.instance.ModalGetTop() == GetModalRef())
            {
                UIModalManager.instance.ModalCloseTop();
            }

            //envoke event
            if (!FsmEvent.IsNullOrEmpty(actionEvent))
            {
                Fsm.Event(actionEvent);
            }

            Finish();
        }
예제 #7
0
        //true = success
        bool SetDialog(bool addCallback)
        {
            UIModalCharacterDialog dlg;

            dlg = UIModalCharacterDialog.Open(
                true,
                GetModalRef(),
                textPrefix.Value + mCurIndex.ToString(),
                name.Value,
                portrait.Value,
                mCurIndex == textIndexEnd.Value ? choices : null);

            if (dlg != null)
            {
                if (addCallback)
                {
                    dlg.actionCallback += OnAction;
                }

                return(true);
            }

            return(false);
        }
예제 #8
0
    /// <summary>
    /// Force pickup
    /// </summary>
    public void PickUp(Player player)
    {
        if(player && player.state != (int)EntityState.Dead && player.state != (int)EntityState.Invalid && gameObject.activeInHierarchy) {
            float val = value;

            switch(type) {
                case ItemType.Health:
                    if(player.stats.curHP < player.stats.maxHP) {
                        if(player.stats.curHP + val > player.stats.maxHP) {
                            player.stats.subTankEnergyCurrent += (player.stats.curHP + val) - player.stats.maxHP;
                        }

                        player.stats.curHP += val;
                    }
                    else {
                        float curTankAmt = player.stats.subTankEnergyCurrent;
                        player.stats.subTankEnergyCurrent += val;

                        if(curTankAmt < player.stats.subTankEnergyCurrent)
                            SoundPlayerGlobal.instance.Play(sfxId);
                    }
                    break;

                case ItemType.Energy:
                    Weapon wpn = null;
                    if(player.currentWeaponIndex == 0 || player.currentWeapon.isMaxEnergy) {
                        wpn = player.lowestEnergyWeapon;
                    }
                    else
                        wpn = player.currentWeapon;

                    if(wpn && !wpn.isMaxEnergy) {
                        if(wpn.currentEnergy + val > Weapon.weaponEnergyDefaultMax) {
                            player.stats.subTankWeaponCurrent += (wpn.currentEnergy + val) - Weapon.weaponEnergyDefaultMax;
                        }

                        wpn.currentEnergy += val;

                        if(wpn != player.currentWeapon)
                            SoundPlayerGlobal.instance.Play(sfxId);
                    }
                    else {
                        float curTankAmt = player.stats.subTankWeaponCurrent;
                        player.stats.subTankWeaponCurrent += val;

                        if(curTankAmt < player.stats.subTankWeaponCurrent)
                            SoundPlayerGlobal.instance.Play(sfxId);
                    }
                    break;

                case ItemType.Life:
                    PlayerStats.curLife++;
                    HUD.instance.RefreshLifeCount();
                    SoundPlayerGlobal.instance.Play(sfxId);
                    break;

                case ItemType.HealthUpgrade:
                    SlotInfo.AddHPMod(bit);
                    Player.instance.stats.RefreshHPMod();
                    SoundPlayerGlobal.instance.Play(sfxId);
                    break;

                case ItemType.EnergyTank:
                    if(bit == 0)
                        player.stats.AcquireSubTankEnergy1();
                    else
                        player.stats.AcquireSubTankEnergy2();

                    SoundPlayerGlobal.instance.Play(sfxId);
                    break;

                case ItemType.WeaponTank:
                    if(bit == 0)
                        player.stats.AcquireSubTankWeapon1();
                    else
                        player.stats.AcquireSubTankWeapon2();

                    SoundPlayerGlobal.instance.Play(sfxId);
                    break;

                case ItemType.Armor:
                    player.stats.AcquireArmor();
                    player.RefreshArmor();

                    SoundPlayerGlobal.instance.Play(sfxId);
                    break;

                case ItemType.Invul:
                    player.stats.invulGO.SetActive(true);
                    break;
            }

            if(savePickUp) {
                SceneState.instance.SetGlobalFlag(LevelController.levelPickupBitState, pickupBit, true, false);

                bool isHardcore = SlotInfo.gameMode == SlotInfo.GameMode.Hardcore;
                if(isHardcore) {
                    int dat = SceneState.instance.GetGlobalValue(LevelController.levelPickupBitState, 0);
                    SceneState.instance.SetValue(LevelController.levelPickupBitState, dat, true);
                }
            }

            if(!string.IsNullOrEmpty(sound)) {
                SoundPlayerGlobal.instance.Play(sound);
            }

            if(collider)
                collider.enabled = false;

            if(pickupCallback != null)
                pickupCallback(this);

            if(dialogTextRefs != null && dialogTextRefs.Length > 0) {
                mCurDialogTextInd = 0;
                UIModalCharacterDialog dlg = UIModalCharacterDialog.Open(true, UIModalCharacterDialog.defaultModalRef,
                                                                         dialogTextRefs[mCurDialogTextInd], HUD.gitgirlNameRef, HUD.gitgirlPortraitRef, null);
                dlg.actionCallback += OnDialogAction;

            }
            else {
                if(!string.IsNullOrEmpty(popTextRef))
                    HUD.instance.PopUpMessage(GameLocalize.GetText(popTextRef));

                Release();
            }
        }
    }