示例#1
1
        public override void Create()
        {
            base.Create();

            cControl = new XboxController(SlimDX.XInput.UserIndex.One);
            pControl = new XboxController(SlimDX.XInput.UserIndex.Two);

            GameObject cursor = new Cursor(cControl);
            GameObject player = new Player(pControl);
            GameObject cannon1 = new Cannon();
            cannon1.Position.X = 365;
            cannon1.Position.Y = -265;
            GameObject cannon2 = new Cannon();
            cannon2.Position.X = 365;
            cannon2.Position.Y = 265;
            GameObject cannon3 = new Cannon();
            cannon3.Position.X = -365;
            cannon3.Position.Y = 265;
            GameObject cannon4 = new Cannon();
            cannon4.Position.X = -365;
            cannon4.Position.Y = -265;
            ObjectManager.AddGameObject(cursor);
            ObjectManager.AddGameObject(player);
            ObjectManager.AddGameObject(cannon1);
            ObjectManager.AddGameObject(cannon2);
            ObjectManager.AddGameObject(cannon3);
            ObjectManager.AddGameObject(cannon4);
        }
        public GameScreen(ContentManager Content, Texture2D Background, Player player, Robot robot, bool OnLeftSide)
        {
            this.Content.Unload();
            this.Content.Dispose();
            this.Content = Content;

            //Do some stuff to Left and Right before adding them
            if (OnLeftSide)
            {
                player.Position = new Vector2(60, 120);
                robot.Position = new Vector2(730, 120);
            }
            else
            {
                player.Position = new Vector2(730, 120);
                robot.Position = new Vector2(60, 120);
            }

            FlyingDisc flyingDisc = new FlyingDisc(Content.Load<Texture2D>("General\\FlyingDisc"));
            flyingDisc.Position = new Vector2(70, 110);

            Entities = new List<Entity>(new List<Entity> { player, robot, flyingDisc });

            this.Background = Background;
        }
示例#3
0
 public static Player CreateDefaultPlayer()
 {
     Player player = new Player(10, 10, 20, 0, 0);
     player.Inventory.Add(new InventoryItem(World.ItemByID(World.ITEM_ID_RUSTY_SWORD), 1));
     player.CurrentLocation = World.LocationByID(World.LOCATION_ID_HOME);
     return player;
 }
示例#4
0
        public SuperAdventure()
        {
            InitializeComponent();

            _player = new Player(10, 10, 20, 0, 1);

            lblHitPoints.Text = _player.CurrentHitPoints.ToString();
            lblGold.Text = _player.Gold.ToString();
            lblExperience.Text = _player.ExperiencePoints.ToString();
            lblLevel.Text = _player.Level.ToString();
        }
示例#5
0
        public GameHandler()
        {
            player = new Player(Game1.VIEW_WIDTH / 2, Game1.VIEW_HEIGHT / 2);
            enemy = new Enemy(Game1.VIEW_WIDTH / 2, Game1.VIEW_HEIGHT / 2);
            hud = new Hud();

            //rtCircles = new RenderTarget2D(Game1.graphicsDevice, Game1.VIEW_WIDTH, Game1.VIEW_HEIGHT, true, Game1.graphicsDevice.DisplayMode.Format, DepthFormat.Depth24, 1, RenderTargetUsage.PreserveContents);
            item = 0;
            lost = false;
            lostI = 300;
        }
示例#6
0
        public SuperAdventure()
        {
            InitializeComponent();

            location = new Location(1, "Home", "This is your house");
            player = new Player(10, 10, 20, 0, 1);

            lblHitPoints.Text = player.CurrentHitPoints.ToString();
            lblGold.Text = player.Gold.ToString();
            lblExperience.Text = player.ExperiencePoints.ToString();
            lblLevel.Text = player.Level.ToString();
        }
        public Adventure()
        {
            InitializeComponent();

            _player = new Player(10, 10, 20, 0, 1);

            MoveTo(World.LocationByID(World.LOCATION_ID_HOME));

            lblHitPoints.Text = _player.CurrentHitPoints.ToString();
            lblGold.Text = _player.Gold.ToString();
            lblExperience.Text = _player.ExperiencePoints.ToString();
            lblLevel.Text = _player.Level.ToString();
        }
