Пример #1
0
        //----------------------------------------------------------------------->>METHODS<<
        //adds a node
        //nodes have a number of islands between 0 and 2
        public void AddNode(bool newRow, Texture2D mapImage, List<Texture2D> islandImages, Texture2D fishImage, Texture2D stormImage,
                            Texture2D pirateImage, int screenWidth, int screenHeight, List<InventoryItem> items, Player play)
        {
            MapNode node = new MapNode(rand.Next(0,4),
                                       rand.Next(0,3),
                                       rand.Next(0,2),
                                       rand.Next(0, 3),
                                       mapImage,
                                       islandImages,
                                       fishImage,
                                       stormImage,
                                       pirateImage,
                                       screenWidth,
                                       screenHeight);
            bool addItem = false;
            node.makeIslands(rand, play);
            node.makeFishingSpots(rand);
            node.makeVortexes(rand);
            node.makePirates(rand);
            node.AddItem(items, addItem, rand);
            if (newRow)
            {
                maps.Add(new List<MapNode>());
            }

            maps[Rows() - 1].Add(node);
        }
Пример #2
0
 public void UpdateLabel(Player play)
 {
     if (item == null)
         return;
     if (play.Inventory.GetItemOfType(item.Name) != null)
         text = item.Name + " : " + play.Inventory.GetItemOfType(item.Name).StackNum;
     else
         text = item.Name + " : 0";
 }
Пример #3
0
 /// <summary>
 /// occurs when player collides with a storm
 /// decreases health and fuel
 /// </summary>
 /// <param name="play"></param>
 public void ResolveStorm(Player play, Random rand)
 {
     if (available == true)
     {
         play.changeFuel(-5f);
         play.changeHealth(rand.Next(-30, -10));
         this.available = false;
     }
 }
Пример #4
0
 public Button(String label, Player play, Rectangle rectangle, Texture2D texture, ChangeValue changeValue): base(rectangle, texture)
 {
     this.label = label;
     this.rectangle = rectangle;
     returnValue = false;
     this.texture = texture;
     lastKeyPress = 0;
     this.changeValue = changeValue;
     this.play = play;
 }
Пример #5
0
        public void Move(int screenWidth, int screenHeight, Player play)
        {
            
            xMove = rand.Next(-4, 5);
            yMove = rand.Next(-4, 5);
            change = rand.Next(-15, 15);
            if (change == -10)
            {
                xMod = -2;
            }
            else if (change == 10)
            {
                xMod = 2;
            }
            else if (change == 0)
            {
                xMod = 0;
            }
            change = rand.Next(-15, 15);
            if (change == -10)
            {
                yMod = -2;
            }
            else if (change == 10)
            {
                yMod = 2;
            }
            else if (change == 0)
            {
                yMod = 0;
            }
            xMove += xMod;
            yMove += yMod;

            rekt.X += xMove;
            rekt.Y += yMove;
            
            if(rekt.X < 0)
            {
                rekt.X += Math.Abs(xMove);
            }
            else if(rekt.X + image.Width >= screenWidth)
            {
                rekt.X -= Math.Abs(xMove);
            }
            if(rekt.Y < 0)
            {
                rekt.Y += Math.Abs(yMove);
            }
            else if(rekt.Y + image.Height >= screenHeight)
            {
                rekt.Y -= Math.Abs(yMove);
            }
            
        }
Пример #6
0
 public void ResolvePirate(Player play)
 {
     Random rand = new Random();
     if(available)
     {
         play.changeHealth(rand.Next((int)Math.Ceiling(play.Health / 5f), (int)Math.Ceiling((play.Health / 3f)))* -1);
         int num = play.changeCrew(rand.Next((int)Math.Ceiling(play.Crew / 6f), (int)Math.Ceiling((play.Crew / 2f)))* -1);
         if (num != -1)
             play.Crew -= num;
         this.available = false;
     }
 }
