Пример #1
0
        public void doLoadSaveGameDialog()
        {
            List<string> saveList = new List<string> {slotA,slot0,slot1,slot2,slot3,slot4,slot5};

            using (ItemListSelector itSel = new ItemListSelector(gv, saveList, "Choose a Saved Game to Load."))
            {
                itSel.IceBlinkButtonClose.Visible = true;
                itSel.IceBlinkButtonClose.Enabled = true;
                itSel.ShowDialog();

                if (itSel.selectedIndex == 0)
                {
                    bool result = LoadSave("autosave.json");
                    if (result)
                    {
                        gv.screenType = "main";
                        doUpdate();
                    }
                    else
                    {
                        //Toast.makeText(gv.gameContext, "Save file not found", Toast.LENGTH_SHORT).show();
                    }
                }
                else if (itSel.selectedIndex == 1)
                {
                    bool result = LoadSave("quicksave.json");
                    if (result)
                    {
                        gv.screenType = "main";
                        doUpdate();
                    }
                    else
                    {
                        //Toast.makeText(gv.gameContext, "Save file not found", Toast.LENGTH_SHORT).show();
                    }
                }
                else if (itSel.selectedIndex == 2)
                {
                    bool result = LoadSave("slot1.json");
                    if (result)
                    {
                        gv.screenType = "main";
                        doUpdate();
                    }
                    else
                    {
                        //Toast.makeText(gv.gameContext, "Save file not found", Toast.LENGTH_SHORT).show();
                    }
                }
                else if (itSel.selectedIndex == 3)
                {
                    bool result = LoadSave("slot2.json");
                    if (result)
                    {
                        gv.screenType = "main";
                        doUpdate();
                    }
                    else
                    {
                        //Toast.makeText(gv.gameContext, "Save file not found", Toast.LENGTH_SHORT).show();
                    }
                }
                else if (itSel.selectedIndex == 4)
                {
                    bool result = LoadSave("slot3.json");
                    if (result)
                    {
                        gv.screenType = "main";
                        doUpdate();
                    }
                    else
                    {
                        //Toast.makeText(gv.gameContext, "Save file not found", Toast.LENGTH_SHORT).show();
                    }
                }
                else if (itSel.selectedIndex == 5)
                {
                    bool result = LoadSave("slot4.json");
                    if (result)
                    {
                        gv.screenType = "main";
                        doUpdate();
                    }
                    else
                    {
                        //Toast.makeText(gv.gameContext, "Save file not found", Toast.LENGTH_SHORT).show();
                    }
                }
                else if (itSel.selectedIndex == 6)
                {
                    bool result = LoadSave("slot5.json");
                    if (result)
                    {
                        gv.screenType = "main";
                        doUpdate();
                    }
                    else
                    {
                        //Toast.makeText(gv.gameContext, "Save file not found", Toast.LENGTH_SHORT).show();
                    }
                }
            }
            /*
            final CharSequence[] items = {slotA,slot0,slot1,slot2,slot3,slot4,slot5};
            // Creating and Building the Dialog
            AlertDialog.Builder builder = new AlertDialog.Builder(gv.gameContext);
            builder.setTitle("Choose a Saved Game to Load.");
            builder.setItems(items, new DialogInterface.OnClickListener()
            {
                public void onClick(DialogInterface dialog, int item)
                {
                    if (item == 0)
                    {
                        boolean result = LoadSave("autosave.json");
                        if (result)
                        {
                            gv.screenType = "main";
                            doUpdate();
                        }
                        else
                        {
                            Toast.makeText(gv.gameContext, "Save file not found", Toast.LENGTH_SHORT).show();
                        }
                    }
                    else if (item == 1)
                    {
                        boolean result = LoadSave("quicksave.json");
                        if (result)
                        {
                            gv.screenType = "main";
                            doUpdate();
                        }
                        else
                        {
                            Toast.makeText(gv.gameContext, "Save file not found", Toast.LENGTH_SHORT).show();
                        }
                    }
                    else if (item == 2)
                    {
                        boolean result = LoadSave("slot1.json");
                        if (result)
                        {
                            gv.screenType = "main";
                            doUpdate();
                        }
                        else
                        {
                            Toast.makeText(gv.gameContext, "Save file not found", Toast.LENGTH_SHORT).show();
                        }
                    }
                    else if (item == 3)
                    {
                        boolean result = LoadSave("slot2.json");
                        if (result)
                        {
                            gv.screenType = "main";
                            doUpdate();
                        }
                        else
                        {
                            Toast.makeText(gv.gameContext, "Save file not found", Toast.LENGTH_SHORT).show();
                        }
                    }
                    else if (item == 4)
                    {
                        boolean result = LoadSave("slot3.json");
                        if (result)
                        {
                            gv.screenType = "main";
                            doUpdate();
                        }
                        else
                        {
                            Toast.makeText(gv.gameContext, "Save file not found", Toast.LENGTH_SHORT).show();
                        }
                    }
                    else if (item == 5)
                    {
                        boolean result = LoadSave("slot4.json");
                        if (result)
                        {
                            gv.screenType = "main";
                            doUpdate();
                        }
                        else
                        {
                            Toast.makeText(gv.gameContext, "Save file not found", Toast.LENGTH_SHORT).show();
                        }
                    }
                    else if (item == 6)
                    {
                        boolean result = LoadSave("slot5.json");
                        if (result)
                        {
                            gv.screenType = "main";
                            doUpdate();
                        }
                        else
                        {
                            Toast.makeText(gv.gameContext, "Save file not found", Toast.LENGTH_SHORT).show();
                        }
                    }
                    gv.ActionDialog.dismiss();
                    gv.invalidate();
                }
            });
            gv.ActionDialog = builder.create();
            gv.ActionDialog.show();
            */
        }
