/// <summary>
        /// Draws the Game.
        /// </summary>
        public override void Draw(BaseGameModel model, Painter painter, Graphics g, int totalClientWidth, int totalClientHeight)
        {
            GameModel m = model as GameModel;

            if (m != null && m.World != null)
            {
                GameWorld w = m.World;
                if (m.ReadyToDraw)
                {
                    switch (w.StatePrimary)
                    {
                    case GameStatePrimary.LoadingResources:
                    case GameStatePrimary.MainMenu:
                    case GameStatePrimary.GameInProgressMenu:
                        ViewTitleMenu.Draw(m, painter, g);
                        break;

                    case GameStatePrimary.CoreGamePlay:
                        ViewCoreGameplay.Draw(m, painter, g, totalClientWidth, totalClientHeight);
                        break;

                    case GameStatePrimary.Exiting: break;
                    }

                    ViewDebugPrimary.Draw(m, painter, g, totalClientWidth, totalClientHeight);
                }
            }
        }
        public static void Process(BaseGameModel baseGameModel, NvpRecord record)
        {
            GameModel model     = baseGameModel as GameModel;
            Animation animation = new Animation();
            String    forSprite = null;

            foreach (KeyValuePair <String, String> kvp in record.NameValuePairs)
            {
                switch (kvp.Key)
                {
                case KeyForSprite:
                    forSprite = kvp.Value;
                    break;

                case KeyForSpriteCategory:
                    animation.Category = kvp.Value;
                    break;

                case KeyName:
                    animation.Key = kvp.Value;
                    break;

                case KeyOverallDelay:
                    animation.OverallDelay = Int32.Parse(kvp.Value);
                    break;

                case KeyFrames:
                    ProcessAnimationFrames(animation, kvp.Value);
                    break;
                }
            }
            model.SpriteFactory.AddAnimation(animation);
        }
        /// <summary>
        /// Given some text we want to draw (which may not already be set into a PreparedPagedText object),
        /// draw it to the screen at the given logical position.
        /// </summary>
        public static void DrawPreparedText(BaseGameModel model, Position logicalPosition, String fullText, Graphics g, Font font,
                                            Boolean drawBorder, Pen penBorder, Int32 edgeBuffer, ref PreparedPagedText prepText)
        {
            Position displayPos = model.Camera.MapLogicalToDisplay(logicalPosition, true);

            if (drawBorder)
            {
                Drawing2D.DrawRectBorder(g, penBorder, displayPos);
            }
            if (prepText == null)
            {
                prepText = DrawText.PrepareTextForDisplayInBox(fullText, g,
                                                               font, (Int32)displayPos.Width, (Int32)displayPos.Height, (Int32)(edgeBuffer * model.Camera.CurrentScale));
            }

            List <String> preparedOutputText = prepText.GetCurrentPageText();
            Int32         currentLineY       = 0;

            for (Int32 currentLine = 0; currentLine < preparedOutputText.Count; currentLine++)
            {
                String   textToDraw     = preparedOutputText[currentLine];
                Position displayTextPos = model.Camera.TopLeftAlignTextWithinRect(logicalPosition, textToDraw, font, g, ignoreCameraPosition: true);
                g.DrawString(textToDraw, font, Brushes.White, (Single)displayTextPos.UpperLeftX, (Single)displayTextPos.UpperLeftY + currentLineY);
                currentLineY += prepText.LineHeight;
            }
        }
        public static void Process(BaseGameModel baseGameModel, NvpRecord record)
        {
            GameModel model = baseGameModel as GameModel;

            if (model != null)
            {
                SpriteSheet sheet = new SpriteSheet();
                if (record.NameValuePairs.ContainsKey(KeyCategory))
                {
                    sheet.Category = record.NameValuePairs[KeyCategory];
                }
                if (record.NameValuePairs.ContainsKey(KeyPath))
                {
                    String path = record.NameValuePairs[KeyPath];
                    sheet.ImageData = new Bitmap(path);
                    foreach (Color transparentColor in model.Config.TransparentColors)
                    {
                        sheet.ImageData.MakeTransparent(transparentColor);
                    }
                    String baseKey = Path.GetFileNameWithoutExtension(path);
                    if (record.NameValuePairs.ContainsKey(KeyKeyPrefix))
                    {
                        sheet.Key = String.Concat(record.NameValuePairs[KeyKeyPrefix], baseKey);
                    }
                    else
                    {
                        sheet.Key = baseKey;
                    }
                }
                if (record.NameValuePairs.ContainsKey(KeyNumFramesX))
                {
                    sheet.NumFramesX = Int32.Parse(record.NameValuePairs[KeyNumFramesX]);
                }
                else
                {
                    sheet.NumFramesX = 1;
                }
                if (record.NameValuePairs.ContainsKey(KeyNumFramesY))
                {
                    sheet.NumFramesY = Int32.Parse(record.NameValuePairs[KeyNumFramesY]);
                }
                else
                {
                    sheet.NumFramesY = 1;
                }
                if (record.NameValuePairs.ContainsKey(KeyBorderWidth))
                {
                    sheet.BorderWidth = Int32.Parse(record.NameValuePairs[KeyBorderWidth]);
                }
                else
                {
                    sheet.BorderWidth = 1;
                }

                sheet.FrameWidth  = (sheet.ImageData.Width - sheet.BorderWidth) / sheet.NumFramesX - sheet.BorderWidth;
                sheet.FrameHeight = (sheet.ImageData.Height - sheet.BorderWidth) / sheet.NumFramesY - sheet.BorderWidth;

                model.SpriteFactory.AddSpriteSheet(sheet);
            }
        }
 /// <summary>
 /// Creates a new GameDataLoader.
 /// </summary>
 internal GameDataLoader(BaseGameModel gameModel)
 {
     m_gameModel           = gameModel;
     DirectoryData         = DefaultDirectoryData;
     DataFileSearchPattern = DefaultDataSearchPattern;
     SimulatedLoadingDelay = DefaultSimulatedLoadingDelay;
 }