Пример #7
0
        //----------------------------------------------------------------------->>METHODS<<

        public void ResolveFishing(Player play, Random rand, InventoryItem item, MouseState mouse)
        {
            //get random number
            int percent = rand.Next(0, 10);

            if(item == Inventory.net)
            {
                if (play.Inventory.GetItemOfType(item.Name) != null && play.Inventory.GetItemOfType(item.Name).StackNum > 0)
                {
                    if (percent < 6)
                       play.Inventory.AddItem(Inventory.herring, 2);
                    else
                       play.Inventory.AddItem(Inventory.tuna, 1);

                    play.Inventory.DecrementItem(Inventory.net, 1);   
                }
            }

            if (item == Inventory.cage)
            {
                if (play.Inventory.GetItemOfType(item.Name) != null && play.Inventory.GetItemOfType(item.Name).StackNum > 0)
                {
                    if (percent < 1)
                    {
                        play.Inventory.AddItem(Inventory.lobster, 3);
                    }
                    else if (percent < 5)
                    {
                        play.Inventory.AddItem(Inventory.lobster, 2);
                    }
                    else if (percent < 9)
                    {
                        play.Inventory.AddItem(Inventory.lobster, 1);
                    }
                    play.Inventory.DecrementItem(Inventory.cage, 1);
                }
            }

            if (item == Inventory.harpoon)
            {
                if (play.Inventory.GetItemOfType(item.Name) != null && play.Inventory.GetItemOfType(item.Name).StackNum > 0)
                {
                    if (percent < 9)
                        play.Inventory.AddItem(Inventory.swordfish, 1);
                    else
                        play.Inventory.AddItem(Inventory.whale, 1);

                    play.Inventory.DecrementItem(Inventory.harpoon, 1);
                }
            }

        }
Пример #8
0
        //update mousestate
        //check for collisions with mouse and buttons
        public void UpdateManager(MouseState mouseState, KeyboardState key, GameTime gameTime, Player play, SoundEffectInstance sound)
        {
            Point mousePosition = new Point(mouseState.X, mouseState.Y);

            foreach (Button button in list.OfType<Button>())
            {
                if (button.Rectangle.Contains(mousePosition) && mouseState.LeftButton == ButtonState.Pressed && button.Pressed == false)
                {
                    button.Pressed = true;
                }

                if (button.Pressed == true)
                {
                    button.UserInput = button.GetUserInput(button.UserInput, key, gameTime);
                    
                    
                    foreach (Button button2 in list.OfType<Button>())
                    {
                        button2.Pressed = false;
                        button2.NumError = false;
                    }
                    

                    button.Pressed = true;
                }

                if (button.ReturnValue == true)
                {
                    button.UpdatePlayer(play, sound);
                    button.Pressed = false;
                    button.UserInput = "0";
                }
            }

            foreach (TextBox text in List.OfType<TextBox>())
            {
                text.UpdateLabel(play);
                if(text.Rectangle.Contains(mousePosition) && mouseState.LeftButton == ButtonState.Pressed && text.Pressed == false && last.LeftButton == ButtonState.Released)
                {
                    text.Pressed = true;
                }
            }

            last = mouseState;
        }
Пример #9
0
        public void Move(Player play, Random rand)
        {
            if (available)
            {
                Vector2 start = new Vector2(this.rekt.X, this.rekt.Y);
                Vector2 end = new Vector2(play.XPos, play.YPos);

                float distance = Vector2.Distance(start, end);
                Vector2 direction = Vector2.Normalize(end - start);
                int movement = 0;
                if (distance < 90)
                {
                    movement = rand.Next(6, 10);
                    this.rekt.X += (int)(direction.X * movement);
                    this.rekt.Y += (int)(direction.Y * movement);
                }
                else if (distance < 150)
                {
                    movement = rand.Next(5, 8);
                    this.rekt.X += (int)(direction.X * movement);
                    this.rekt.Y += (int)(direction.Y * movement);
                }
                else
                {
                    movement = rand.Next(2, 5);
                    this.rekt.X += (int)(direction.X * movement);
                    this.rekt.Y += (int)(direction.Y * movement);
                }

                if(play.Rekt.X > rekt.X)
                {
                    direct = true;
                }
                else
                {
                    direct = false;
                }
            }
        }