Пример #2
0
        public void doSelectedSpell(bool inCombat)
        {
            if (isSelectedSpellSlotInKnownSpellsRange())
            {
                //only allow to cast spells that you know and are usable on this map
                if (getCastingPlayer().knownSpellsTags.Contains(GetCurrentlySelectedSpell().tag))
                {
                    if (inCombat)                 //Combat Map
                    {
                        gv.screenCombat.dontEndTurn = false;

                        bool swiftBlocked = false;
                        if (GetCurrentlySelectedSpell().isSwiftAction&& gv.mod.swiftActionHasBeenUsedThisTurn)
                        {
                            swiftBlocked = true;
                        }

                        bool coolBlocked = false;
                        for (int i = 0; i < getCastingPlayer().coolingSpellsByTag.Count; i++)
                        {
                            if (getCastingPlayer().coolingSpellsByTag[i] == GetCurrentlySelectedSpell().tag)
                            {
                                coolBlocked = true;
                            }
                        }

                        if ((getCastingPlayer().sp >= GetCurrentlySelectedSpell().costSP) && (getCastingPlayer().hp > GetCurrentlySelectedSpell().costHP) && (!gv.mod.nonRepeatableFreeActionsUsedThisTurnBySpellTag.Contains(GetCurrentlySelectedSpell().tag)) && !swiftBlocked && !coolBlocked)
                        {
                            //AoO code
                            foreach (Creature crt in gv.mod.currentEncounter.encounterCreatureList)
                            {
                                if (gv.screenCombat.CalcDistance(crt, crt.combatLocX, crt.combatLocY, getCastingPlayer().combatLocX, getCastingPlayer().combatLocY) == 1 && !crt.isHeld())
                                {
                                    bool playerReceivesAoOWhileCasting = true;
                                    foreach (Effect ef in getCastingPlayer().effectsList)
                                    {
                                        if (ef.allowCastingWithoutTriggeringAoO)
                                        {
                                            playerReceivesAoOWhileCasting = false;
                                            break;
                                        }
                                    }

                                    if ((GetCurrentlySelectedSpell().triggersAoO) && playerReceivesAoOWhileCasting)
                                    {
                                        gv.cc.addLogText("<font color='blue'>Attack of Opportunity by: " + crt.cr_name + "</font><BR>");
                                        int dcForSaveAdder = getCastingPlayer().hp;

                                        //gv.screenCombat.doStandardCreatureAttackAoO(getCastingPlayer(), crt, 1);
                                        gv.screenType      = "combat";
                                        gv.sf.CombatTarget = getCastingPlayer();
                                        gv.screenCombat.CreatureDoesAttack(crt, false, getCastingPlayer());

                                        if ((getCastingPlayer().hp <= 0) || (getCastingPlayer().isHeld()))
                                        {
                                            gv.screenType = "combat";
                                            gv.screenCombat.endPcTurn(true);
                                        }
                                        dcForSaveAdder = dcForSaveAdder - getCastingPlayer().hp;
                                        if (dcForSaveAdder > 0)
                                        {
                                            bool playerCanBeInterruptedWhileCasting = true;
                                            foreach (Effect ef in getCastingPlayer().effectsList)
                                            {
                                                if (ef.allowCastingWithoutRiskOfInterruption)
                                                {
                                                    playerCanBeInterruptedWhileCasting = false;
                                                    break;
                                                }
                                            }

                                            if ((GetCurrentlySelectedSpell().canBeInterrupted) && (GetCurrentlySelectedSpell().castTimeInTurns == 0) && playerCanBeInterruptedWhileCasting)
                                            {
                                                //check interruption
                                                //TODO: continue below, tying in the new effects..
                                                #region Do Calc Save and DC
                                                int saveChkRoll  = gv.sf.RandInt(20);
                                                int saveChk      = 0;
                                                int DC           = 10 + dcForSaveAdder;
                                                int saveChkAdder = getCastingPlayer().will;

                                                saveChk = saveChkRoll + saveChkAdder;
                                                #endregion

                                                if (saveChk >= DC)
                                                {
                                                    gv.cc.addLogText("<font color='yellow'>" + getCastingPlayer().name + " makes will save(" + saveChkRoll + "+" + saveChkAdder + " >= " + DC + "), avoiding interruption." + "</font><BR>");
                                                }
                                                else
                                                {
                                                    gv.cc.addLogText("<font color='yellow'>" + getCastingPlayer().name + " fails will save(" + saveChkRoll + "+" + saveChkAdder + " <= " + DC + "), " + getCastingPlayer().playerClass.spellLabelSingular + " is interrupted. " + "</font><BR>");
                                                    //switch screen, endturn
                                                    getCastingPlayer().sp -= GetCurrentlySelectedSpell().costSP;
                                                    getCastingPlayer().hp -= GetCurrentlySelectedSpell().costHP;
                                                    getCastingPlayer().isPreparingSpell         = false;
                                                    getCastingPlayer().doCastActionInXFullTurns = 0;
                                                    getCastingPlayer().tagOfSpellToBeCastAfterCastTimeIsDone = "none";
                                                    getCastingPlayer().thisCastIsFreeOfCost       = false;
                                                    getCastingPlayer().thisCasterCanBeInterrupted = true;
                                                    //backupKnownSpellTagsInCombat.Clear();
                                                    //gv.screenType = "combat";
                                                    //gv.screenCombat.onKeyUp(Keys.S);
                                                    //gv.screenCombat.animationSeqStack.Clear();
                                                    //gv.screenCombat.onKeyUp(Keys.S);
                                                    if (GetCurrentlySelectedSpell().usesTurnToActivate)
                                                    {
                                                        backupKnownSpellTagsInCombat.Clear();
                                                        gv.screenType = "combat";
                                                        gv.screenCombat.endPcTurn(true);
                                                    }
                                                    else
                                                    {
                                                        backupKnownSpellTagsInCombat.Clear();
                                                        gv.screenCombat.continueTurn = true;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }

                            if ((getCastingPlayer().hp > 0) && (!getCastingPlayer().isHeld()))
                            {
                                if (GetCurrentlySelectedSpell().castTimeInTurns == 0)
                                {
                                    gv.cc.currentSelectedSpell = GetCurrentlySelectedSpell();
                                    getCastingPlayer().thisCasterCanBeInterrupted = GetCurrentlySelectedSpell().canBeInterrupted;

                                    /*
                                     * if (GetCurrentlySelectedSpell().onlyOncePerTurn)
                                     * {
                                     *  gv.mod.nonRepeatableFreeActionsUsedThisTurnBySpellTag.Add(GetCurrentlySelectedSpell().tag);
                                     * }
                                     * if (GetCurrentlySelectedSpell().isSwiftAction)
                                     * {
                                     *  gv.mod.swiftActionHasBeenUsedThisTurn = true;
                                     * }
                                     * if (GetCurrentlySelectedSpell().coolDownTime > 0)
                                     * {
                                     *  getCastingPlayer().coolingSpellsByTag.Add(GetCurrentlySelectedSpell().tag);
                                     *  getCastingPlayer().coolDownTimes.Add(GetCurrentlySelectedSpell().coolDownTime);
                                     * }
                                     */
                                    gv.screenType = "combat";
                                    gv.screenCombat.currentCombatMode = "cast";
                                    doCleanUp();
                                }
                                //a spell requiring a full turn or more is cast
                                else
                                {
                                    //reduce sp and hp in the moment the caster begins the spell
                                    getCastingPlayer().sp -= GetCurrentlySelectedSpell().costSP;
                                    getCastingPlayer().hp -= GetCurrentlySelectedSpell().costHP;

                                    //back to combat screen (rendering now)
                                    gv.screenType = "combat";

                                    //set values to flag taht the pc is now in the process of casting (how long, which spell, can be interrupted, is preparing spell)
                                    getCastingPlayer().doCastActionInXFullTurns = GetCurrentlySelectedSpell().castTimeInTurns;
                                    getCastingPlayer().tagOfSpellToBeCastAfterCastTimeIsDone = GetCurrentlySelectedSpell().tag;
                                    getCastingPlayer().thisCasterCanBeInterrupted            = GetCurrentlySelectedSpell().canBeInterrupted;
                                    getCastingPlayer().isPreparingSpell = true;

                                    //entry in log explaining that the player just started a long time cast
                                    gv.cc.addLogText("<font color='yellow'>" + getCastingPlayer().name + " begins with a " + getCastingPlayer().playerClass.spellLabelSingular + " that takes " + getCastingPlayer().doCastActionInXFullTurns + " full turn(s)..." + " </font><BR>");

                                    //end turn of casting player for now
                                    //gv.screenCombat.animationSeqStack.Clear();
                                    //gv.screenCombat.isPlayerTurn = false;
                                    //gv.screenCombat.canMove = false;
                                    //while (gv.screenCombat.animationSeqStack.Count > 0)
                                    //{
                                    gv.screenCombat.dontEndTurn = false;
                                    gv.screenCombat.endPcTurn(true);
                                    //}

                                    //wonder why this is after swap of render to combat screen, imitating it here
                                    doCleanUp();
                                }
                            }
                        }
                        else
                        {
                            //Toast.makeText(gv.gameContext, "Not Enough SP for that spell", Toast.LENGTH_SHORT).show();
                        }
                    }
                    else                 //Adventure Map
                    {
                        //only cast if useable on adventure maps
                        if ((GetCurrentlySelectedSpell().useableInSituation.Equals("Always")) || (GetCurrentlySelectedSpell().useableInSituation.Equals("OutOfCombat")))
                        {
                            if ((getCastingPlayer().sp >= GetCurrentlySelectedSpell().costSP) && (getCastingPlayer().hp > GetCurrentlySelectedSpell().costHP))
                            {
                                gv.cc.currentSelectedSpell = GetCurrentlySelectedSpell();
                                //ask for target
                                // selected to USE ITEM

                                //********************************************

                                //if target is SELF then just do doSpellTarget(self)
                                if (gv.cc.currentSelectedSpell.spellTargetType.Equals("Self"))
                                {
                                    doSpellTarget(getCastingPlayer(), getCastingPlayer());
                                }

                                //********************************************
                                else
                                {
                                    List <string> pcNames = new List <string>();
                                    pcNames.Add("cancel");
                                    foreach (Player p in gv.mod.playerList)
                                    {
                                        pcNames.Add(p.name + " (" + p.hp + "/" + p.hpMax + " HP)");
                                    }

                                    //If only one PC, do not show select PC dialog...just go to cast selector
                                    if (gv.mod.playerList.Count == 1)
                                    {
                                        try
                                        {
                                            Player target = gv.mod.playerList[0];
                                            gv.cc.doSpellBasedOnScriptOrEffectTag(gv.cc.currentSelectedSpell, target, target, true, false);
                                            gv.screenType = "main";
                                            doCleanUp();
                                            return;
                                        }
                                        catch (Exception ex)
                                        {
                                            gv.errorLog(ex.ToString());
                                        }
                                    }

                                    using (ItemListSelector pcSel = new ItemListSelector(gv, pcNames, gv.mod.getPlayerClass(getCastingPlayer().classTag).spellLabelSingular + " Target"))
                                    {
                                        pcSel.ShowDialog();
                                        Player pc = getCastingPlayer();
                                        if (pcSel.selectedIndex > 0)
                                        {
                                            try
                                            {
                                                Player target = gv.mod.playerList[pcSel.selectedIndex - 1];
                                                gv.cc.doSpellBasedOnScriptOrEffectTag(gv.cc.currentSelectedSpell, pc, target, true, false);
                                                gv.screenType = "main";
                                                doCleanUp();
                                            }
                                            catch (Exception ex)
                                            {
                                                IBMessageBox.Show(gv, "error with Pc Selector screen: " + ex.ToString());
                                                gv.errorLog(ex.ToString());
                                            }
                                        }
                                        else if (pcSel.selectedIndex == 0) // selected "cancel"
                                        {
                                            //do nothing
                                        }
                                    }
                                }//closing else or target self
                            }
                            else
                            {
                                //Toast.makeText(gv.gameContext, "Not Enough SP for that spell", Toast.LENGTH_SHORT).show();
                            }
                        }
                    }
                }
            }
        }
Пример #3
0
        public void doSavesDialog()
        {
            List<string> saveList = new List<string> { slot0, slot1, slot2, slot3, slot4, slot5 };

            using (ItemListSelector itSel = new ItemListSelector(gv, saveList, "Choose a slot to save game."))
            {
                itSel.IceBlinkButtonClose.Enabled = true;
                itSel.IceBlinkButtonClose.Visible = true;
                itSel.setupAll(gv);
                var ret = itSel.ShowDialog();

                if (itSel.selectedIndex == 0)
                {
                    try
                    {
                        QuickSave();
                    }
                    catch (Exception e)
                    {
                        gv.sf.MessageBox("Failed to Save: Not enough free memory(RAM) on device, try and free up some memory and try again.");
                    }
                }
                else if (itSel.selectedIndex == 1)
                {
                    Player pc = gv.mod.playerList[0];
                    gv.mod.saveName = pc.name + ", Level:" + pc.classLevel + ", XP:" + pc.XP + ", WorldTime:" + gv.mod.WorldTime;
                    slot1 = gv.mod.saveName;
                    try
                    {
                        SaveGame("slot1.json");
                        SaveGameInfo("slot1info.json");
                    }
                    catch (Exception e)
                    {
                        gv.sf.MessageBox("Failed to Save: Not enough free memory(RAM) on device, try and free up some memory and try again.");
                    }
                }
                else if (itSel.selectedIndex == 2)
                {
                    Player pc = gv.mod.playerList[0];
                    gv.mod.saveName = pc.name + ", Level:" + pc.classLevel + ", XP:" + pc.XP + ", WorldTime:" + gv.mod.WorldTime;
                    slot2 = gv.mod.saveName;
                    try
                    {
                        SaveGame("slot2.json");
                        SaveGameInfo("slot2info.json");
                    }
                    catch (Exception e)
                    {
                        gv.sf.MessageBox("Failed to Save: Not enough free memory(RAM) on device, try and free up some memory and try again.");
                    }
                }
                else if (itSel.selectedIndex == 3)
                {
                    Player pc = gv.mod.playerList[0];
                    gv.mod.saveName = pc.name + ", Level:" + pc.classLevel + ", XP:" + pc.XP + ", WorldTime:" + gv.mod.WorldTime;
                    slot3 = gv.mod.saveName;
                    try
                    {
                        SaveGame("slot3.json");
                        SaveGameInfo("slot3info.json");
                    }
                    catch (Exception e)
                    {
                        gv.sf.MessageBox("Failed to Save: Not enough free memory(RAM) on device, try and free up some memory and try again.");
                    }
                }
                else if (itSel.selectedIndex == 4)
                {
                    Player pc = gv.mod.playerList[0];
                    gv.mod.saveName = pc.name + ", Level:" + pc.classLevel + ", XP:" + pc.XP + ", WorldTime:" + gv.mod.WorldTime;
                    slot4 = gv.mod.saveName;
                    try
                    {
                        SaveGame("slot4.json");
                        SaveGameInfo("slot4info.json");
                    }
                    catch (Exception e)
                    {
                        gv.sf.MessageBox("Failed to Save: Not enough free memory(RAM) on device, try and free up some memory and try again.");
                    }
                }
                else if (itSel.selectedIndex == 5)
                {
                    Player pc = gv.mod.playerList[0];
                    gv.mod.saveName = pc.name + ", Level:" + pc.classLevel + ", XP:" + pc.XP + ", WorldTime:" + gv.mod.WorldTime;
                    slot5 = gv.mod.saveName;
                    try
                    {
                        SaveGame("slot5.json");
                        SaveGameInfo("slot5info.json");
                    }
                    catch (Exception e)
                    {
                        gv.sf.MessageBox("Failed to Save: Not enough free memory(RAM) on device, try and free up some memory and try again.");
                    }
                }
            }

            /*TODO
            final CharSequence[] items = {slot0,slot1,slot2,slot3,slot4,slot5};
            // Creating and Building the Dialog
            AlertDialog.Builder builder = new AlertDialog.Builder(gv.gameContext);
            builder.setTitle("Choose a save slot to overwrite and save your game.");
            builder.setItems(items, new DialogInterface.OnClickListener()
            {
                public void onClick(DialogInterface dialog, int item)
                {
                    if (item == 0)
                    {
                        try
                        {
                            QuickSave();
                        }
                        catch (Exception e)
                        {
                            gv.sf.MessageBox("Failed to Save: Not enough free memory(RAM) on device, try and free up some memory and try again.");
                        }
                    }
                    else if (item == 1)
                    {
                        Player pc = gv.mod.playerList.get(0);
                        gv.mod.saveName = pc.name + ", Level:" + pc.classLevel + ", XP:" + pc.XP + ", WorldTime:" + gv.mod.WorldTime;
                        slot1 = gv.mod.saveName;
                        try
                        {
                            SaveGame("slot1.json");
                            SaveGameInfo("slot1info.json");
                        }
                        catch (Exception e)
                        {
                            gv.sf.MessageBox("Failed to Save: Not enough free memory(RAM) on device, try and free up some memory and try again.");
                        }
                    }
                    else if (item == 2)
                    {
                        Player pc = gv.mod.playerList.get(0);
                        gv.mod.saveName = pc.name + ", Level:" + pc.classLevel + ", XP:" + pc.XP + ", WorldTime:" + gv.mod.WorldTime;
                        slot2 = gv.mod.saveName;
                        try
                        {
                            SaveGame("slot2.json");
                            SaveGameInfo("slot2info.json");
                        }
                        catch (Exception e)
                        {
                            gv.sf.MessageBox("Failed to Save: Not enough free memory(RAM) on device, try and free up some memory and try again.");
                        }
                    }
                    else if (item == 3)
                    {
                        Player pc = gv.mod.playerList.get(0);
                        gv.mod.saveName = pc.name + ", Level:" + pc.classLevel + ", XP:" + pc.XP + ", WorldTime:" + gv.mod.WorldTime;
                        slot3 = gv.mod.saveName;
                        try
                        {
                            SaveGame("slot3.json");
                            SaveGameInfo("slot3info.json");
                        }
                        catch (Exception e)
                        {
                            gv.sf.MessageBox("Failed to Save: Not enough free memory(RAM) on device, try and free up some memory and try again.");
                        }
                    }
                    else if (item == 4)
                    {
                        Player pc = gv.mod.playerList.get(0);
                        gv.mod.saveName = pc.name + ", Level:" + pc.classLevel + ", XP:" + pc.XP + ", WorldTime:" + gv.mod.WorldTime;
                        slot4 = gv.mod.saveName;
                        try
                        {
                            SaveGame("slot4.json");
                            SaveGameInfo("slot4info.json");
                        }
                        catch (Exception e)
                        {
                            gv.sf.MessageBox("Failed to Save: Not enough free memory(RAM) on device, try and free up some memory and try again.");
                        }
                    }
                    else if (item == 5)
                    {
                        Player pc = gv.mod.playerList.get(0);
                        gv.mod.saveName = pc.name + ", Level:" + pc.classLevel + ", XP:" + pc.XP + ", WorldTime:" + gv.mod.WorldTime;
                        slot5 = gv.mod.saveName;
                        try
                        {
                            SaveGame("slot5.json");
                            SaveGameInfo("slot5info.json");
                        }
                        catch (Exception e)
                        {
                            gv.sf.MessageBox("Failed to Save: Not enough free memory(RAM) on device, try and free up some memory and try again.");
                        }
                    }
                    gv.ActionDialog.dismiss();
                    gv.invalidate();
                }
            });
            gv.ActionDialog = builder.create();
            gv.ActionDialog.show();
            */
        }
Пример #4
0
        public void doSelectedSpell(bool inCombat)
        {
            if (isSelectedSpellSlotInKnownSpellsRange())
            {
                //only allow to cast spells that you know and are usable on this map
                if (getCastingPlayer().knownSpellsTags.Contains(GetCurrentlySelectedSpell().tag))
                {
                    if (inCombat) //Combat Map
                    {

                        if (getCastingPlayer().sp >= GetCurrentlySelectedSpell().costSP)
                        {
                            gv.cc.currentSelectedSpell = GetCurrentlySelectedSpell();
                            gv.screenType = "combat";
                            gv.screenCombat.currentCombatMode = "cast";
                            doCleanUp();
                        }
                        else
                        {
                            //Toast.makeText(gv.gameContext, "Not Enough SP for that spell", Toast.LENGTH_SHORT).show();
                        }
                    }
                    else //Adventure Map
                    {
                        //only cast if useable on adventure maps
                        if ((GetCurrentlySelectedSpell().useableInSituation.Equals("Always")) || (GetCurrentlySelectedSpell().useableInSituation.Equals("OutOfCombat")))
                        {
                            if (getCastingPlayer().sp >= GetCurrentlySelectedSpell().costSP)
                            {
                                gv.cc.currentSelectedSpell = GetCurrentlySelectedSpell();
                                //ask for target
                                // selected to USE ITEM

                                List<string> pcNames = new List<string>();
                                pcNames.Add("cancel");
                                foreach (Player p in mod.playerList)
                                {
                                    pcNames.Add(p.name);
                                }

                                //If only one PC, do not show select PC dialog...just go to cast selector
                                if (mod.playerList.Count == 1)
                                {
                                    try
                                    {
                                        Player target = mod.playerList[0];
                                        gv.cc.doSpellBasedOnTag(gv.cc.currentSelectedSpell.tag, target, target);
                                        gv.screenType = "main";
                                        doCleanUp();
                                        return;
                                    }
                                    catch (Exception ex)
                                    {
                                        //print error
                                    }
                                }

                                using (ItemListSelector pcSel = new ItemListSelector(gv, pcNames, "Spell Target"))
                                {
                                    pcSel.ShowDialog();
                                    Player pc = getCastingPlayer();
                                    if (pcSel.selectedIndex > 0)
                                    {
                                        try
                                        {
                                            Player target = mod.playerList[pcSel.selectedIndex - 1];
                                            gv.cc.doSpellBasedOnTag(gv.cc.currentSelectedSpell.tag, pc, target);
                                            gv.screenType = "main";
                                            doCleanUp();
                                        }
                                        catch (Exception ex)
                                        {
                                            IBMessageBox.Show(gv, "error with Pc Selector screen: " + ex.ToString());
                                            //print error
                                        }
                                    }
                                    else if (pcSel.selectedIndex == 0) // selected "cancel"
                                    {
                                        //do nothing
                                    }
                                }
                            }
                            else
                            {
                                //Toast.makeText(gv.gameContext, "Not Enough SP for that spell", Toast.LENGTH_SHORT).show();
                            }
                        }
                    }
                }
            }
        }