コード例 #1
0
ファイル: ClothBox.cs プロジェクト: TODO-Project/TODO-game
        public override void Update(GameTime gametime)
        {
            if (SpriteCollision(currentPlayer.destinationRectangle))
            {
                this.pressButtonMsg = true;
                if (currentPlayer.Controls.Use && !isOpen)
                {
                    isOpen = true;
                }
            }
            else
            {
                this.pressButtonMsg = false;
            }
            if (isOpen)
            {
                if (!TimerStarted)
                {
                    RandomObject();
                    clothPic     = new ClothPic(randomCloth, Position);
                    TimerStarted = true;
                    chrono       = DateTime.Now;
                }
                else
                {
                    if (DateTime.Now > chrono.AddSeconds(chronoDuration))
                    {
                        ////console.writeLine(chronoDuration);
                        GamePage.BonusList.Remove(this);
                    }
                }

                currentRow     = 0; // sprite ouvert
                pressButtonMsg = false;

                if (!currentPlayer.Controls.Use)
                {
                    Validated = true;
                }
                if (Validated && SpriteCollision(currentPlayer.destinationRectangle))
                {
                    pressButtonMsg = true;
                    if (currentPlayer.Controls.Use)
                    {
                        interract(currentPlayer);
                    }
                }
            }
        }
コード例 #2
0
ファイル: GamePage.cs プロジェクト: TODO-Project/TODO-game
        public override void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.End();
            var viewMatrix = camera.GetViewMatrix(this);

            spriteBatch.Begin(transformMatrix: viewMatrix);

            bgPosition = camera.Origin;
            //spriteBatch.Draw(bgtexture, bgPosition, Color.White);

            map.Draw(spriteBatch);

            #region Drawing and updating Bonuses
            for (var i = 0; i < BonusList.Count; i++)
            {
                var currentBonus = BonusList[i];
                currentBonus.Draw(spriteBatch);
                currentBonus.Update(Game1.gameTime);
                currentBonus.UpdateSprite(Game1.gameTime);
            }
            #endregion

            #region Drawing and updating bullets
            for (var i = 0; i < Bullet.BulletList.Count; i++)
            {
                Bullet currentBullet = (Bullet)Bullet.BulletList[i];
                currentBullet.Update(Game1.gameTime, 32, mapWidth, mapHeight, map.BCollisionLayer);
                currentBullet.Draw(spriteBatch);
            }
            #endregion

            #region Drawing and updating players
            Player bad_player = PlayerList.Find(x => x.Id == 0);
            if (bad_player != null)
            {
                PlayerList.Remove(bad_player);
            }
            for (var i = 0; i < PlayersToDraw.Count; i++)
            {
                Player player = PlayersToDraw[i];
                player.Control(Game1.gameTime, 32, mapWidth, mapHeight, map.PCollisionLayer);
            }

            for (var i = 0; i < PlayersToDraw.Count; i++)
            {
                Player player = PlayersToDraw[i];
                player.healthBar.Draw(spriteBatch);
                player.DrawCharacter(Game1.spriteBatch);
            }

            #endregion

            #region Drawing WeaponPics
            for (var i = 0; i < GamePage.PicList.Count; i++)
            {
                if (GamePage.PicList[i] is WeaponPic)
                {
                    WeaponPic weaponPic = (WeaponPic)GamePage.PicList[i];
                    weaponPic.Draw(spriteBatch);
                }
                else if (GamePage.PicList[i] is ClothPic)
                {
                    ClothPic clothPic = (ClothPic)GamePage.PicList[i];
                    clothPic.Draw(spriteBatch);
                }
            }
            #endregion
            spriteBatch.End();   // fin spritebatch

            spriteBatch.Begin(); // tout ce qui ne bouge pas avec la camera

            overlay.Draw(spriteBatch);
            #region drawing clothes to body

            for (var i = 0; i < player.ClothesList.Length; i++)
            {
                if (player.ClothesList[i] != null)
                {
                    player.ClothesList[i].Draw(spriteBatch);
                }
            }
            DrawTeamScores(spriteBatch);
            scOverlay.Draw(spriteBatch);
            #endregion
        }