/// <summary> /// Create the game instance /// </summary> public MainGame(string level) { currentBomb_ = new CurrentElement(); this.graphics_ = new GraphicsDeviceManager(this) { IsFullScreen = true, SupportedOrientations = DisplayOrientation.LandscapeLeft, PreferMultiSampling = true }; this.level_ = level; ended_ = false; lose_ = false; this.em_ = new Event(); this.ladder_ = new Ladder(); this.selecterAnimation_ = new SelecterAnimation(); #region mapNameInit mapName_ = new List<string> { "NumbaWan", "DidUCheckTuto", "It's Something", "Versus", "CombisTheG", "InTheRedCorner", "TheBreach", "OppositeForces", "XFactor", "ChooseYourSide", "DynamiteWarehouse", "FaceToFace", "OneStepAway", "FindYourWayOut", "Corporate", "Unreachable", "Tetris", "Life", "Invasion", "A-Maze-Me" }; tutoName_ = new List<string> { "TutoNormalBomb", "TutoLineBomb", "TutoConeBomb", "TutoXBomb", "TutoCheckpointBS", "TutoHBomb", "TutoUltimateBomb", "TutoBonusTNT" }; #endregion isTuto_ = tutoName_.Contains(this.level_); Content.RootDirectory = "Content"; }
/// <summary> /// Event Unitests /// </summary> public static void Unitest() { var e = new Event(); while (true) { var ret = e.GetEvents(); while (ret.ActionType == Action.Type.NoEvent) { ret = e.GetEvents(); // Do an action to leave the loop } // Put your breakpoint here } }
/// <summary> /// /// </summary> /// <param name="text"> The SpriteSheet</param> /// <param name="framesPerAnim">The number of Frames of each animations</param> /// <param name="linesPerAnim">The number of Lines for each animations</param> /// <param name="frameSpeed">the average speed given to the animations</param> /// <param name="cycles"></param> /// <param name="animations">the number of animation on the SpriteSheet</param> public SpriteSheet(Texture2D text, int[] framesPerAnim, int[] linesPerAnim, double[] frameSpeed, bool[] cycles, int animations) { this.spriteSheet_ = text; this.currentAnimation_ = 0; this.currentFrame_ = 0; this.currentElapsedTime_ = 0; this.event_ = new Event(); this.anims_ = new Dictionary<int, Anim>(); // int useless, a terme mettre un enum qui fit bien. this.frameSize_ = new Rectangle(0, 0, this.spriteSheet_.Width / framesPerAnim.Max(), this.spriteSheet_.Height / animations); for (var i = 0; i < animations; ++i) { this.anims_.Add(i, new Anim(new Point(0, i), framesPerAnim[i], frameSpeed[i], cycles[i])); i += linesPerAnim[i] - 1; } }
/// <summary> /// /// </summary> /// <param name="text">The SpriteSheet</param> /// <param name="framesPerAnim">The number of Frames of each animations</param> /// <param name="animations">the number of animation on the SpriteSheet</param> /// <param name="frameSpeed">the average speed given to the animations</param> public SpriteSheet(Texture2D text, int[] framesPerAnim, int animations, double frameSpeed = 30.0) { this.spriteSheet_ = text; this.currentAnimation_ = 0; this.currentFrame_ = 0; this.currentLine_ = 0; this.currentElapsedTime_ = 0; this.event_ = new Event(); this.anims_ = new Dictionary<int, Anim>(); // int useless, a terme mettre un enum qui fit bien. this.frameSize_ = new Rectangle(0, 0, this.spriteSheet_.Width / framesPerAnim.Max(), this.spriteSheet_.Height / animations); this.anims_.Add(0, new Anim(new Point(0, 0), framesPerAnim[0], frameSpeed, true)); for (var i = 1; i < animations; ++i) { this.anims_.Add(i, new Anim(new Point(0, i), framesPerAnim[i], frameSpeed)); } }
/// <summary> /// Constructor used by the clone methods. /// Create a new SpriteSheet who is exactly the same /// than the one taken in parameters. /// </summary> /// <param name="ss">The spriteSheet to clone</param> private SpriteSheet(SpriteSheet ss) { this.spriteSheet_ = ss.spriteSheet_; this.frameSize_ = ss.frameSize_; this.anims_ = ss.anims_; this.event_ = ss.event_; this.currentAnimation_ = ss.currentAnimation_; this.AnimationDone = ss.AnimationDone; this.currentFrame_ = ss.currentFrame_; this.currentLine_ = ss.currentLine_; this.currentElapsedTime_ = ss.currentElapsedTime_; }