public override void init(ContentManager Content) { content = Content; texture = Content.Load <Texture2D>(".\\Sprites\\mushrooms\\bolinhaVoadora\\flyingBolinha"); spriteSheetPositions = Content.Load <Dictionary <string, Rectangle> >(".\\Sprites\\mushrooms\\bolinhaVoadora\\flyingBolinhaXML"); spriteSheet = new SpriteSheet(texture, spriteSheetPositions); spriteSheet.addAnimation(new AnimationStruct("RUN", AnimationStruct.makeSequence(11, 12), 10, null)); spriteSheet.addAnimation(new AnimationStruct("IDLE1", AnimationStruct.makeSequence(0, 10), 15, endIdle)); spriteSheet.play("IDLE1"); centerPosition = new Vector2(spriteSheet[spriteSheet.currentAnimation.frames.ElementAt(0)].Width / 2, spriteSheet[spriteSheet.currentAnimation.frames.ElementAt(0)].Height / 2); idRandom = new Random().Next(); gravity = .1f; range = 30; // velocity.Y = 2.8f; limitBaseY = 325; isInitialized = true; position.Y = limitBaseY; // velocity.Y = -2; }
public override void init(ContentManager Content) { acumDie = 0; texture = Content.Load <Texture2D>(".\\Sprites\\mushrooms\\star\\star"); spriteSheetPositions = Content.Load <Dictionary <string, Rectangle> >(".\\Sprites\\mushrooms\\star\\starXML"); spriteSheet = new SpriteSheet(texture, spriteSheetPositions); spriteSheet.addAnimation(new AnimationStruct("INIT", AnimationStruct.makeSequence(0, 5), 10, endInit)); spriteSheet.addAnimation(new AnimationStruct("IDLE", AnimationStruct.makeSequence(5, 8), 12, endIdle)); spriteSheet.addAnimation(new AnimationStruct("GOAWAY", AnimationStruct.makeSequence(5, 0), 8, kill)); spriteSheet.play("INIT"); centerPosition = new Vector2(spriteSheet[spriteSheet.currentAnimation.frames.ElementAt(0)].Width / 2, spriteSheet[spriteSheet.currentAnimation.frames.ElementAt(0)].Height / 2); idRandom = new Random().Next(); gravity = 0f; range = 35; //velocity.Y = 1; limitBaseY = 325; effect = behaviour.effect; isInitialized = true; }
public override void init(ContentManager Content) { content = Content; texture = Content.Load <Texture2D>(".\\Sprites\\mushrooms\\bolinha\\bolinha"); spriteSheetPositions = Content.Load <Dictionary <string, Rectangle> >(".\\Sprites\\mushrooms\\bolinha\\bolinhaXML"); spriteSheet = new SpriteSheet(texture, spriteSheetPositions); spriteSheet.addAnimation(new AnimationStruct("RUN", AnimationStruct.makeSequence(12, 21), 10, null)); spriteSheet.addAnimation(new AnimationStruct("IDLE1", AnimationStruct.makeSequence(0, 7), 15, null)); spriteSheet.addAnimation(new AnimationStruct("FALLING", AnimationStruct.makeSequence(8, 11), 12, run)); spriteSheet.play("IDLE1"); centerPosition = new Vector2(spriteSheet[spriteSheet.currentAnimation.frames.ElementAt(0)].Width / 2, spriteSheet[spriteSheet.currentAnimation.frames.ElementAt(0)].Height / 2); idRandom = new Random().Next(); gravity = .1f; range = 30; // velocity.Y = 2.8f; limitBaseY = 335; isInitialized = true; Game1.playSound("bupbup"); }
public override void init(ContentManager Content) { content = Content; texture = Content.Load <Texture2D>(".\\Sprites\\mushrooms\\bolinhaVermelha\\bolinhaVermelha"); spriteSheetPositions = Content.Load <Dictionary <string, Rectangle> >(".\\Sprites\\mushrooms\\bolinhaVermelha\\bolinhaVermelhaXML"); spriteSheet = new SpriteSheet(texture, spriteSheetPositions); spriteSheet.addAnimation(new AnimationStruct("RUN", AnimationStruct.makeSequence(12, 21), 10, null)); spriteSheet.addAnimation(new AnimationStruct("IDLE1", AnimationStruct.makeSequence(0, 7), 15, null)); spriteSheet.addAnimation(new AnimationStruct("FALLING", AnimationStruct.makeSequence(8, 11), 12, run)); spriteSheet.play("IDLE1"); centerPosition = new Vector2(spriteSheet[spriteSheet.currentAnimation.frames.ElementAt(0)].Width / 2, spriteSheet[spriteSheet.currentAnimation.frames.ElementAt(0)].Height / 2); Random rnd = new Random(); idRandom = rnd.Next(0, 10); gravity = .1f; range = 30; // velocity.Y = 2.8f; limitBaseY = 325; position = new Vector2(); position.Y = limitBaseY; if (idRandom < 5) { position.X = -50; } else { position.X = 820; } behaviour.force += 3; isInitialized = true; }
public override void init(ContentManager Content) { content = Content; idRandom = new Random().Next(0, 100); if (idRandom < 10 && behaviour.type == AbstractBehaviour.MUSHROOM) { soonDeadly = true; } texture = Content.Load <Texture2D>(behaviour.tileSheet); if (behaviour.tileSheetXML != null && behaviour.tileSheetXML != "") { spriteSheetPositions = Content.Load <Dictionary <string, Rectangle> >(behaviour.tileSheetXML); spriteSheet = new SpriteSheet(texture, spriteSheetPositions); spriteSheet.addAnimation(new AnimationStruct("IDLE", AnimationStruct.makeSequence(0, behaviour.totFrames), 20, null)); spriteSheet.play("IDLE"); centerPosition = new Vector2(spriteSheet[spriteSheet.currentAnimation.frames.ElementAt(0)].Width / 2, spriteSheet[spriteSheet.currentAnimation.frames.ElementAt(0)].Height / 2); } else { centerPosition = new Vector2(texture.Width / 2, texture.Height / 2); } if (soonDeadly && !inRain) { deadlyMush = Content.Load <Texture2D>(".\\Sprites\\enemies\\deadly\\deadly"); deadlyCounter = 0; colorBlinkCounter = 0; } if (inRain) { // gravity = 0.1f; //velocity.X = 3f; velocity.Y = 3f; } else { gravity = 0f; } range = behaviour.range; isInitialized = true; DefaultFX tempFX = new FXShow(position.X - texture.Width / 2, position.Y - texture.Height / 2); GameScreen.getFXLayer().add(tempFX); tempFX.init(Content); dieCounter = 2000; effect = behaviour.effect; }
public override void init(ContentManager Content) { texture = Content.Load <Texture2D>(".\\Sprites\\effects\\impact\\FXImpact"); spriteSheetPositions = Content.Load <Dictionary <string, Rectangle> >(".\\Sprites\\effects\\impact\\FXImpactXML"); spriteSheet = new SpriteSheet(texture, spriteSheetPositions); spriteSheet.addAnimation(new AnimationStruct("INIT", AnimationStruct.makeSequence(0, 3), 10, kill)); spriteSheet.play("INIT"); centerPosition = new Vector2(spriteSheet[spriteSheet.currentAnimation.frames.ElementAt(0)].Width / 2, spriteSheet[spriteSheet.currentAnimation.frames.ElementAt(0)].Height / 2); idRandom = new Random().Next(); isInitialized = true; collidable = false; limitBaseY = 480; }
public bool PlayClip(SpriteRenderer targetRenderer, string path, bool looping = false, int fps = 10) { // DON'T PLAY THE SAME ANIMATION ON TOP OF ITSELF, STOP THE PREVIOUS ANIMATION if (!_animations.ContainsKey(targetRenderer)) { _animations.Add(targetRenderer, null); } else if (_animations[targetRenderer]._path == path) { return(true); } else { StopCoroutine(_animations[targetRenderer]._coroutine); } AnimationStruct animation = new AnimationStruct(); animation._target = targetRenderer; animation._path = path; _animations[targetRenderer] = animation; // LOAD THE SPRITESHEET AND AVERT USER IF THE IMPORT FAILED Sprite[] frames = Resources.LoadAll <Sprite>(path); if (frames.Length == 0) { //Debug.Log("Resources/" + spriteSheetPath + " not found."); return(false); } // LAUNCH LOOPING ANIMATION OR SINGLE ANIMATION COROUTINE if (looping) { animation._length = Mathf.Infinity; animation._coroutine = StartCoroutine(PlayForever(targetRenderer, frames, fps)); } else { animation._length = frames.Length * (1f / fps); animation._coroutine = StartCoroutine(PlayOnce(targetRenderer, frames, fps)); } return(true); }
public SuperRufusBehaviour() { tileSheet = ".\\Sprites\\rufus1\\rufusSuperman\\rufusSuperman"; tileSheetXML = ".\\Sprites\\rufus1\\rufusSuperman\\rufusSupermanXML"; idleFrames = AnimationStruct.makeSequence(0, 2); idleFrames.AddLast(1); jumpFrames = AnimationStruct.makeSequence(3, 5); fallingFrames = AnimationStruct.makeSequence(9, 11); downFrames = AnimationStruct.makeSequence(7, 8); upFrames = AnimationStruct.makeSequence(5, 6); airdyingFrames = AnimationStruct.makeSequence(12, 13); dieFrames = AnimationStruct.makeSequence(14, 16); gravity = AbstractBehaviour.DEFAULT_GRAVITY * 0.5f; force = AbstractBehaviour.DEFAULT_SPEED * 1.01f; centerPosition = new Vector2(25, 25); spriteSheetPosition = new Vector2(-25, -20); range = 40; bounce = 0.5f; }
public FatBehaviour() { tileSheet = ".\\Sprites\\rufus1\\fatRufus\\fatRufus"; tileSheetXML = ".\\Sprites\\rufus1\\fatRufus\\fatRufusXML"; idleFrames = AnimationStruct.makeSequence(0, 3); jumpFrames = AnimationStruct.makeSequence(4, 6); fallingFrames = AnimationStruct.makeSequence(8, 10); downFrames = AnimationStruct.makeSequence(7, 7); upFrames = AnimationStruct.makeSequence(6, 6); airdyingFrames = AnimationStruct.makeSequence(11, 11); dieFrames = AnimationStruct.makeSequence(12, 14); dieFrames.AddLast(14); dieFrames.AddLast(14); dieFrames.AddLast(14); gravity = AbstractBehaviour.DEFAULT_GRAVITY; force = AbstractBehaviour.DEFAULT_SPEED * 0.9f; spriteSheetPosition = new Vector2(); centerPosition = new Vector2(30, 30); range = 30; bounce = 0.8f; }
public override void init(ContentManager Content) { content = Content; texture = Content.Load <Texture2D>(".\\Sprites\\enemies\\goomba\\goomba"); spriteSheetPositions = Content.Load <Dictionary <string, Rectangle> >(".\\Sprites\\enemies\\goomba\\goombaXML"); spriteSheet = new SpriteSheet(texture, spriteSheetPositions); spriteSheet.addAnimation(new AnimationStruct("IDLE1", AnimationStruct.makeSequence(0, 3), 20, null)); spriteSheet.play("IDLE1"); centerPosition = new Vector2(spriteSheet[spriteSheet.currentAnimation.frames.ElementAt(0)].Width / 2, spriteSheet[spriteSheet.currentAnimation.frames.ElementAt(0)].Height / 2); idRandom = new Random().Next(); gravity = 0f; range = 30; velocity.Y = 1; limitBaseY = 310; isInitialized = true; deadly = true; }
public void redraw(int type) { if (type == 1) { texture = content.Load <Texture2D>(".\\Sprites\\effects\\screenFX\\screeneffect"); spriteSheetPositions = content.Load <Dictionary <string, Rectangle> >(".\\Sprites\\effects\\screenFX\\screeneffectXML"); } else if (type == 2) { texture = content.Load <Texture2D>(".\\Sprites\\effects\\screenFX\\screeneffectPlus"); spriteSheetPositions = content.Load <Dictionary <string, Rectangle> >(".\\Sprites\\effects\\screenFX\\screeneffectPlusXML"); } else if (type == 3) { texture = content.Load <Texture2D>(".\\Sprites\\effects\\screenFX\\screeneffectMag"); spriteSheetPositions = content.Load <Dictionary <string, Rectangle> >(".\\Sprites\\effects\\screenFX\\screeneffectMagXML"); } spriteSheet = new SpriteSheet(texture, spriteSheetPositions); spriteSheet.addAnimation(new AnimationStruct("IDLE1", AnimationStruct.makeSequence(0, 1), 2, null)); spriteSheet.play("IDLE1"); position = new Vector2(); }
public bool PlayClip(SpriteRenderer targetRenderer, string path, bool looping = false, int fps = 10) { // DON'T PLAY THE SAME ANIMATION ON TOP OF ITSELF, STOP THE PREVIOUS ANIMATION if (!_animations.ContainsKey(targetRenderer)) _animations.Add(targetRenderer, null); else if (_animations[targetRenderer]._path == path) return true; else StopCoroutine(_animations[targetRenderer]._coroutine); AnimationStruct animation = new AnimationStruct(); animation._target = targetRenderer; animation._path = path; _animations[targetRenderer] = animation; // LOAD THE SPRITESHEET AND AVERT USER IF THE IMPORT FAILED Sprite[] frames = Resources.LoadAll<Sprite>(path); if (frames.Length == 0) { //Debug.Log("Resources/" + spriteSheetPath + " not found."); return false; } // LAUNCH LOOPING ANIMATION OR SINGLE ANIMATION COROUTINE if (looping) { animation._length = Mathf.Infinity; animation._coroutine = StartCoroutine(PlayForever(targetRenderer, frames, fps)); } else { animation._length = frames.Length * (1f / fps); animation._coroutine = StartCoroutine(PlayOnce(targetRenderer, frames, fps)); } return true; }
/** * Adiciona animações na lista de animações */ public void addAnimation(AnimationStruct _animation) { animations.AddFirst(_animation); }