示例#1
0
文件: Enemy.cs 项目: JSinc/choco
        public void SeekPlayer(GameTime gametime, Player player)
        {
            UpdateFrame(player);

            if (position.X < player.position.X)
            {
                direction.X = moveRight;
                speed.X = enemySpeed;
            }
            if (position.X > player.position.X)
            {
                direction.X = moveLeft;
                speed.X = enemySpeed;
            }
            if (position.Y < player.position.Y)
            {
                direction.Y = moveDown;
                speed.Y = enemySpeed;
            }
            if (position.Y > player.position.Y)
            {
                direction.Y = moveUp;
                speed.Y = enemySpeed;
            }

            sourceRectangle = new Rectangle(frameSize.X * currentFrame.X, frameSize.Y * currentFrame.Y, frameSize.X, frameSize.Y);

            destinationRectangle = new Rectangle((int)position.X, (int)position.Y, characterTexture.Width / 2, characterTexture.Height / 1);

            base.Update(gametime, speed, direction);
        }
示例#2
0
文件: HealthBar.cs 项目: JSinc/choco
        public void Update(Player player)
        {
            KeyboardState mKeys = Keyboard.GetState();

            UpdateHealth(player);

            health = (int)MathHelper.Clamp(health, 0, 100);
        }
示例#3
0
文件: Stats.cs 项目: JSinc/choco
        public void Update(Player player)
        {
            health = player.health;
            mass = player.mass;

            hString = "Health: " + health.ToString() + "%";
            sString = "Score: " + score.ToString();
            mString = "Mass: " + mass.ToString();
            score++;
        }
示例#4
0
文件: HealthBar.cs 项目: JSinc/choco
 public void UpdateHealth(Player player)
 {
     health = player.health;
 }
示例#5
0
文件: Enemy.cs 项目: JSinc/choco
        public void UpdateFrame(Player player)
        {
            if (player.position.X < position.X)
                currentFrame.X = 0;

            if (player.position.X > position.X)
                currentFrame.X = 1;
        }
示例#6
0
文件: Game1.cs 项目: JSinc/choco
        protected override void Initialize()
        {
            player = new Player();
            enemy = new Enemy();
            largeEnemy = new LargeEnemy();
            playerHealth = new HealthBar();
            stats = new Stats(player);

            background1 = new Scrolling(Content.Load<Texture2D>("Backgrounds/background1"), new Rectangle(0, 0, screenWidth, screenHeight));
            background2 = new Scrolling(Content.Load<Texture2D>("Backgrounds/background1"), new Rectangle(screenWidth, 0, screenWidth, screenHeight));

            base.Initialize();
        }
示例#7
0
文件: Stats.cs 项目: JSinc/choco
        String sString; // score string

        #endregion Fields

        #region Constructors

        public Stats(Player player)
        {
            health = player.health;
            mass = player.mass;
        }
示例#8
0
文件: Scrolling.cs 项目: JSinc/choco
 public void Update(Player player)
 {
     if (player.position.X >= 700 && player.direction.X == player.moveRight)
         rec.X -= (int)player.frameSize.X;
 }