示例#1
0
        public void ValidateAndIfNecessaryCreateExitChildren()
        {
            if (!Game1.IsMasterGame)
            {
                return;
            }

            if (this.playerCount.Value <= 0)
            {
                return;
            }

            if (this.level.Value > 1 && this.Parent == null && !this.HasExit(CastEnterDirToExitDir(this.EnterDir)))
            {
                // this.abandonedByParentTime = Game1.timeOfDay;
                this.exits.Add(new DeepWoodsExit(this, CastEnterDirToExitDir(this.EnterDir), this.EnterLocation));
            }

            foreach (var exit in this.exits)
            {
                DeepWoods exitDeepWoods = Game1.getLocationFromName(exit.TargetLocationName) as DeepWoods;
                if (exitDeepWoods == null)
                {
                    exitDeepWoods = new DeepWoods(this, this.level.Value + 1, ExitDirToEnterDir(exit.ExitDir));
                    DeepWoodsManager.AddDeepWoodsToGameLocations(exitDeepWoods);
                }
                exit.TargetLocationName = exitDeepWoods.Name;
                exit.TargetLocation     = exitDeepWoods.EnterLocation;
            }
        }
        private static void CheckValid()
        {
            if (!Game1.IsMasterGame)
            {
                return;
            }

            if (!IsValidForThisGame())
            {
                Remove();
                DeepWoodsManager.AddDeepWoodsToGameLocations(new DeepWoods(null, 1, EnterDirection.FROM_TOP));
            }
        }
        public static void Restore()
        {
            if (!Game1.IsMasterGame)
            {
                return;
            }

            if (DeepWoodsManager.rootDeepWoodsBackup != null)
            {
                DeepWoodsManager.AddDeepWoodsToGameLocations(DeepWoodsManager.rootDeepWoodsBackup);
            }
            DeepWoodsManager.rootDeepWoodsBackup = null;

            CheckValid();
        }
        public static DeepWoods AddDeepWoodsFromObelisk(int level)
        {
            if (!Game1.IsMasterGame)
            {
                throw new ApplicationException("Illegal call to DeepWoodsManager.AddDeepWoodsFromObelisk in client.");
            }

            // First check if a level already exists and use that.
            foreach (GameLocation gameLocation in Game1.locations)
            {
                if (gameLocation is DeepWoods && (gameLocation as DeepWoods).level.Value == level)
                {
                    return(gameLocation as DeepWoods);
                }
            }

            // Otherwise create a new level.
            DeepWoods deepWoods = new DeepWoods(level);

            DeepWoodsManager.AddDeepWoodsToGameLocations(deepWoods);
            return(deepWoods);
        }