using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; namespace FaceOff { class Cell : GameObject { private BorderStar mStar; public BorderStar Star { get { return mStar; } set { mStar = value; } } private bool mAnimatingStar = false; //to be used after the tray is placed public bool AnimatingStar { get { return mAnimatingStar; } set { mAnimatingStar = value; } } private float mScale = 1.0f; private int mCategory = -1; public int Category { get { return mCategory; } set { mCategory = value; } } private int holdingRef; public int HoldingReference { get { return holdingRef; } set { holdingRef = value; } } private int alpha = 255; public int Alpha { get { return alpha; } set { alpha = value; } } //Should we draw the cell private bool mVisible; public bool Visible { get { return mVisible; } set { mVisible = value; } } //True if the cell is blank and needs to be filled private bool mBlank; public bool Blank { get { return mBlank; } set { mBlank = value; #if DEBUG Console.WriteLine(mBlank); #endif } } //the bounding box for collision private BoundingBox collisionBox; public BoundingBox CollisionBox { get { return collisionBox; } set { collisionBox = value; } } //has the cell been placed private bool placed; public bool Placed { get { return placed; } set { placed = value; } } private bool answered = false; public bool Answered { get { return answered; } set { answered = value; } } private Vector2 mDrawPosition; public Vector2 DrawPosition { get { return mDrawPosition; } set { mDrawPosition = value; } } private int mSize; public int Size { get { return mSize; } set { mSize = value; } } public void Scale() { if (Texture.Width != mSize) { mScale = (float)mSize / (float)Texture.Width; } } public void contains(TrayCell holding) { Texture = holding.Texture; mBlank = false; placed = true; mCategory = holding.Category; holdingRef = holding.Reference; mAnimatingStar = true; Scale(); } public void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch) { if (mVisible && Texture != null) { spriteBatch.Draw(Texture, mDrawPosition, null, new Color(255,255,255,(byte)alpha), 0.0f, Vector2.Zero, mScale, SpriteEffects.None, 1.0f); } if (mAnimatingStar) { mStar.Draw(spriteBatch); } } /// /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// /// Provides a snapshot of timing values. public void Update(GameTime gameTime) { if (Answered) { //fade out the image. It is alpha greater than 5 because if it is anything less //the screen will flicker with the decrement of 10 each frame once it gets to a negative alpha. if (alpha > 5) { alpha -= 10; } else { Visible = false; } } if (mAnimatingStar) { mStar.Update(); } } } }