示例#8
0
        public basicRPG()
        {
            InitializeComponent();

            _player = new Player(10, 10, 20, 0, 1);
            MoveTo(World.LocationByID(World.LOCATION_ID_HOME));
            _player.Inventory.Add(new InventoryItem(World.ItemByID(World.ITEM_ID_RUSTY_SWORD), 1));

            lblHitPoints.Text = _player.CurrentHitPoints.ToString();
            lblGold.Text = _player.Gold.ToString();
            lblExperience.Text = _player.ExperiencePoints.ToString();
            lblLevel.Text = _player.Level.ToString();
        }
 ///<summary>
 /// Konstruktor.
 ///</summary>
 /// <param name="b">objek board</param>
 /// <param name="d">objek dadu</param>
 /// <param name="gameType">tipe game</param>
 public Game(Board b, Dice d,int gameType)
 {
     this.dice = d;
     this.papan = b;
     if (gameType == GAME_TYPE1)
     {
         players = new Player[] { new Player(0, "Player 1", false), new Player(0, "Player 2", false) };
     }
     else
     {
         players = new Player[] { new Player(0, "Player 1", false), new Player(0, "Computer", true) };
     }
     this.winner = null;
     this.totalPlayer = players.Length;
     this.playingTurn = 0;
 }
示例#10
0
        public SuperAdventure()
        {
            InitializeComponent();

            Engine.Location location = new Engine.Location(1, "home", "This Is Your House", null);



            _player = new Engine.Player(10, 10, 20, 0, 1);

            Location test1 = new Engine.Location(1, "your house", "where you live", null);

            Item     item   = new Item(1, "key", "first key");
            Quest    quest1 = new Quest(1, "", "", 100, 100);
            Location test3  = new Engine.Location(1, "", "", item, quest1, null);
        }
        public SuperAdventure()
        {
            InitializeComponent();

            _player = new Player();

            _player.CurrentHitPoints = 10;
            _player.MaximumHitPoints = 10;
            _player.Gold = 20;
            _player.ExperiancePoints = 0;
            _player.Level = 1;

            lblHitPoints.Text = _player.CurrentHitPoints.ToString();
            lblGold.Text = _player.Gold.ToString();
            lblExperiance.Text = _player.ExperiancePoints.ToString();
            lblLevel.Text = _player.Level.ToString();
        }
