} PlayScreenModes Mode = PlayScreenModes.Init; // Sprites on the screen public ShipSprite ship; MissileSprite missile; List<AlienMissileSprite> alienMissiles = new List<AlienMissileSprite>(); UfoSprite ufo; BarrierSprite barrier1; BarrierSprite barrier2; BarrierSprite barrier3; BarrierSprite barrier4; //LineSprite line; List<AlienSprite> aliens = new List<AlienSprite>(); List<LivesSprite> lifesprites = new List<LivesSprite>(); float MoveWaitSeconds; float AlienMoveXStep = 10; float AlienMoveYStep = 10; float AlienHitBottomY = -70; float MoveWaitPercent = 0.97f; int level; int alienMoveSound = 1; int AlienCount; public int ActivePlayer; public int Lives = 3; AlienDirections alienDirection; // Text on the screen Text shipStatusText; Text DebugText;
/// <summary> /// Set the costume for this sprite /// </summary> /// <param name="costume">costume to switch to</param> public void SetCostume(Costume costume) { this.Costume = costume; this.costumeNumber = null; }
/// <summary> /// Begin creating a custom costume by copying the current costume /// </summary> public Costume Copy(string name) { Costume newCostume = new Costume { Name = name, xCenter = this.xCenter, yCenter = this.yCenter, }; newCostume.frameSeconds = this.frameSeconds; newCostume.textures = new List<Texture2D>(); int prevCurrentFrameNumber = currentFrameNumber; for (int i = 0 ; i < textures.Count() ; i++) { newCostume.pixels.Add(null); CurrentFrameNumber = i + 1; var newTexture = new Texture2D(ScratchyXnaGame.ScratchyGame.GraphicsDevice, this.Width, this.Height); Color[] newPixels = new Color[this.Width * this.Height]; this.textures[i].GetData(newPixels); newTexture.SetData(newPixels); newCostume.textures.Add(newTexture); } currentFrameNumber = prevCurrentFrameNumber; newCostume.CalculateCenter(); return newCostume; }
/// <summary> /// Get a costume ready to use /// </summary> /// <param name="costume">Costume to add to this sprite</param> public Costume AddCostume(Costume costume) { // Keep a local list of sprite specific costumes Costumes.Add(costume); if (Costume == null) { Costume = costume; } return costume; }
public override void Load() { YCenter = VerticalAlignments.Bottom; AddSound("Helicopter sounds/heli"); ChopperLeft = AddCostume("Chopper/ChopperMove1") .AddFrame("Chopper/ChopperMove2") .AddFrame("Chopper/ChopperMove3") .StartAnimation(); ChopperRight = AddCostume(ChopperLeft.Copy().FlipX()) .StartAnimation(); ; ChopperFront = AddCostume("Chopper/ChopperForward") .AddFrame("Chopper/ChopperForward2") .AddFrame("Chopper/ChopperForward3") .StartAnimation(); AnimationSpeed = .25f; SpriteColor = Color.Red; Layer = 1.7f; Lives = 3; Scale = 0.5f; X = 50; Y = -50; state = ChopperStates.Alive; fire1 = Scene.AddSprite<Fire>(); fire2 = Scene.AddSprite<Fire>(); fire1.Hide(); fire2.Hide(); if (playScene != null) { fire2.BackgroundLayer = playScene.GroundLayer; fire1.BackgroundLayer = playScene.GroundLayer; } if (Scene is PlayScene) { PlaySound("Helicopter sounds/heli", true); } }