Пример #10
0
        public void ResetGame()
        {
            #region Reset Player
            //Reset player. will update width and length when image is present
            Texture2D temp = play.Image;
            play = new Player("Player", new Rectangle(5, 5, 25, 25));
            play.Image = temp;
            #endregion

            #region Reset Rows / Columns
            currentCol = 0;
            currentRow = 0;
            #endregion

            #region Reset gameState
            //Reset enum
            gameState = States.titleMenu;
            #endregion

            #region Reset objectList
            //Creates an object list to hold the objects currently on screen
            objectList = new List<Object>();
            #endregion

            #region IReset mapManager
            mapManager = new MapManager();
            #endregion

            bool newRow = true;
            List<InventoryItem> shopItems = new List<InventoryItem>();
            #region Adds MapNodes to the MapManager
            //Adding MapNodes to the MapManager
            Random rand = new Random();
            int rows = rand.Next(6, 8);
            int cols = rand.Next(7, 9);
            for (int i = 1; i < rows; i++)
            {
                for (int j = 1; j < cols; j++)
                {
                    if (j > 1)
                        newRow = false;
                    mapManager.AddNode(newRow, mapImage, islandImages, fishingImage, stormImage, pirateImage, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, shopItems, play);
                }
                newRow = true;
            }
            #endregion
        }
Пример #11
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            #region Initialize Player
            //initialize player. will update width and length when image is present
            play = new Player("Player", new Rectangle(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, 25, 25));
            #endregion

            #region Initialize Rows / Columns
            currentCol = 0;
            currentRow = 0;
            #endregion

            #region Initialize gameState
            //initialize enum
            gameState = States.titleMenu;
            #endregion

            #region Initialize objectList
            //Creates an object list to hold the objects currently on screen
            objectList = new List<Object>();
            #endregion

            #region Initialize UImanager
            //initialize manager
            ShopUImanager = new UI_manager();
            TitleUIManager = new UI_manager();
            ControlUIManager = new UI_manager();
            OverUIManager = new UI_manager();
            FishingUI = new UI_manager();
            InventoryUIManager = new UI_manager();
            #endregion

            #region Initialize mapManager
            mapManager = new MapManager();
            #endregion

            #region Initialize islandImages
            islandImages = new List<Texture2D>();
            #endregion

            #region Creates the fullscreen effect
            Window.Position = new Point(0, 0);
            Window.IsBorderless = true;
            graphics.PreferredBackBufferWidth = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
            graphics.PreferredBackBufferHeight = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;
            graphics.ApplyChanges();
            #endregion

            //start external tool
            //Process.Start("C:/Users/Jeffrey Karger/Desktop/scrublords/GameObject/FileChecker/bin/Debug/FileChecker.exe");
            DirectoryInfo di = new DirectoryInfo(".");

            //ProcessStartInfo info = new ProcessStartInfo();
            //info.WorkingDirectory = "../../../../FileChecker/bin/Debug/";
            //info.FileName = "FileChecker.exe";
            //info.UseShellExecute = false;
            //Process.Start(info);
            Process.Start(di.FullName + "/../../../../FileChecker/bin/Debug/FileChecker.exe");


            base.Initialize();
        }