示例#12
0
        public MemoAdventure()
        {
            InitializeComponent();

            if(File.Exists(PLAYER_DATA_FILE_NAME))
            {
                _player = Player.CreatePlayerFromXmlString(File.ReadAllText(PLAYER_DATA_FILE_NAME));
            }
            else
            {
                _player = Player.CreateDefaultPlayer();
            }

            MoveTo(_player.CurrentLocation);

            UpdatePlayerStats();
        }
        public SuperAdventure()
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR");
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-FR");

            InitializeComponent();

            if (File.Exists(PLAYER_DATA_FILE_NAME))
            {
                _player = Player.CreatePlayerFromXmlString(File.ReadAllText(PLAYER_DATA_FILE_NAME));
            }
            else
            {
                _player = Player.CreateDefaultPlayer();
            }
            MoveTo(_player.CurrentLocation);
            UpdatePlayerStats();
        }
        public SuperAdventure()
        {
            InitializeComponent();

            if (File.Exists(PLAYER_DATA_FILE_NAME))
            {
                //Set player to default to see if XML part of code has changed any of the basic functions
                // of the game or if just so you can save current state of game to disk.
                //_player = Player.CreatePlayerFromXmlString(File.ReadAllText(PLAYER_DATA_FILE_NAME));
                _player = Player.CreateDefaultPlayer();

            }
            else
            {
                _player = Player.CreateDefaultPlayer();
            }

            MoveTo(_player.CurrentLocation);

            UpdatePlayerStats();
        }
        /// <summary>
        /// Start Game logic
        /// </summary>
        public void Start(Grid root)
        {
            // Initialize the two basic objects needed for user interactions
            this.InputProvider = this.inputProvider ?? new WpfInputProvider();
            this.OutputRenderer = this.outputRenderer ?? new WpfRenderer(root);

            string testPlayerName = "John";

            // Create the active player
            var player = new Player(testPlayerName);

            BoardSettings testBoardSettings = new EasyBoardSettings();

            var board = new Board(testBoardSettings, new List<IBoardObserver>());
            var scoreboard = new Scoreboard();
            var contentFactory = new ContentFactory();
            var initializationStrategy = new StandardGameInitializationStrategy(contentFactory);
            var boardOperator = new CommandOperator(board, scoreboard);
            var engine = new StandardOnePlayerMinesweeperEngine(board, this.inputProvider, this.outputRenderer, boardOperator, scoreboard, player);

            engine.Initialize(initializationStrategy);
            board.Subscribe(engine);
            engine.Run();
        }
        /// <summary>
        /// Start Game logic
        /// </summary>
        public void Start()
        {
            // Initialize the two basic objects needed for user interactions
            this.InputProvider = this.inputProvider ?? new ConsoleInputProvider();
            this.OutputRenderer = this.outputRenderer ?? new ConsoleRenderer();

            // Render initial UI
            this.OutputRenderer.RenderWelcomeScreen(string.Join(string.Empty, RenderersConstants.GameTitle));
            this.OutputRenderer.RenderNewPlayerCreationRequest();

            // Create the active player
            var player = new Player(this.InputProvider.ReceiveInputLine());

            // Render console menu handler and execute logic for requesting board settings
            // TODO: Refactor menu handler logic
            int[] cursorPosition = this.OutputRenderer.GetCursor();
            var menuItems = new List<IGameMode>()
            {
                new BeginnerMode(),
                new IntermediateMode(),
                new ExpertMode()
            };

            var menuHandler = new ConsoleMenuHandler(this.inputProvider, this.outputRenderer, menuItems, cursorPosition[0] + 1, cursorPosition[1]);

            menuHandler.ShowSelections();

            BoardSettings boardSettings = menuHandler.RequestUserSelection();
            this.OutputRenderer.ClearScreen();
            this.OutputRenderer.SetCursor(visible: true);
            //// End of menu handler logic

            var board = new Board(boardSettings, new List<IBoardObserver>());
            var scoreboard = new Scoreboard();
            var contentFactory = new ContentFactory();
            var initializationStrategy = new StandardGameInitializationStrategy(contentFactory);
            var boardOperator = new CommandOperator(board, scoreboard);
            var engine = new StandardOnePlayerMinesweeperEngine(board, this.inputProvider, this.outputRenderer, boardOperator, scoreboard, player);

            engine.Initialize(initializationStrategy);
            board.Subscribe(engine);
            engine.Run();
        }
 public Robot(Texture2D Texture, Player Player)
     : base(Texture, new Vector2(Texture.Width / 2, Texture.Height / 2))
 {
 }
        public override void Update(GameTime gameTime)
        {
            if (Updates)
            {
                #region Rectangles

                Vector2 BBottomRight = new Vector2(Backgrounds[Bindex].Value.Width, Backgrounds[Bindex].Value.Height);
                BRectangle = new Rectangle(Graphics.Width / 2 - (int)BBottomRight.X / 4, (int)BBottomRight.Y / 4, (int)BBottomRight.X / 2, (int)BBottomRight.Y / 2);

                Vector2 PleftBottomRight = new Vector2(Characters[Pleftindex].Value.Width, Characters[Pleftindex].Value.Height);
                Vector2 PrightBottomRight = new Vector2(Characters[Prightindex].Value.Width, Characters[Prightindex].Value.Height);
                PleftRectangle = new Rectangle(Graphics.Width / 4 - (int)PleftBottomRight.X / 2 - 60, Graphics.Height / 4 * 3 - (int)PleftBottomRight.Y / 2, (int)PleftBottomRight.X, (int)PleftBottomRight.Y);
                PrightRectangle = new Rectangle(Graphics.Width / 4 * 3 - (int)PrightBottomRight.X / 2 + 60, Graphics.Height / 4 * 3 - (int)PrightBottomRight.Y / 2, (int)PrightBottomRight.X, (int)PrightBottomRight.Y);

                StartTripRectangle = new Rectangle(Graphics.Width / 2 - StartTripTex.Width / 2, Graphics.Height / 4 * 3 - StartTripTex.Height, StartTripTex.Width, StartTripTex.Height);

                StartTripRectangle.Inflate(80, 40);

                #endregion

                foreach (TouchLocation tl in Input.Touches)
                {
                    #region Selector

                    if (tl.State == TouchLocationState.Pressed)
                    {
                        if (Graphics.Device.Viewport.Bounds.Contains((int)tl.Position.X, (int)tl.Position.Y))
                        {
                            if (Utilities.PadRectangle(PleftRectangle, 1.2f, 1.03f).Contains((int)tl.Position.X, (int)tl.Position.Y))
                            {
                                if (OnLeftSide)
                                {
                                    if (Pleftindex >= Characters.Count - 1) Pleftindex = 0; else Pleftindex++;
                                }
                                else
                                {
                                    OnLeftSide = true;
                                }
                            }
                            else if (Utilities.PadRectangle(PrightRectangle, 1.25f, 1.04f).Contains((int)tl.Position.X, (int)tl.Position.Y))
                            {
                                //This code is for the right player selection
                                //if (Prightindex >= Characters.Count - 1) Prightindex = 0; else Prightindex++;

                                if (!OnLeftSide)
                                {
                                    if (Pleftindex >= Characters.Count - 1) Pleftindex = 0; else Pleftindex++;
                                }
                                else
                                {
                                    OnLeftSide = false;
                                }
                            }
                            else if (StartTripRectangle.Contains((int)tl.Position.X, (int)tl.Position.Y))
                            {
                                StartPressed = true;
                                startId = tl.Id;
                            }
                            else
                            {
                                if (Bindex >= Backgrounds.Count - 1) Bindex = 0; else Bindex++;
                            }
                        }
                    }
                    if (tl.State == TouchLocationState.Released)
                    {
                        if (!StartTripRectangle.Contains((int)tl.Position.X, (int)tl.Position.Y))
                        {
                            if (startId == tl.Id)
                            {
                                StartPressed = false;
                            }
                        }
                        if (StartTripRectangle.Contains((int)tl.Position.X, (int)tl.Position.Y))
                        {
                            if (startId == tl.Id)
                            {
                                StartPressed = false;
                                Prightindex = Rand.Next(Characters.Count - 1);
                                Texture2D leftTex = Characters[Pleftindex].Value;
                                Texture2D rightTex = Characters[Prightindex].Value; //Just make it random
                                Texture2D Background = Backgrounds[Bindex].Value;

                                Backgrounds.RemoveAt(Bindex);

                                //logic is wierd here since upon removing indices change
                                //Consider revisiting seperate content managers per Screen
                                if (Pleftindex == Prightindex)
                                {
                                    Characters.RemoveAt(Pleftindex);
                                }
                                else if (Pleftindex < Prightindex)
                                {
                                    Prightindex--;
                                    Characters.RemoveAt(Pleftindex);
                                    Characters.RemoveAt(Prightindex);
                                }
                                else if (Pleftindex > Prightindex)
                                {
                                    Characters.RemoveAt(Pleftindex);
                                    Characters.RemoveAt(Prightindex);
                                }

                                //Manually dispose of unneeded content
                                foreach (var pair in Backgrounds) pair.Value.Dispose();
                                foreach (var pair in Characters) pair.Value.Dispose();

                                StartTripPressedTex.Dispose();
                                StartTripTex.Dispose();

                                Player player = new Player(leftTex);
                                Robot robot = new Robot(rightTex, player);

                                //Exceptions can throw if you try to draw disposed content
                                base.Updates = false;
                                base.Draws = false;

                                GameState.AddScreen(new LoadingScreen(new GameScreen(Content, Background, player, robot, OnLeftSide)));
                                GameState.RemoveScreen(this);
                            }
                        }
                    }

                    #endregion
                }
            }
        }
 /// <summary>
 /// Method untuk menentukan pemenang.
 /// </summary>
 /// <param name="p">pemain yang menang</param>
 public void SetWinner(Player p)
 {
     this.winner = p;
 }