Exemple #6
0
        public static async Task <List <BaseGameModel> > CollectBaseGameInformation()
        {
            List <BaseGameModel> baseGameModelList = new List <BaseGameModel>();

            //season 16 - 35
            for (int f = 16; f < 35; f++)
            {
                var seasonNumber = f.ToString();

                var url        = "http://www.j-archive.com/showseason.php?season=" + seasonNumber;
                var httpClient = new HttpClient();
                var html       = await httpClient.GetStringAsync(url);

                Regex  rgxShowNumber   = new Regex("(>&#35;)");
                string showNumberClean = rgxShowNumber.Replace(html, "xxshow_number=");
                Regex  rgxDate         = new Regex("(, aired&#160;)");
                string dateClean       = rgxDate.Replace(showNumberClean, "xxdate=");

                //GameModel_id=6079"xxshow_number=7815xxdate=2018-07-27</a>

                for (int i = 0; i < dateClean.Length - 19; i++)
                {
                    var showNumber = "";
                    var gameId     = "";
                    var date       = "";
                    var j          = i;

                    var a = '"'.ToString();

                    if (dateClean.Substring(i, 8) == "game_id=")
                    {
                        while (dateClean.Substring(j + 8, 1) != '"'.ToString()) //collect gameId
                        {
                            gameId += dateClean.Substring(j + 8, 1);
                            j++;
                        }
                        while (dateClean.Substring(j, 14) != "xxshow_number=") //collect showNumber
                        {
                            j++;
                        }
                        while (dateClean.Substring(j + 14, 7) != "xxdate=") //collect showDebutDate
                        {
                            showNumber += dateClean.Substring(j + 14, 1);
                            j++;
                        }
                        if (dateClean.Substring(j + 14, 7) == "xxdate=")
                        {
                            date = dateClean.Substring(j + 21, 10);
                        }
                        BaseGameModel newBaseGameModel = new BaseGameModel();
                        newBaseGameModel.BaseGameJArchiveGameId = gameId;
                        newBaseGameModel.BaseGameShowNumber     = showNumber;
                        newBaseGameModel.BaseGameShowDebutDate  = date;
                        baseGameModelList.Add(newBaseGameModel);
                    }
                }
            }
            return(baseGameModelList);
        }
 public static void FillCircle(BaseGameModel model, Graphics g, Brush b, Single xCenterLog, Single yCenterLog, Single radiusLog, Boolean ignoreCameraPosition)
 {
     //PointF logPoint = new PointF(xCenterLog, yCenterLog);
     //PointF dispPoint = model.Camera.MapLogicalToDisplay(logPoint, ignoreCameraPosition);
     //Double scale = model.Camera.GetScale(ignoreCameraPosition);
     //Single radiusDisp = (Single)(radiusLog * scale);
     //g.FillEllipse(b, dispPoint.X - radiusDisp, dispPoint.Y - radiusDisp, radiusDisp * 2, radiusDisp * 2);
 }
        /// <summary>
        /// Given some offset rectangle, and some logical position, draw a solid color rectangle and text over it.
        /// </summary>
        public static void DrawTextOnRectangle(BaseGameModel model, Position logPosOffsetRect, Position logPosRect,
                                               SolidBrush sbBaseRect, SolidBrush sbText, Graphics g, Font f, String text)
        {
            logPosRect = logPosRect.AddPositionUpperLeft(logPosOffsetRect);
            Position disPosRect = model.Camera.MapLogicalToDisplay(logPosRect, true);

            Drawing2D.DrawRect(g, sbBaseRect, disPosRect);
            Position disPosText = model.Camera.BottomLeftAlignTextWithinRect(logPosRect, text, f, g, true);

            g.DrawString(text, f, sbText, (Single)disPosText.UpperLeftX, (Single)disPosText.UpperLeftY);
        }
        /// <summary>
        /// Draws a rectangle with a border.  Basically draws a larger rectangle with the border color, and then draws a small
        /// rectangle inside with the fill color.
        /// Returns the display position for the inner rectangle.
        /// If the fill color is semi-transparent, realize that due to the implementation of this method, the border color will appear through
        /// the fill color.
        /// </summary>
        public static void FillRectWithBorder(BaseGameModel model, Graphics g, Position rectDisplay, Brush borderColor, Brush fillColor,
                                              Double borderSizeLogical, Boolean ignoreCameraPos, out Position rectInnerDisplay)
        {
            Position p = rectDisplay;

            Drawing2D.DrawRect(g, borderColor, p);

            rectInnerDisplay = new Position(p);
            Double scale = model.Camera.GetScale(ignoreCameraPos);

            rectInnerDisplay.TransformByPixels(-borderSizeLogical * scale);
            Drawing2D.DrawRect(g, fillColor, rectInnerDisplay);
        }
        /// <summary>
        /// ALL Player Input checking starts here.
        /// </summary>
        public override void ApplyInput(BaseGameModel model, UserInput userInput)
        {
            base.ApplyInput(model, userInput);
            GameModel m     = model as GameModel;
            GameWorld world = m.World;

            switch (world.StatePrimary)
            {
            case GameStatePrimary.MainMenu: ControllerMainMenu.ApplyInput(m, userInput); break;

            case GameStatePrimary.CoreGamePlay: ControllerCoreGameplay.ApplyInput(m, userInput); break;
            }

            // Also check for Debug key presses
            ControllerDebug.ApplyInput(m, userInput);
        }
