/* * Tile.cs * Authors: Brian Chesbrough * * Copyright Matthew Belmonte 2007 */ using System; using System.Collections.Generic; using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Storage; using System.Diagnostics; using Pina3D.Particles; using tAC_Engine; namespace Astropolis { class HackerTile : Entity { private bool mMouseWasOver; //True when mouse is over tile private bool mLeftClickedThisCycle; //True when mouse left clicks on tile during current cycle private bool mLeftClickedLastCycle; //True when mouse was left clicked last cycle private int mNumClicks; //Number of times this tile has been clicked public int NumClicks { set { mNumClicks = value; } get { return mNumClicks; } } public bool MouseWasOver { set { mMouseWasOver = value; } get { return mMouseWasOver; } } public bool IsLeftClicked { get { return mLeftClickedThisCycle; } } public bool WasMouseClicked { get { return mLeftClickedLastCycle; } } /// /// Constructor /// /// Sprite Texture /// /// public HackerTile(Texture2D sprite, int xPos, int yPos) : base(sprite) { this.X = xPos; this.Y = yPos; this.Tint = Color.TransparentBlack; mNumClicks = 0; mMouseWasOver = false; } public void Update(MouseState mouse) { mLeftClickedLastCycle = mLeftClickedThisCycle; mLeftClickedThisCycle = false; //Check for left click release to increment the number of clicks on tile if (mLeftClickedLastCycle) { if (mMouseWasOver) { if (mouse.LeftButton == ButtonState.Released) { if (mNumClicks < 2) { mNumClicks++; } } } } //If this tile is left clicked if (mMouseWasOver) { if (mouse.LeftButton == ButtonState.Pressed) { mLeftClickedThisCycle = true; } } } } }