示例#20
0
        public SuperAdventure()
        {
            InitializeComponent();

            if (File.Exists(PLAYER_DATA_FILE_NAME))
            {
                _player = Player.CreatePlayerFromXmlString(File.ReadAllText(PLAYER_DATA_FILE_NAME));
            }
            else
            {
                _player = Player.CreateDefaultPlayer();
            }

            lblHitPoints.DataBindings.Add("Text", _player, "CurrentHitPoints");
            lblGold.DataBindings.Add("Text", _player, "Gold");
            lblExperience.DataBindings.Add("Text", _player, "ExperiencePoints");
            lblLevel.DataBindings.Add("Text", _player, "Level");

            dgvInventory.RowHeadersVisible = false;
            dgvInventory.AutoGenerateColumns = false;

            dgvInventory.DataSource = _player.Inventory;

            dgvInventory.Columns.Add(new DataGridViewTextBoxColumn
            {
                HeaderText = "Name",
                Width = 197,
                DataPropertyName = "Description"
            });

            dgvInventory.Columns.Add(new DataGridViewTextBoxColumn
            {
                HeaderText = "Quantity",
                DataPropertyName = "Quantity"
            });

            dgvQuests.RowHeadersVisible = false;
            dgvQuests.AutoGenerateColumns = false;

            dgvQuests.DataSource = _player.Quests;

            dgvQuests.Columns.Add(new DataGridViewTextBoxColumn
            {
                HeaderText = "Name",
                Width = 197,
                DataPropertyName = "Name"
            });

            dgvQuests.Columns.Add(new DataGridViewTextBoxColumn
            {
                HeaderText = "Done?",
                DataPropertyName = "IsCompleted"
            });

            cboWeapons.DataSource = _player.Weapons;
            cboWeapons.DisplayMember = "Name";
            cboWeapons.ValueMember = "Id";

            if (_player.CurrentWeapon != null)
            {
                cboWeapons.SelectedItem = _player.CurrentWeapon;
            }

            cboWeapons.SelectedIndexChanged += cboWeapons_SelectedIndexChanged;

            cboPotions.DataSource = _player.Potions;
            cboPotions.DisplayMember = "Name";
            cboPotions.ValueMember = "Id";

            _player.PropertyChanged += PlayerOnPropertyChanged;
            _player.OnMessage += DisplayMessage;

            _player.MoveTo(_player.CurrentLocation);
        }