Exemple #11
0
        public static void Process(BaseGameModel baseGameModel, NvpRecord record)
        {
            GameModel  model = baseGameModel as GameModel;
            GameConfig cfg   = model.Config;

            foreach (KeyValuePair <String, String> kvp in record.NameValuePairs)
            {
                switch (kvp.Key)
                {
                case KeySimulateLoadingDelay: cfg.SimulateLoadingDelay = Int32.Parse(kvp.Value); break;

                case KeyTransparentColor: AddTransparentColor(cfg, kvp.Value); break;

                case KeyInitialArsenalAbility: AddInitialArsenalAbilities(cfg, kvp.Value); break;

                case KeyInitialArsenalSlots: cfg.InitialArsenalSlots = Int32.Parse(kvp.Value); break;
                }
            }
        }
Exemple #12
0
 public UIElement(BaseGameModel model, Double bottomCenterX, Double bottomCenterY, Double width, Double height)
 {
     m_model  = model;
     m_logPos = new Position(bottomCenterX, bottomCenterY, width, height);
 }
Exemple #13
0
 public BaseScreenModel(BaseGameModel model)
 {
     m_model = model;
 }
 public override bool IsBetterThan(BaseGameModel other)
 {
     // No model info to compare progression, so keep first
     return(true);
 }
        /// <summary>
        /// Draws a border for a rectangle.  Remember: Pens have a width.
        /// </summary>
        public static void DrawRectBorder(BaseGameModel m, Graphics g, Pen p, Position logicalPos, Boolean ignoreCameraPos)
        {
            Position displayPos = m.Camera.MapLogicalToDisplay(logicalPos, ignoreCameraPos);

            DrawRectBorder(g, p, displayPos);
        }
        /// <summary>
        /// Draws a solid/filled rectangle.  Maps this rectangle to the display window based on the camera.
        /// </summary>
        public static void DrawRect(BaseGameModel model, Graphics g, Brush b, Position rect)
        {
            Position rectAdjusted = model.Camera.MapLogicalToDisplay(rect, true);

            Drawing2D.DrawRect(g, b, rectAdjusted);
        }
Exemple #17
0
 public NameGenerator(BaseGameModel model)
 {
     m_baseGameModel = model;
 }
Exemple #18
0
 public NameCollection(BaseGameModel model)
 {
     m_baseGameModel = model;
 }
 public DrawableObject(BaseGameModel m)
 {
     m_model  = m;
     m_camera = m.Camera;
     Visible  = true;
 }