コード例 #1
0
 public IEnumerator <YieldInstruction> RestrictLevel(ZoneData zone, bool silent)
 {
     if (zone.LevelCap)
     {
         StartLevel = zone.Level;
         for (int ii = 0; ii < ActiveTeam.Players.Count; ii++)
         {
             RestrictCharLevel(ActiveTeam.Players[ii], zone.Level, true);
             ActiveTeam.Players[ii].BackRef = new TempCharBackRef(false, ii);
         }
         for (int ii = 0; ii < ActiveTeam.Guests.Count; ii++)
         {
             RestrictCharLevel(ActiveTeam.Guests[ii], zone.Level, true);
             //no backref for guests
         }
         for (int ii = 0; ii < ActiveTeam.Assembly.Count; ii++)
         {
             RestrictCharLevel(ActiveTeam.Assembly[ii], zone.Level, true);
             ActiveTeam.Assembly[ii].BackRef = new TempCharBackRef(true, ii);
         }
         if (!silent)
         {
             yield return(CoroutineManager.Instance.StartCoroutine(MenuManager.Instance.SetDialogue(Text.FormatKey("DLG_RESTRICT_LEVEL", StartLevel))));
         }
     }
 }
コード例 #2
0
        public override IEnumerator <YieldInstruction> BeginGame(int zoneID, ulong seed, DungeonStakes stakes, bool recorded, bool noRestrict)
        {
            ZoneData zone = DataManager.Instance.GetZone(zoneID);

            //restrict team size/bag size/etc
            if (!noRestrict)
            {
                yield return(CoroutineManager.Instance.StartCoroutine(RestrictTeam(zone, false)));
            }

            MidAdventure = true;
            Stakes       = stakes;
            //create a copy (from save and load) of the current state and mark it with loss
            DataManager.Instance.SaveMainGameState();

            GameState state = DataManager.Instance.LoadMainGameState();

            if (state != null)
            {
                if (Stakes == DungeonStakes.Risk)
                {
                    LossPenalty(state.Save);
                }

                DataManager.Instance.SaveGameState(state);
            }

            //set everyone's levels and mark them for backreferral
            if (!noRestrict)
            {
                yield return(CoroutineManager.Instance.StartCoroutine(RestrictLevel(zone, false)));
            }

            RestartLogs(seed);
            RescuesLeft = zone.Rescues;

            if (recorded)
            {
                DataManager.Instance.BeginPlay(DataManager.QUICKSAVE_FILE_PATH, zoneID, false);
            }
        }
コード例 #3
0
        public IEnumerator <YieldInstruction> RestrictTeam(ZoneData zone, bool silent)
        {
            int teamSize = ExplorerTeam.MAX_TEAM_SLOTS;

            if (zone.TeamSize > -1)
            {
                teamSize = zone.TeamSize;
            }
            if (zone.TeamRestrict)
            {
                teamSize = 1;
            }

            List <string> teamRestrictions = new List <string>();

            while (ActiveTeam.Players.Count > teamSize)
            {
                int sendHomeIndex = ActiveTeam.Players.Count - 1;
                if (sendHomeIndex == ActiveTeam.LeaderIndex)
                {
                    sendHomeIndex--;
                }
                teamRestrictions.Add(ActiveTeam.Players[sendHomeIndex].BaseName);
                if (GameManager.Instance.CurrentScene == GroundScene.Instance)
                {
                    GroundScene.Instance.SilentSendHome(sendHomeIndex);
                }
                else if (GameManager.Instance.CurrentScene == DungeonScene.Instance)
                {
                    DungeonScene.Instance.SilentSendHome(sendHomeIndex);
                }
            }

            if (!silent)
            {
                if (teamRestrictions.Count > 1)
                {
                    string compositeList = Text.BuildList(teamRestrictions.ToArray());
                    yield return(CoroutineManager.Instance.StartCoroutine(MenuManager.Instance.SetDialogue(Text.FormatKey("MSG_TEAM_SENT_HOME_PLURAL", compositeList))));
                }
                else if (teamRestrictions.Count == 1)
                {
                    yield return(CoroutineManager.Instance.StartCoroutine(MenuManager.Instance.SetDialogue(Text.FormatKey("MSG_TEAM_SENT_HOME", teamRestrictions[0]))));
                }
            }

            List <string> bagRestrictions = new List <string>();

            if (zone.MoneyRestrict && ActiveTeam.Money > 0)
            {
                ActiveTeam.Bank += ActiveTeam.Money;
                ActiveTeam.Money = 0;
                bagRestrictions.Add(Text.FormatKey("DLG_RESTRICT_MONEY"));
            }

            if (zone.BagRestrict > -1)
            {
                bool removedItems = false;
                int  heldSlots    = 0;
                foreach (Character player in ActiveTeam.Players)
                {
                    if (player.EquippedItem.ID > -1)
                    {
                        heldSlots++;
                    }
                }
                List <InvItem> itemsToStore = new List <InvItem>();
                while (ActiveTeam.GetInvCount() + heldSlots > zone.BagRestrict && ActiveTeam.GetInvCount() > 0)
                {
                    removedItems = true;
                    itemsToStore.Add(ActiveTeam.GetInv(ActiveTeam.GetInvCount() - 1));

                    ActiveTeam.RemoveFromInv(ActiveTeam.GetInvCount() - 1);
                }
                while (ActiveTeam.GetInvCount() + heldSlots > zone.BagRestrict)
                {
                    foreach (Character player in ActiveTeam.Players)
                    {
                        if (player.EquippedItem.ID > -1)
                        {
                            removedItems = true;
                            itemsToStore.Add(player.EquippedItem);
                            player.DequipItem();
                            heldSlots--;
                            break;
                        }
                    }
                }
                ActiveTeam.StoreItems(itemsToStore);
                if (!silent && removedItems)
                {
                    if (zone.BagRestrict > 0)
                    {
                        bagRestrictions.Add(Text.FormatKey("DLG_RESTRICT_ITEM_SLOT", zone.BagRestrict));
                    }
                    else
                    {
                        bagRestrictions.Add(Text.FormatKey("DLG_RESTRICT_ITEM_ALL"));
                    }
                }
            }
            if (bagRestrictions.Count > 0 && !silent)
            {
                string compositeList = Text.BuildList(bagRestrictions.ToArray());
                string finalMsg      = Text.FormatKey("DLG_RESTRICT_BAG", (compositeList[0].ToString()).ToUpper() + compositeList.Substring(1));
                yield return(CoroutineManager.Instance.StartCoroutine(MenuManager.Instance.SetDialogue(finalMsg)));
            }
        }