using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework; using Util; namespace FaceOff { /* * used to show which panels are from the face tray * * * * */ enum Moving { Right, Left, Down, Up }; class BorderStar : GameObject { float movespeed = .5f;//how fast the star moves around the cell int width = 1, height = 1; //size of a texture Vector2 myPosition = new Vector2(0,0); // topleft of the star public Vector2 Position { get { return myPosition; } set { myPosition = value; } } Vector2 Star1Position = new Vector2(0, 0); Vector2 diff1 = new Vector2(20, 0); Moving moving1 = Moving.Right; float rot1 = 0.0f; float rotspeed1 = .05f; Vector2 Star2Position = new Vector2(0, 0); Vector2 diff2 = new Vector2(10, 0); Moving moving2 = Moving.Right; float rot2 = 0.0f; float rotspeed2 = .1f; Vector2 Star3Position = new Vector2(0, 0); Vector2 diff3 = new Vector2(0, 0); Moving moving3 = Moving.Right; float rot3 = 0.0f; float rotspeed3 = .2f; bool mVisible = true; Vector2 mScale1 = new Vector2(.4f, .4f); Vector2 mScale2 = new Vector2(.25f, .25f); Vector2 mScale3 = new Vector2(.15f, .15f); public BorderStar( Vector2 nPosition, int nwidth, int nheight) { myPosition = nPosition; Vector2 diff1 = new Vector2(50, 0); Vector2 diff2 = new Vector2(10, 0); Vector2 diff3 = new Vector2(0, 0); width = nwidth; height = nheight; } //moves the star around the portrait public void Update() { MoveStar(ref Star1Position, ref diff1, ref moving1); MoveStar(ref Star2Position, ref diff2, ref moving2); MoveStar(ref Star3Position, ref diff3, ref moving3); rot1 += rotspeed1; rot2 += rotspeed2; rot3 += rotspeed3; } public void MoveStar(ref Vector2 pos, ref Vector2 diff, ref Moving moving) { pos.X = myPosition.X + diff.X; pos.Y = myPosition.Y + diff.Y; switch (moving) { case Moving.Right: diff.X += movespeed; if (pos.X >= myPosition.X + width - 3) moving = Moving.Down; break; case Moving.Down: diff.Y += movespeed; if (pos.Y >= myPosition.Y + height - 3) moving = Moving.Left; break; case Moving.Left: diff.X -= movespeed; if (pos.X <= myPosition.X + 5) moving = Moving.Up; break; case Moving.Up: diff.Y -= movespeed; if (pos.Y <= myPosition.Y + 5) moving = Moving.Right; break; } } public void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch) { if (mVisible) { spriteBatch.Draw(Texture, Star1Position, null, new Color(255, 255, 255, 255), rot1, new Vector2(Texture.Width / 2, Texture.Height / 2), mScale1, SpriteEffects.None, 1.0f); spriteBatch.Draw(Texture, Star2Position, null, new Color(255, 255, 255, 255), rot2, new Vector2(Texture.Width / 2, Texture.Height / 2), mScale2, SpriteEffects.None, 1.0f); spriteBatch.Draw(Texture, Star3Position, null, new Color(255, 255, 255, 255), rot3, new Vector2(Texture.Width / 2, Texture.Height / 2), mScale3, SpriteEffects.None, 1.0f); } } } }