コード例 #1
0
ファイル: DirectionController.cs プロジェクト: pjflip/TabPlay
        public ActionResult Index(int sectionID, int tableNumber, string direction = "", bool confirm = false)
        {
            Table table = AppData.TableList.Find(x => x.SectionID == sectionID && x.TableNumber == tableNumber);

            if (table == null)
            {
                table = new Table(sectionID, tableNumber);
                AppData.TableList.Add(table);
            }

            EnterDirection enterDirection = new EnterDirection
            {
                SectionID   = sectionID,
                TableNumber = tableNumber,
                Direction   = direction,
                PairNumber  = table.PairNumber,
                Confirm     = confirm
            };
            string sectionLetter = AppData.SectionList.Find(x => x.SectionID == sectionID).SectionLetter;

            ViewData["Header"]  = $"Table {sectionLetter + tableNumber.ToString()} - Round {table.RoundNumber}";
            ViewData["Buttons"] = ButtonOptions.OKInvisible;
            ViewData["Title"]   = $"Direction - {sectionLetter + tableNumber.ToString()}";
            return(View(enterDirection));
        }
コード例 #2
0
        public Location GetRandomEnterLocation(EnterDirection enterDir, DeepWoodsRandom random)
        {
            int x, y;

            if (enterDir == EnterDirection.FROM_BOTTOM || enterDir == EnterDirection.FROM_TOP)
            {
                x = random.GetRandomValue(Settings.Map.MinCornerDistanceForEnterLocation, this.mapWidth - Settings.Map.MinCornerDistanceForEnterLocation);
                if (enterDir == EnterDirection.FROM_BOTTOM)
                {
                    y = this.mapHeight - 1;
                }
                else
                {
                    y = 0;
                }
            }
            else
            {
                y = random.GetRandomValue(Settings.Map.MinCornerDistanceForEnterLocation, this.mapHeight - Settings.Map.MinCornerDistanceForEnterLocation);
                if (enterDir == EnterDirection.FROM_RIGHT)
                {
                    x = this.mapWidth - 1;
                }
                else
                {
                    x = 0;
                }
            }
            return(new Location(x, y));
        }
コード例 #3
0
        public DeepWoods(DeepWoods parent, int level, EnterDirection enterDir)
            : this()
        {
            base.isOutdoors.Value            = true;
            base.ignoreDebrisWeather.Value   = true;
            base.ignoreOutdoorLighting.Value = true;

            this.hasReceivedNetworkData.Value = true;

            this.uniqueMultiplayerID.Value = Game1.MasterPlayer.UniqueMultiplayerID;
            this.seed = DeepWoodsRandom.CalculateSeed(level, enterDir, parent?.Seed);
            if (level == 1)
            {
                base.name.Value = "DeepWoods";
            }
            else
            {
                base.name.Value = "DeepWoods_" + this.seed;
            }
            this.parentName.Value             = parent?.Name;
            this.ParentExitLocation           = parent?.GetExit(EnterDirToExitDir(enterDir))?.Location ?? new Location();
            this.level.Value                  = level;
            DeepWoodsState.LowestLevelReached = Math.Max(DeepWoodsState.LowestLevelReached, this.level.Value - 1);
            this.EnterDir        = enterDir;
            this.spawnTime.Value = Game1.timeOfDay;

            this.spawnedFromObelisk.Value = parent?.spawnedFromObelisk?.Value ?? false;

            ModEntry.GetAPI().CallOnCreate(this);

            CreateSpace();
            DetermineExits();
            updateMap();

            ModEntry.GetAPI().CallBeforeFill(this);
            if ((this.isLichtung.Value && this.lichtungHasLake.Value) || !ModEntry.GetAPI().CallOverrideFill(this))
            {
                DeepWoodsStuffCreator.AddStuff(this, new DeepWoodsRandom(this, this.seed ^ Game1.currentGameTime.TotalGameTime.Milliseconds ^ Game1.random.Next()));
            }
            ModEntry.GetAPI().CallAfterFill(this);

            ModEntry.GetAPI().CallBeforeMonsterGeneration(this);
            if (!ModEntry.GetAPI().CallOverrideMonsterGeneration(this))
            {
                DeepWoodsMonsters.AddMonsters(this, new DeepWoodsRandom(this, this.seed ^ Game1.currentGameTime.TotalGameTime.Milliseconds ^ Game1.random.Next()));
            }
            ModEntry.GetAPI().CallAfterMonsterGeneration(this);

            if (parent == null && level > 1 && !this.HasExit(CastEnterDirToExitDir(this.EnterDir)))
            {
                this.exits.Add(new DeepWoodsExit(this, CastEnterDirToExitDir(this.EnterDir), this.EnterLocation));
            }

            if (parent != null)
            {
                ModEntry.Log($"Child spawned, time: {Game1.timeOfDay}, name: {this.Name}, level: {this.level}, parent: {this.parentName}, enterDir: {this.EnterDir}, enterLocation: {this.EnterLocation.X}, {this.EnterLocation.Y}", LogLevel.Trace);
            }
        }
