Example #1
0
        public bool setCurrentArea(string filename, GameView gv)
        {
            try
            {
                foreach (Area area in this.moduleAreasObjects)
                {
                    if (area.Filename.Equals(filename))
                    {
                        this.currentArea = area;
                        if (!gv.mod.useAllTileSystem)
                        {
                            gv.cc.DisposeOfBitmap(ref gv.cc.bmpMap);
                            gv.cc.bmpMap = gv.cc.LoadBitmap(this.currentArea.ImageFileName);

                            //TODO gv.cc.LoadTileBitmapList();

                            foreach (Prop p in this.currentArea.Props)
                            {
                                gv.cc.DisposeOfBitmap(ref p.token);
                                p.token = gv.cc.LoadBitmap(p.ImageFileName);
                            }
                        }

                        return(true);
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                gv.errorLog(ex.ToString());
                return(false);
            }
        }
Example #2
0
 public void loadPlayerList()
 {
     pcList.Clear();
     string[] files;
     if (Directory.Exists(gv.mainDirectory + "\\saves\\" + gv.mod.moduleName + "\\characters"))
     {
         files = Directory.GetFiles(gv.mainDirectory + "\\saves\\" + gv.mod.moduleName + "\\characters", "*.json");
         foreach (string file in files)
         {
             try
             {
                 AddCharacterToList(file);
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.ToString());
                 gv.errorLog(ex.ToString());
             }
         }
     }
 }
Example #3
0
 public void loadAreas(GameView gv)
 {
     foreach (string areaName in this.moduleAreasList)
     {
         try
         {
             using (StreamReader file = File.OpenText(gv.mainDirectory + "\\modules\\" + this.moduleName + "\\areas\\" + areaName + ".lvl"))
             {
                 JsonSerializer serializer = new JsonSerializer();
                 Area           newArea    = (Area)serializer.Deserialize(file, typeof(Area));
                 foreach (Prop p in newArea.Props)
                 {
                     p.initializeProp();
                 }
                 moduleAreasObjects.Add(newArea);
             }
         }
         catch (Exception ex)
         {
             gv.errorLog(ex.ToString());
         }
     }
 }
        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();
                            }
                        }
                    }
                }
            }
        }
Example #5
0
 public void LoadPlayerTokenList()
 {
     playerTokenList.Clear();
     try
     {
         //Load from gv.module folder first
         string[] files;
         if (Directory.Exists(gv.mainDirectory + "\\modules\\" + gv.mod.moduleName + "\\pctokens"))
         {
             files = Directory.GetFiles(gv.mainDirectory + "\\modules\\" + gv.mod.moduleName + "\\pctokens", "*.png");
             //directory.mkdirs();
             foreach (string file in files)
             {
                 try
                 {
                     string filename = Path.GetFileName(file);
                     if (filename.EndsWith(".png"))
                     {
                         string fileNameWithOutExt = Path.GetFileNameWithoutExtension(file);
                         playerTokenList.Add(fileNameWithOutExt);
                     }
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Show(ex.ToString());
                     gv.errorLog(ex.ToString());
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
         gv.errorLog(ex.ToString());
     }
     try
     {
         //Load from PlayerTokens folder last
         string[] files;
         if (Directory.Exists(gv.mainDirectory + "\\PlayerTokens"))
         {
             files = Directory.GetFiles(gv.mainDirectory + "\\PlayerTokens", "*.png");
             //directory.mkdirs();
             foreach (string file in files)
             {
                 try
                 {
                     string filename = Path.GetFileName(file);
                     if (filename.EndsWith("_pc.png"))
                     {
                         string fileNameWithOutExt = Path.GetFileNameWithoutExtension(file);
                         if (!playerTokenList.Contains(fileNameWithOutExt))
                         {
                             playerTokenList.Add(fileNameWithOutExt);
                         }
                     }
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Show(ex.ToString());
                     gv.errorLog(ex.ToString());
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
         gv.errorLog(ex.ToString());
     }
 }