示例#21
0
        public static void Load(ContentManager cm)
        {
            if (map != null)
                map.Reset();

            MapContentManager = cm;
            map = MapContentManager.Load<Map>("Maps/Start");
            font = MapContentManager.Load<SpriteFont>("Arial");
            boxTexture = MapContentManager.Load<Texture2D>("Textures/tile");
            Map.CollisionTexture = MapContentManager.Load<Texture2D>("Textures/collision");
            Map.BlockTexture = MapContentManager.Load<Texture2D>("Textures/block");
            Block b = new Block();
            b.Position = new Vector2(5, 4);
            b.Size = new Vector2(32, 32);
            b.IsMoveable = true;
            map.Blocks.Add(b);
            map.SetIndex(LayerType.Collision, (int)b.Position.X, (int)b.Position.Y, 1);

            player = new Player();
            Player.Load(MapContentManager, "Textures/Player");
            Player.Position = new Vector2(64, 64);

            fadeIn = true;

            fadeTexture = MapContentManager.Load<Texture2D>("Textures/fade");
        }
        private void LoadGame()
        {
            // Open a previously saved game and sets the player properties
            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            openFileDialog1.InitialDirectory = Application.ExecutablePath;
            openFileDialog1.Filter = "Xml Files|*.xml";
            openFileDialog1.FileName = PLAYER_DATA_FILE_NAME;

            if(openFileDialog1.ShowDialog() == DialogResult.OK)
                _player = Player.CreatePlayerFromXmlString(File.ReadAllText(openFileDialog1.FileName));
            MoveTo(_player.CurrentLocation);
            UpdatePlayerStats();
            openFileDialog1.Dispose();
        }
示例#23
0
        public static Player CreatePlayerFromXmlString(string xmlPlayerData)
        {
            try
            {
                XmlDocument playerData = new XmlDocument();

                playerData.LoadXml(xmlPlayerData);

                int currentHitPoints = Convert.ToInt32(playerData.SelectSingleNode("/Player/Stats/CurrentHitPoints").InnerText);
                int maximumHitPoints = Convert.ToInt32(playerData.SelectSingleNode("/Player/Stats/MaximumHitPoints").InnerText);
                int gold = Convert.ToInt32(playerData.SelectSingleNode("/Player/Stats/Gold").InnerText);
                int experiencePoints = Convert.ToInt32(playerData.SelectSingleNode("/Player/Stats/ExperiencePoints").InnerText);

                Player player = new Player(currentHitPoints, maximumHitPoints, gold, experiencePoints);

                int currentLocationID = Convert.ToInt32(playerData.SelectSingleNode("/Player/Stats/CurrentLocation").InnerText);
                player.CurrentLocation = World.LocationByID(currentLocationID);

                foreach (XmlNode node in playerData.SelectNodes("/Player/InventoryItems/InventoryItem"))
                {
                    int id = Convert.ToInt32(node.Attributes["ID"].Value);
                    int quantity = Convert.ToInt32(node.Attributes["Quantity"].Value);

                    for (int i = 0; i < quantity; i++)
                    {
                        player.AddItemToInventory(World.ItemByID(id));
                    }
                }

                foreach (XmlNode node in playerData.SelectNodes("/Player/PlayerQuests/PlayerQuest"))
                {
                    int id = Convert.ToInt32(node.Attributes["ID"].Value);
                    bool isCompleted = Convert.ToBoolean(node.Attributes["IsCompleted"].Value);

                    PlayerQuest playerQuest = new PlayerQuest(World.QuestByID(id));
                    playerQuest.IsCompleted = isCompleted;

                    player.Quests.Add(playerQuest);
                }

                return player;
            }
            catch
            {
                // If there was an error with the XML data, return a default player object
                return Player.CreateDefaultPlayer();
            }
        }
 private void newGameToolStripMenuItem_Click(object sender, EventArgs e)
 {
     // Create a new game and reset interface and properties
     rtbMessages.Clear();
     _player = Player.CreateDefaultPlayer();
     MoveTo(_player.CurrentLocation);
     UpdatePlayerStats();
 }