コード例 #4
0
        public ActionResult Index(int sectionID, int tableNumber, int roundNumber, Direction direction = Direction.Null, bool confirm = false)
        {
            Section        section        = AppData.SectionsList.Find(x => x.SectionID == sectionID);
            EnterDirection enterDirection = new EnterDirection(section, tableNumber, direction, roundNumber, confirm);

            ViewData["Title"]         = $"Enter Direction - {section.SectionLetter}{tableNumber}";
            ViewData["Header"]        = $"Table {section.SectionLetter}{tableNumber}";
            ViewData["ButtonOptions"] = ButtonOptions.OKDisabled;
            if (AppData.IsIndividual)
            {
                return(View("Individual", enterDirection));
            }
            else
            {
                return(View("Pair", enterDirection));
            }
        }
コード例 #5
0
        public static Dictionary <ExitDirection, Location> CreateExitDictionary(EnterDirection enterDir, Location enterLocation, IList <DeepWoodsExit> exits)
        {
            Dictionary <ExitDirection, Location> exitDictionary = new Dictionary <ExitDirection, Location>();

            exitDictionary.Add(CastEnterDirToExitDir(enterDir), enterLocation);
            foreach (var exit in exits)
            {
                if (!exitDictionary.ContainsKey(exit.ExitDir))
                {
                    exitDictionary.Add(exit.ExitDir, exit.Location);
                }
                else if (exitDictionary[exit.ExitDir] != exit.Location)
                {
                    throw new ApplicationException("Invalid state in CreateExitDictionary: got conflicting enter and exit locations!");
                }
            }
            return(exitDictionary);
        }
コード例 #6
0
        public static ExitDirection CastEnterDirToExitDir(EnterDirection enterDir)
        {
            switch (enterDir)
            {
            case EnterDirection.FROM_LEFT:
                return(ExitDirection.LEFT);

            case EnterDirection.FROM_TOP:
                return(ExitDirection.TOP);

            case EnterDirection.FROM_RIGHT:
                return(ExitDirection.RIGHT);

            case EnterDirection.FROM_BOTTOM:
                return(ExitDirection.BOTTOM);

            default:
                return(ExitDirection.TOP);
            }
        }
コード例 #7
0
        public static int EnterDirToFacingDirection(EnterDirection enterDir)
        {
            switch (enterDir)
            {
            case EnterDirection.FROM_LEFT:
                return(1);

            case EnterDirection.FROM_TOP:
                return(2);

            case EnterDirection.FROM_RIGHT:
                return(3);

            case EnterDirection.FROM_BOTTOM:
                return(0);

            default:
                return(2);
            }
        }
コード例 #8
0
        public void Update(GameTime gameTime, EnterDirection enterDir)
        {
            // Update Location
            if (viewButton != null)
            {
                viewButton.Text = Language.Translate("View");
            }

            if (enterDir == EnterDirection.Top && bgRect.Y == windowHeight)
            {
                bgRect.Y = 0 - bgRect.Height;
            }
            if (enterDir == EnterDirection.Bottom && bgRect.Y == 0 - bgRect.Height)
            {
                bgRect.Y = windowHeight;
            }

            hideButton.X = (bgRect.Width + bgRect.X) - (SPACING + hideButton.Width);
            hideButton.Y = bgRect.Y + (bgRect.Height / 2 - (hideButton.Height / 2));
            if (viewButton != null)
            {
                viewButton.X = hideButton.X - (viewButton.Width + SPACING);
                viewButton.Y = hideButton.Y;
            }

            textPos.X = bgRect.X + SPACING;
            textPos.Y = bgRect.Y + SPACING;

            // Update Objects
            if (viewButton != null && showing)
            {
                viewButton.Update(gameTime);
            }

            hideButton.Update(gameTime);

            if (showing)
            {
                timer.Update(gameTime);
            }

            if (timer.QueryWaitTime(gameTime))
            {
                leaving = true;
            }

            #region Entering and Leaving Animation

            if (entering)
            {
                currentDir = enterDir;
                if (enterDir == EnterDirection.Top)
                {
                    if (bgRect.Y < SPACING)
                    {
                        bgRect.Y += 2;
                    }
                    else
                    {
                        entering = false;
                    }
                }
                else if (enterDir == EnterDirection.Bottom)
                {
                    if (bgRect.Y > windowHeight - bgRect.Height - SPACING)
                    {
                        bgRect.Y -= 2;
                    }
                    else
                    {
                        entering = false;
                    }
                }
            }
            else if (leaving)
            {
                if (bgRect.Y < windowHeight / 2)
                {
                    if (bgRect.Y >= 0 - bgRect.Height)
                    {
                        bgRect.Y -= 2;
                    }
                    else
                    {
                        leaving = false;
                        showing = false;
                        Active  = false;
                    }
                }
                else
                {
                    if (bgRect.Y < windowHeight)
                    {
                        bgRect.Y += 2;
                    }
                    else
                    {
                        leaving = false;
                        showing = false;
                        Active  = false;
                    }
                }
            }

            #endregion
        }
コード例 #9
0
ファイル: Enter_Action.cs プロジェクト: RhythNS/Toybox
 public Enter(bool entering, Actor prefabActor, EnterDirection enterDirection)
 {
     this.entering       = entering;
     this.prefabActor    = prefabActor;
     this.enterDirection = enterDirection;
 }