Пример #12
0
        public void UpdatePlayer(Player play, SoundEffectInstance sound)
        {
            sound.Play();
            //fuel
            if (changeValue == ChangeValue.fuel)
            {
                if (play.changeCurrency(int.Parse(this.UserInput) * -1) != -1)
                {
                    this.NumError = true;
                    if (this.UserInput == "0")
                        this.NumError = false;
                }
                else
                {
                    int diff = play.changeFuel(float.Parse(this.UserInput));
                    play.changeCurrency(diff * 1);
                }
                this.ReturnValue = false;
            }

            //health
            if(changeValue == ChangeValue.health)
            {
                if (play.changeCurrency(int.Parse(this.UserInput) * -1) != -1)
                {
                    this.NumError = true;
                    if (this.UserInput == "0")
                        this.NumError = false;
                }
                else
                {
                    int diff = play.changeHealth(int.Parse(this.UserInput));
                    play.changeCurrency(diff * 1);
                }
                this.ReturnValue = false;
            }

            //inventory buy
            if(changeValue == ChangeValue.inventoryBuy)
            {
                if (play.changeCurrency((int.Parse(this.UserInput)*inventoryItem.BuyPrice) * -1) != -1)
                {
                    this.NumError = true;
                    if (this.UserInput == "0")
                        this.NumError = false;
                }
                else
                {
                    int difference = play.Inventory.AddItem(this.inventoryItem, int.Parse(this.UserInput));
                    if(difference != -1)
                        play.changeCurrency(difference * inventoryItem.BuyPrice);
                }
                this.ReturnValue = false;
            }

            //inventory sell
            if(changeValue == ChangeValue.inventorySell)
            {
                int difference = play.Inventory.DecrementItem(this.inventoryItem, int.Parse(this.UserInput));
                play.changeCurrency(int.Parse(this.UserInput) * inventoryItem.SellPrice);
                if (difference != -1)
                {
                    play.changeCurrency((difference * inventoryItem.SellPrice) * -1);
                }
                this.ReturnValue = false;
            }

            //crew
            if(changeValue == ChangeValue.crew)
            {
                if (this.label.Contains("Sell"))
                {
                    int difference = play.changeCrew(int.Parse(this.UserInput) * -1);
                    play.changeCurrency(int.Parse(this.UserInput) * 1);
                    if(difference != -1)
                    {
                        play.changeCurrency(difference * -1);
                        this.NumError = true;
                        if (this.UserInput == "0")
                            this.NumError = false;
                    }
                    this.ReturnValue = false;

                }
                else
                {
                    if (play.changeCurrency(int.Parse(this.UserInput) * -1) != -1)
                    {
                        this.NumError = true;
                        if (this.UserInput == "0")
                            this.NumError = false;
                    }
                    else
                    {
                        play.changeCrew(int.Parse(this.UserInput));
                    }
                    this.ReturnValue = false;
                }
            }
        }
Пример #13
0
        //Creates the island (if there is one) on the map
        //places in a random location with a random size
        public void makeIslands(Random rand, Player play)
        {
            List<int> removedindexes = new List<int>();
            
            Island tempIsland;
            Texture2D islImage;

            for (int i = 0; i < islandNum; i++)
            {
                //Makes sure no islands have the same image on screen
                int num0 = rand.Next(0, islandImages.Count);
                while(removedindexes.Contains(num0))
                {
                    num0 = rand.Next(0, islandImages.Count);
                }
                islImage = islandImages[num0]; 
                removedindexes.Add(num0);

                //Creates the parameters for the new islands
                int num1 = rand.Next(0, screenWidth - islImage.Width - 50);
                int num2 = rand.Next(0, screenHeight - islImage.Height - 50);
                int num3 = rand.Next(50, 150);
                int num4 = rand.Next(50, 150);

                //Creates the island / adds them to the island and object lists
                tempIsland = new Island(num1, num2, num3, num3, islImage);

                islandList.Add(tempIsland);
                objects.Add(tempIsland);
            }
            
            //This crazy bastard makes sure islands don't overlap
            for(int j = 0; j < islandList.Count; j++)
            {
                for(int k = 0; k < islandList.Count; k++)
                {
                    rand = new Random();
                    while(j!=k && (islandList[j].Rekt.Intersects(islandList[k].Rekt) || islandList[k].Rekt.Intersects(play.Rekt)))
                    {
                        islandList[k].Rekt = new Rectangle(rand.Next(0, screenWidth - islandList[k].Rekt.Width),
                                                        rand.Next(0, screenHeight - islandList[k].Rekt.Height),
                                                        rand.Next(50, islandList[k].Rekt.Width),
                                                        rand.Next(50, islandList[k].Rekt.Height));
                    }
                }
            }
                   
        }