Example #1
0
 public void Draw()
 {
     TopWall.Draw();
     BottomWall.Draw();
     LeftWall.Draw();
     RightWall.Draw();
     Terrain.Draw();
 }
Example #2
0
    // Update is called once per frame
    void FixedUpdate()
    {
        RaycastHit hit;
        Ray        ray = new Ray(Camera.main.transform.position, (go_Player.transform.position - Camera.main.transform.position));

        LeftWall.SetActive(true);
        RightWall.SetActive(true);
        BottomWall.SetActive(true);
        TopWall.SetActive(true);


        if (Physics.Raycast(ray, out hit, Mathf.Infinity, mask, QueryTriggerInteraction.Collide))
        {
            hit.transform.gameObject.SetActive(false);
        }
    }
Example #3
0
 public static void DrawAll()
 {
     Console.ForegroundColor = ConsoleColor.White;
     try {
         if (State.ScreenNeedsRedraw)
         {
             BottomWall.Draw();
             TopWall.Draw();
             ScoreBoard.DrawScoreBoard();
             Player1.Draw();
             Player2.Draw();
         }
         else if (State.PlayerNeedsRedraw)
         {
             Player1.Draw();
             Player2.Draw();
         }
         Ball.Draw();
     }
     catch (Exception e) {
         throw new InvalidOperationException("You need to use InitializeGame method before. " + e.Message);
     }
 }
Example #4
0
        public void LoadContent(Vector2 tileDimensions)
        {
            Image.LoadContent();
            if (Water.Path != String.Empty)
            {
                Water.LoadContent();
            }
            Vector2 position = -tileDimensions; //tileDimensions - new Vector2(128,128)

            foreach (string row in Tile.Row)
            {
                string[] split = row.Split(']');
                position.X  = -tileDimensions.X;
                position.Y += tileDimensions.Y;
                rowLength   = split.Length - 1;
                foreach (string s in split)
                {
                    if (s != String.Empty)
                    {
                        position.X += tileDimensions.X;
                        tilesCount.Add(TileCollision.Passive);

                        if (!s.Contains("x"))
                        {
                            Tile tile = new Tile();

                            string str    = s.Replace("[", String.Empty);
                            int    value1 = int.Parse(str.Substring(0, str.IndexOf(':')));
                            int    value2 = int.Parse(str.Substring(str.IndexOf(':') + 1));

                            //Set TileTypes
                            if (SolidTiles.Contains("[" + value1.ToString() + ":" + value2.ToString() + "]"))
                            {
                                tilesCount[tilesCount.Count() - 1] = TileCollision.Solid;
                            }
                            else if (RightWall.Contains("[" + value1.ToString() + ":" + value2.ToString() + "]"))
                            {
                                tilesCount[tilesCount.Count() - 1] = TileCollision.RightWall;
                            }
                            else if (TopWall.Contains("[" + value1.ToString() + ":" + value2.ToString() + "]"))
                            {
                                tilesCount[tilesCount.Count() - 1] = TileCollision.TopWall;
                            }
                            else if (BottomWall.Contains("[" + value1.ToString() + ":" + value2.ToString() + "]"))
                            {
                                tilesCount[tilesCount.Count() - 1] = TileCollision.BottomWall;
                            }
                            else if (BottomDoor.Contains("[" + value1.ToString() + ":" + value2.ToString() + "]"))
                            {
                                tilesCount[tilesCount.Count() - 1] = TileCollision.BottomDoor;
                            }
                            else if (SEWallCorner.Contains("[" + value1.ToString() + ":" + value2.ToString() + "]"))
                            {
                                tilesCount[tilesCount.Count() - 1] = TileCollision.SEWallCorner;
                            }
                            else if (SWWallCorner.Contains("[" + value1.ToString() + ":" + value2.ToString() + "]"))
                            {
                                tilesCount[tilesCount.Count() - 1] = TileCollision.SWWallCorner;
                            }
                            else if (NEWallCorner.Contains("[" + value1.ToString() + ":" + value2.ToString() + "]"))
                            {
                                tilesCount[tilesCount.Count() - 1] = TileCollision.NEWallCorner;
                            }
                            else if (NWWallCorner.Contains("[" + value1.ToString() + ":" + value2.ToString() + "]"))
                            {
                                tilesCount[tilesCount.Count() - 1] = TileCollision.NWWallCorner;
                            }
                            else if (RightHalf.Contains("[" + value1.ToString() + ":" + value2.ToString() + "]"))
                            {
                                tilesCount[tilesCount.Count() - 1] = TileCollision.RightHalf;
                            }
                            else if (LeftHalf.Contains("[" + value1.ToString() + ":" + value2.ToString() + "]"))
                            {
                                tilesCount[tilesCount.Count() - 1] = TileCollision.LeftHalf;
                            }
                            else if (SECorner.Contains("[" + value1.ToString() + ":" + value2.ToString() + "]"))
                            {
                                tilesCount[tilesCount.Count() - 1] = TileCollision.SECorner;
                            }
                            else if (SWCorner.Contains("[" + value1.ToString() + ":" + value2.ToString() + "]"))
                            {
                                tilesCount[tilesCount.Count() - 1] = TileCollision.SWCorner;
                            }
                            else if (NECorner.Contains("[" + value1.ToString() + ":" + value2.ToString() + "]"))
                            {
                                tilesCount[tilesCount.Count() - 1] = TileCollision.NECorner;
                            }
                            else if (NWCorner.Contains("[" + value1.ToString() + ":" + value2.ToString() + "]"))
                            {
                                tilesCount[tilesCount.Count() - 1] = TileCollision.NWCorner;
                            }
                            else if (BattleTiles.Contains("[" + value1.ToString() + ":" + value2.ToString() + "]"))
                            {
                                tilesCount[tilesCount.Count() - 1] = TileCollision.Battle;
                            }
                            else if (WaterTiles.Contains("[" + value1.ToString() + ":" + value2.ToString() + "]"))
                            {
                                tilesCount[tilesCount.Count() - 1] = TileCollision.Water;
                                Water.IsActive = true;
                            }
                            else if (NpcTiles.Contains("[" + value1.ToString() + ":" + value2.ToString() + "-"))
                            {
                                string[] p    = NpcTiles.Split(']');
                                string   name = String.Empty;
                                foreach (string pstr in p)
                                {
                                    if (pstr.Contains("[" + value1.ToString() + ":" + value2.ToString() + "-"))
                                    {
                                        name = pstr.Substring(pstr.IndexOf('-') + 1);
                                        tilesCount[tilesCount.Count() - 1] = TileCollision.NPC;
                                        Vector2 npcLocation = new Vector2((int)Math.Floor(position.X / tileDimensions.X),
                                                                          (int)Math.Floor(position.Y / tileDimensions.Y));
                                        npcTiles.Add(npcLocation, name);
                                        npcName.Add(name, npcLocation);
                                    }
                                }
                            }
                            else if (PortalTiles.Contains("[" + value1.ToString() + ":" + value2.ToString() + "-"))
                            {
                                string[] p      = PortalTiles.Split(']');
                                string   value3 = String.Empty;
                                foreach (string pstr in p)
                                {
                                    if (pstr.Contains("[" + value1.ToString() + ":" + value2.ToString() + "-"))
                                    {
                                        value3 = pstr.Substring(pstr.IndexOf('-') + 1);
                                        tilesCount[tilesCount.Count() - 1] = TileCollision.Portal;
                                        portalTiles.Add(new Vector2((int)Math.Floor(position.X / tileDimensions.X),
                                                                    (int)Math.Floor(position.Y / tileDimensions.Y)), value3);
                                    }
                                }
                            }

                            tile.LoadContent(position, new Rectangle(
                                                 (int)(value1 * tileDimensions.X), (int)(value2 * tileDimensions.Y),
                                                 (int)tileDimensions.X, (int)tileDimensions.Y), tilesCount[tilesCount.Count() - 1]);


                            if (OverlayTiles.Contains("[" + value1.ToString() + ":" + value2.ToString() + "]"))
                            {
                                overlayTiles.Add(tile);
                            }
                            else
                            {
                                underlayTiles.Add(tile);
                            }

                            tileLength = tile.SourceRect.Width;
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Load graphics content for the game.
        /// </summary>
        public override void LoadContent()
        {
            if (Content == null)
                Content = new ContentManager(ScreenManager.Game.Services, "Content");

            //gameFont = Content.Load<SpriteFont>("gamefont");
            Football.LoadContent(Content);
            football.CalculateScale(); // need to call this after loading content.
            Stats.LoadContent(Content);
            background = Content.Load<Texture2D>("soccer field");

            // load high scores
            HighScoreScreen.LoadHighscore();

            // Bonus Object Load Content
            WindBonusObject.LoadContent(Content);
            RingBonusObject.LoadContent(Content);
            DoubleBonusObject.LoadContent(Content);
            TimeBonusObject.LoadContent(Content);
            //ringTexture = Content.Load<Texture2D>("ring");
            PatternStars.LoadContent(Content);
            //loading walls
            Wall leftWall = new LeftWall(null, this);
            Wall rightWall = new RightWall(null, this);
            Wall topWall = new TopWall(null, this);
            Wall bottomWall = new BottomWall(null, this);
            walls = new List<Wall>();
            walls.Add(leftWall); walls.Add(rightWall); walls.Add(topWall); walls.Add(bottomWall);

            InitializeBonusObjects();
            foreach (BonusObject bo in bonusObjects)
            {
                bo.CalculateScale();
            }

            // A real game would probably have more content than this sample, so
            // it would take longer to load. We simulate that by delaying for a
            // while, giving you a chance to admire the beautiful loading screen.
            //Thread.Sleep(1000);

            // once the load has finished, we use ResetElapsedTime to tell the game's
            // timing mechanism that we have just finished a very long frame, and that
            // it should not try to catch up.
            ScreenManager.Game.ResetElapsedTime();
        }