public ExplosionParticle(Vector2 position, Vector2 direction, int lifetime, AnimatedTexture at) :base(position, direction, 0f, lifetime, 1f, at) { int scatter = 60; this.position.X += rand.Next(-scatter, scatter); this.position.Y += rand.Next(-scatter, scatter); }
protected override void LoadContent() { this.largeDust = this.CMProvider.Global.Load <AnimatedTexture>("Background Planes/dust_large"); this.smallDust = this.CMProvider.Global.Load <AnimatedTexture>("Background Planes/dust_small"); this.vaseBreakSound = this.CMProvider.Global.Load <SoundEffect>("Sounds/MiscActors/VaseBreak"); this.thudSound = this.CMProvider.Global.Load <SoundEffect>("Sounds/MiscActors/HitFloor"); }
public static void Draw(AnimBool expanded, ColorName colorName, CaretType caretType, float size) { switch (caretType) { case CaretType.Caret: AnimatedTexture.Draw(expanded, Carets, size, colorName); break; case CaretType.Move: AnimatedTexture.Draw(expanded, MoveCarets, size, colorName); break; case CaretType.Rotate: AnimatedTexture.Draw(expanded, RotateCarets, size, colorName); break; case CaretType.Scale: AnimatedTexture.Draw(expanded, ScaleCarets, size, colorName); break; case CaretType.Fade: AnimatedTexture.Draw(expanded, FadeCarets, size, colorName); break; } }
public async Task Play(AnimatedTexture texture, Color color, float minDuration = 0f) { SceneTreeTimer timer = null; if (minDuration > 0) { timer = GetTree().CreateTimer(minDuration); } Texture = texture; ((AnimatedTexture)Texture).CurrentFrame = 0; Modulate = color; Visible = true; playing = true; await ToSignal(GetTree().CreateTimer(texture.Frames / texture.Fps), "timeout"); playing = false; Visible = false; if (minDuration > 0 && timer?.TimeLeft > 0) { GD.Print("Timer Time Left: ", timer.TimeLeft); await ToSignal(timer, "timeout"); } }
public People(Vector2 position, Vector2 movement, AnimatedTexture at, int type, float speed) { this.position = position; this.movement = movement; this.texture = at; /* * int rnd = rand.Next(0, 100); this.position.Y -= rnd; float rndf = ((float)rnd) / 50; this.scale -= 0.01f * rnd; this.texture.Depth = (0.8f + (float)lane / 100); this.type = type; this.speed = speed; float tmp = ((float)lane) / 5; this.speed -= tmp; this.movement = Vector2.Multiply(this.movement, this.speed); */ int rnd = rand.Next(0, 100); //float rndf = ((float)rnd) / 100; this.position.Y -= rnd; this.scale -= 0.004f * rnd; this.texture.Depth = (0.8f + rnd*0.001f); this.type = type; this.speed = speed; this.speed -= rnd * 0.005f; this.movement = Vector2.Multiply(this.movement, this.speed); }
private void PlaceObstacleRandomly(int row, int type) { var instance = GameObject.CreatePrimitive((type == 0) ? PrimitiveType.Sphere : PrimitiveType.Cube); instance.transform.parent = transform; instance.transform.eulerAngles = transform.eulerAngles; instance.transform.localPosition = new Vector3(Random.Range(-14f, 14f) + newestRowShift * 5, 2, row * 10 + Random.Range(-4f, 4f)); var scale = Random.Range(2f, 5f); if (type < 2) { instance.transform.localScale = new Vector3(scale, scale, scale); } else { instance.transform.localScale = new Vector3(Random.Range(0.5f, 3f), Random.Range(0.5f, 3f), Random.Range(0.5f, 3f)); } instance.transform.Rotate(Vector3.up * Random.Range(0f, 360f)); //instance.SetColor(Random.ColorHSV(0, 1, 0, 0.1f, 0.9f, 1, 1, 1)); var anim = AnimatedTexture.AddToGameObject(instance, obstacleTexture); anim.StartAnimation(Random.Range(0f, 2f)); var rb = instance.AddComponent <Rigidbody>(); rb.mass = scale * 3; }
// Overloaded constructor allows a custom number of lives and bullets. public PlayerCharacter(Texture2D flyingSprite, Texture2D deadSprite, Texture2D loadedBullet, Texture2D foodGauge, Texture2D foodBar, Rectangle sentViewportRect, int numLives, int numBullets) { // See annotations for default constructor. This is practically the same. flySprite = new AnimatedTexture(flyingSprite, 25, 30, Vector2.Zero, 0.0f, 1.0f, .9f); deathSprite = new AnimatedTexture(deadSprite, 35, 20, Vector2.Zero, 0.0f, 1.0f, .9f, 7); width = flyingSprite.Width / 25; height = flyingSprite.Height; alive = true; viewportRect = sentViewportRect; position = new Vector2(viewportRect.Width / 2, viewportRect.Height * .9f); rotation = 0.0f; center = new Vector2(width / 2, height / 2); lives = numLives; maxBullets = numBullets; fireballs = new Bullet[maxBullets]; // Initialize fireball objects, which are bullet objects. for (int i = 0; i < maxBullets; i++) { fireballs[i] = new Bullet(loadedBullet, .5f); } prevKeyboardState = Keyboard.GetState(); // Initialize keyboard state to something. Doesn't matter what. this.foodGauge = foodGauge; this.foodBar = foodBar; }
public EnemyList(ContentManager content) { enemies = new Enemy[NUMBER_OF_ENEMIES]; AnimatedTexture rockAlive = new AnimatedTexture(content.Load <Texture2D>("Enemies\\rock_alive"), 1, 1, Vector2.Zero, 0.0f, 1.0f, 0.2f); AnimatedTexture rockDead = new AnimatedTexture(content.Load <Texture2D>("Enemies\\rock_anim1"), 35, 30, Vector2.Zero, 0.0f, 1.0f, 0.2f); Texture2D rockBullet = content.Load <Texture2D>("Bullets\\rock_bullet"); ERock rock = new ERock(rockAlive, rockDead, rockBullet, 5, 10, .3f, Vector2.Zero, Vector2.Zero, 0, 0, false, false); AnimatedTexture lionAlive = new AnimatedTexture(content.Load <Texture2D>("Enemies\\lion_alive"), 1, 1, Vector2.Zero, 0.0f, .75f, 0.2f); AnimatedTexture lionDead = new AnimatedTexture(content.Load <Texture2D>("Enemies\\lion_death"), 35, 30, Vector2.Zero, 0.0f, .75f, 0.2f, 7); Texture2D lionBullet = content.Load <Texture2D>("Bullets\\lion_bullet"); ELion lion = new ELion(lionAlive, lionDead, lionBullet, 10, 20, .2f, Vector2.Zero, Vector2.Zero, 0, 0, false, false); AnimatedTexture bflyAlive = new AnimatedTexture(content.Load <Texture2D>("Enemies\\butterflyfly"), 10, 30, Vector2.Zero, 0.0f, 1.5f, 0.2f, 5); AnimatedTexture bflyDead = new AnimatedTexture(content.Load <Texture2D>("Enemies\\butterflydeath"), 35, 20, Vector2.Zero, 0.0f, 1.5f, 0.2f, 7); Texture2D bflyBullet = content.Load <Texture2D>("Bullets\\bfly_bullet"); EBfly bfly = new EBfly(bflyAlive, bflyDead, bflyBullet, 20, 20, .9f, Vector2.Zero, Vector2.Zero, 0, 0, false, false); AnimatedTexture mBossAlive = new AnimatedTexture(content.Load <Texture2D>("Enemies\\minibossfly"), 25, 30, Vector2.Zero, 0.0f, 1.0f, 0.75f, 5); AnimatedTexture mBossDead = new AnimatedTexture(content.Load <Texture2D>("Enemies\\minibossdeath"), 40, 30, Vector2.Zero, 0.0f, 1.0f, 0.75f, 8); Texture2D mBossBullet = content.Load <Texture2D>("Bullets\\fireball0001"); EMiniboss miniboss1 = new EMiniboss(mBossAlive, mBossDead, mBossBullet, 100, 500, .6f, Vector2.Zero, Vector2.Zero, 0, 0, false, false); AnimatedTexture batAlive = new AnimatedTexture(content.Load <Texture2D>("Enemies\\batfly"), 10, 30, Vector2.Zero, 0.0f, 1.0f, 0.2f, 5); AnimatedTexture batDead = new AnimatedTexture(content.Load <Texture2D>("Enemies\\batdeath"), 35, 30, Vector2.Zero, 0.0f, 1.0f, 0.2f, 7); Texture2D batBullet = content.Load <Texture2D>("Bullets\\bat_bullet"); EBat bat = new EBat(batAlive, batDead, batBullet, 15, 100, .6f, Vector2.Zero, Vector2.Zero, 0, 0, false, false); AnimatedTexture eyeAlive = new AnimatedTexture(content.Load <Texture2D>("Enemies\\iSpikefly"), 75, 30, Vector2.Zero, 0.0f, 1.0f, 0.2f, 15); AnimatedTexture eyeDead = new AnimatedTexture(content.Load <Texture2D>("Enemies\\ispikedeath"), 35, 30, Vector2.Zero, 0.0f, 1.0f, 0.2f, 7); Texture2D eyeBullet = content.Load <Texture2D>("Bullets\\eye_bullet"); EEye eye = new EEye(eyeAlive, eyeDead, eyeBullet, 20, 15, 1.0f, Vector2.Zero, Vector2.Zero, 0, 0, false, false); AnimatedTexture boss1Alive = new AnimatedTexture(content.Load <Texture2D>("Enemies\\boss1fly"), 50, 30, Vector2.Zero, 0.0f, 1.0f, 0.2f, 10); AnimatedTexture boss1Dead = new AnimatedTexture(content.Load <Texture2D>("Enemies\\boss1death"), 55, 30, Vector2.Zero, 0.0f, 1.0f, 0.2f, 11); Texture2D bossBullet = content.Load <Texture2D>("Bullets\\fireball0001"); EBossS1 stage1Boss = new EBossS1(boss1Alive, boss1Dead, bossBullet, 100, 2000, 1.0f, Vector2.Zero, Vector2.Zero, 0, 0, false, false); enemies[0] = rock; enemies[1] = lion; enemies[2] = bfly; enemies[3] = eye; enemies[4] = miniboss1; enemies[5] = bat; enemies[6] = stage1Boss; }
public static AnimatedTexture Create(SpriteType type,int gridColumn, int gridRow) { var sprite = new AnimatedTexture(); sprite.LoadContent(s_assetHandler,type); sprite.SetPosition(gridColumn, gridRow); return sprite; }
public Enemy(AnimatedTexture spriteA, AnimatedTexture spriteD, Texture2D loadedBullet, int numBullets, float scale, Vector2 initialPosition, int mpattern, int fpattern, bool foodDrop, bool left) { // Assign essential textures. spriteAlive = spriteA; spriteDead = spriteD; width = (int)((spriteA.myTexture.Width / (spriteA.framecount / spriteA.rows)) * spriteA.Scale); height = (int)((spriteA.myTexture.Height / spriteA.rows) * spriteA.Scale); rotation = 0.0f; // No initial rotation. animating = true; alive = true; // Enemies start alive when they are added to the enemy list. maxBullets = numBullets; position = initialPosition; center = new Vector2(width / 2, height / 2); // Center value assigned. movePattern = mpattern; firePattern = fpattern; dropsFood = foodDrop; // time = new fireTimer(); enemyTime = new Timer(); isLeft = left; // Save textures for copying enemies. aliveTex = spriteA.myTexture; deadTex = spriteD.myTexture; bulletText = loadedBullet; // Initializae new array of bullets. bullets = new Bullet[maxBullets]; for (int i = 0; i < maxBullets; i++) { bullets[i] = new Bullet(loadedBullet, scale); } rand = new Random(); }
public Mobile(MobileInfo info, Vector2 pos, float rot) : base(info, pos, rot) { Type = EntityType.MOBILE; Hull = info.Hull; MaxHull = Hull; Mass = info.Mass; if (Mass != 0) { MassInv = 1 / Mass; } else { MassInv = 0; } CanCollide = info.CanCollide; CollideWithOwnSide = info.CollideWithOwnSide; IsDestroyed = false; DampenInnertia = info.DampenInnertia; RotationWanted = 0; MaxSpeed = info.MaxSpeed; ThrustAcceleration = info.ThrustAcceleration; VelocityWanted = new Vector2(0, 0); BoundingBox = new Rectangle(Model.Bounds.X, Model.Bounds.Y, Model.Bounds.Width, Model.Bounds.Height); AIRoutine = new EntityAI(this); DestructionAnimation = info.DestructionAnimation; }
public Explosion(ExplosionInfo info, Vector2 pos, float rot) : base(info, pos, rot) { AnimTexture = info.AnimTexture; Origin = new Vector2(AnimTexture.FrameWidth, AnimTexture.FrameHeight); timeAlive = 0; }
public Emitter(Vector2 position, int lifetime, AnimatedTexture texture, ParticleSystem particleSystem) { this.position = position; this.lifeTime = lifetime; this.texture = texture; this.particleSystem = particleSystem; }
protected void LoadTextures() { mapTexture = Content.Load <Texture2D>("Textures/Maps/Map1"); plainsTexture = Content.Load <Texture2D>("Textures/TilePalettes/FIEG_PlainsTiles"); forestTexture = Content.Load <Texture2D>("Textures/TilePalettes/FIEG_ForestTiles"); mountainsTexture = Content.Load <Texture2D>("Textures/TilePalettes/FIEG_MountainTiles"); waterTextureAnimated = new AnimatedTexture(new SpriteSheet(Content.Load <Texture2D>("Textures/TilePalettes/FIEG_WaterTiles"), new Point(2, 2), new Point(64)), 500); cursorTexture = Content.Load <Texture2D>("Textures/Cursor"); cursorTextureAnimated = new AnimatedTexture(new SpriteSheet(cursorTexture, new Point(1, 2), new Point(64)), 500, includeInList: false); hudTexture = Content.Load <Texture2D>("Textures/FEIG HUD 2"); portraitTexture = Content.Load <Texture2D>("Textures/Portraits/Portraits"); unitMapTexture = Content.Load <Texture2D>("Textures/Units/Units"); iconTexture = Content.Load <Texture2D>("Textures/Icons"); actionBarTexture = Content.Load <Texture2D>("Textures/ActionBar"); titleScreen = Content.Load <Texture2D>("Textures/FEIG_Logo"); moveArrowTexture = Content.Load <Texture2D>("Textures/MoveArrow"); pauseMenuTexture = Content.Load <Texture2D>("Textures/FEIG Menu"); moveTileTexture = Content.Load <Texture2D>("Textures/MoveTiles"); moveTileAnimated = new AnimatedTexture(new SpriteSheet(moveTileTexture, new Point(3, 16), new Point(64)), new Point(0, 0), AnimatedTexture.LoopType.Horizontal, 100); attackTileAnimated = new AnimatedTexture(new SpriteSheet(moveTileTexture, new Point(3, 16), new Point(64)), new Point(0, 1), AnimatedTexture.LoopType.Horizontal, 100); }
} // RocketCommanderXnaGame() /// <summary> /// Initialize textures and models for the game. /// </summary> protected override void Initialize() { base.Initialize(); // Load all available levels levels = Level.LoadAllLevels(); // Initialize asteroidManager and use last avialable level. asteroidManager = new GameAsteroidManager(levels[levels.Length - 1]); rocketModel = new Model("Rocket"); // Load menu textures mainMenuTexture = new Texture("MainMenu.png"); helperTexture = new Texture("ExtraButtons.png"); helpScreenTexture = new Texture("HelpScreen.png"); mouseCursorTexture = new Texture("MouseCursor.dds"); hudTexture = new Texture("Hud.png"); inGameTexture = new Texture("InGame.png"); lightEffectTexture = new Texture("LightEffect.dds"); explosionTexture = new AnimatedTexture("Explosion"); // Create main menu screen gameScreens.Push(new MainMenu()); //tst: //gameScreens.Push(new Mission(levels[0], asteroidManager)); //inGame = gameScreens.Peek().GetType() == typeof(Mission); //camera.InGame = inGame; } // Initialize()
private void ForkLoad(bool dummy) { this.OpenSplash = this.CMProvider.CurrentLevel.Load <AnimatedTexture>("Background Planes/water_giant_splash_open"); this.OpenWaterfall = this.CMProvider.CurrentLevel.Load <AnimatedTexture>("Background Planes/water_giant_open"); this.OpeningSplash = this.CMProvider.CurrentLevel.Load <AnimatedTexture>("Background Planes/water_giant_splash_opening"); this.OpeningWaterfall = this.CMProvider.CurrentLevel.Load <AnimatedTexture>("Background Planes/water_giant_opening"); this.sWaterfallOpening = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/MiscActors/BigWaterfallOpening"); }
public WallGrab(Player player) : base(player) { player.Velocity = new Vec2(0, player.Velocity.Y); if (tex == null) { tex = new AnimatedTexture(new Texture("./Data/img/player/wallgrab/wallgrab.png")); } }
public override AnimatedTexture GetTexture() { if (tex == null) { tex = new AnimatedTexture(new Texture("./Data/img/player/idle/player1.png")); } return(tex); }
private void LoadAnimationController(XMLAsset<AnimationController> f) { if (f?.Content == null) return; AnimController = f.Content; _spriteSheetTexture = AnimController.AnimTex.TextureAsset; Animation = AnimController.AnimTex; _saveName = f.Name; AnimController.SetAnimation(AnimController.Animations.First().Key); }
public Jump(Player player) : base(player) { CanJump = true; tex = new AnimatedTexture(); tex.Loopable = false; tex.Add(new Texture("./Data/img/player/jump/jump1.png"), 0.5); tex.Add(new Texture("./Data/img/player/jump/jump2.png"), 0.05); }
public Particle(Vector2 position, Vector2 direction, float mass, int lifetime, float scale, AnimatedTexture at) { this.position = position; this.direction = direction; this.lifetime = lifetime; this.texture = at; this.scale = scale; this.mass = mass; }
public SmokeLineParticle(Vector2 position, Vector2 direction, int lifetime, float scale, AnimatedTexture at, ParticleSystem ps) { this.position = position; this.direction = direction; this.lifetime = lifetime; this.texture = at; this.ps = ps; this.scale = scale; }
public Food(Texture2D foodImage, Vector2 position, Vector2 velocity, float value) // Construct new food with velocity. { this.foodImage = new AnimatedTexture(foodImage, 2, 2, Vector2.Zero, 0.0f, 1.0f, .8f); this.position = position; this.velocity = velocity; inPlay = true; gaugeValue = value; }
private void LoadSpriteSheetFile(TextureAsset f) { if (f?.Texture == null) return; _spriteSheetTexture?.Dispose(); _spriteSheetTexture = f; Animation = null; AnimController = null; _saveName = ""; }
private void LoadAnimatedTexture(XMLAsset<AnimatedTexture> f) { if (f?.Content == null) return; AnimatedTexture anim = f.Content; _spriteSheetTexture = anim.TextureAsset; Animation = anim; AnimController = null; _saveName = f.Name; }
public AnimationComponent(AnimatedTexture animatedTexture) { _animatedTexture = animatedTexture; _previousState = AnimationState.None; _currentAnimationSet = _animatedTexture.AnimationSets[AnimationState.IdleRight]; _frameSelector.Width = _animatedTexture.FrameWidth; _frameSelector.Height = _animatedTexture.FrameHeight; _frameTicksLeft = 0; }
public virtual void Update(double dt) { player.Velocity -= Vec2.Clamp(new Vec2(player.Velocity.X - player.Controller.NeedVel().X *player.Speed *player.SpeedUp, 0), player.Acc * player.SpeedUp * dt); AnimatedTexture tex = GetTexture(); if (tex != null) { tex.Update(dt); } }
public Dead(Player player) : base(player) { this.player = player; tex = new AnimatedTexture(); for (int i = 1; i <= 7; i++) { tex.Add(new Texture("./Data/img/player/death/death" + i + ".png"), 0.04); } tex.Loopable = false; }
public Projectile(Spell spell, GameHandler game, Entity target, Entity owner) { this.spell = spell; this.game = game; this.target = target; this.owner = owner; arcCount = spell.arcCount; size = new Vector2(4.0f, 4.0f); //To load projTexture = new AnimatedTexture(Main.content.Load <Texture2D>("flyingProj"), 3, 0.5f, 4, 4); //To load/implement }
public override void LoadContent() { this.animatedSprite = new AnimatedTexture(0, 1, 0); this.animatedSprite.Load(this.game.Assets, LeftStickKey, 4, 6); this.timeScore = 300; Debug.WriteLine("burnable: {0}", this.burnScore); base.LoadContent(); }
public SmokeParticle(Vector2 position, Vector2 direction, float mass, int lifetime, float scale, AnimatedTexture at) :base(position, direction, mass, lifetime, scale, at) { float s = rand.Next(-10, 10); s /= 500; this.scale += s; int scatter = 10; this.position.X += (rand.Next(-scatter, scatter)); this.position.Y += (rand.Next(-scatter, scatter)); }
public override Rectangle GetFrameUV(int i) { if (FrameSize == Vector2.Zero) { return(Rectangle.Empty); } // Legacy class can static method that can compute this for us. // In the future this function should be moved here. return(AnimatedTexture.GetGridFrameBounds(TextureSize, FrameSize, Spacing, i)); }
public Game1() { graphics = new GraphicsDeviceManager(this); graphics.IsFullScreen = false; graphics.PreferredBackBufferHeight = height; graphics.PreferredBackBufferWidth = width; Content.RootDirectory = "Content"; redCheckAnimated = new AnimatedTexture(Vector2.Zero, Rotation, Scale, Depth); this.IsMouseVisible = true; }
public override void _Ready() { base._Ready(); timer = GetNode <Timer>("../Timer"); tex = (AnimatedTexture)Texture; tex.Frame0__delaySec = minTime; tex.Pause = false; Spawner.Fade(GetParent().GetParent(), Fade.Out, null); GetNode <ColorRect>("../../../ColorRect").QueueFree(); }
private void LoadAnimationController(XMLAsset <AnimationController> f) { if (f?.Content == null) { return; } _animController = f.Content; _spriteSheetTexture = _animController.AnimTex.TextureAsset; _animation = _animController.AnimTex; _saveName = f.Name; }
public Particle(Vector2 _Pos, double _LifeSpan, Vector2 _Velocity, float _InitialSpeed, AnimatedTexture _Texture, float _Friction = 0, float _Scale = 1, float _Rotation = 0) : base(_Pos, _Scale, _Rotation) { mVelocity = _Velocity; mLifeSpanInitial = _LifeSpan; mLifeSpanRemaining = mLifeSpanInitial; mMovementSpeed = _InitialSpeed; mPosition = _Pos; mFriction = _Friction; mTexture = _Texture; mTexture.SetNewOwner(this); }
public DoubleJump(Player player) : base(player) { CanJump = false; tex = new AnimatedTexture(); tex.Loopable = false; for (int i = 1; i <= 8; i++) { tex.Add(new Texture("./Data/img/player/doublejump/doublejump" + i.ToString() + ".png"), 0.05); } }
public Floor(Vector2 position, AnimatedTexture at, bool mirrored) { this.position = position; this.isMirrored = mirrored; //get building parts this.textures = GraphicsUtil.getBuildingFronts(); this.midTexture = GraphicsUtil.getBuildingMid(); this.backTexture = GraphicsUtil.getBuildingBack(0); Console.WriteLine("Floor build parts: " + textures.Count); }
public Engine() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; animatedTexture = new AnimatedTexture(4, 10); // Set device frame rate to 60 fps. TargetElapsedTime = TimeSpan.FromSeconds(1 / 60.0); Window.AllowUserResizing = true; //allow resize. Window.ClientSizeChanged += new EventHandler<EventArgs>(Window_ClientSizeChanged); }
public ExplosionEmitter(Vector2 position, int area, int lifeTime, float perFrame, float xdirection, AnimatedTexture texture ,ParticleSystem ps) { this.position = position; this.area = area; this.lifeTime = lifeTime; this.perFrame = perFrame; this.ps = ps; this.texture = texture; this.xDirection = xdirection; init(); }
public Guy(World world, float x, float y, Texture2D texture) : base() { CreateBody(world, x, y); onGround = false; canWaterJump = false; inWater = false; facingLeft = false; startJump = holdJump = false; texIdle = new AnimatedTexture(texture, 24, 0, 0, 120, 140); texRun = new AnimatedTexture(texture, 19, 0, 144, 120, 140); texJump = new AnimatedTexture(texture, 9, 19 * 120, 144, 120, 140, 1, false, false); texRoll = new AnimatedTexture(texture, 1, 4 * 120, 288, 120, 140); texWaterIdle = new AnimatedTexture(texture, 14, 5 * 120, 288, 120, 140, 2, true, false); texSwim = new AnimatedTexture(texture, 17, 19 * 120, 288, 120, 144); currentTexture = texIdle; }
public static void update() { //Respawn the player in the center of the screen and give 5 sec. of invulnerability if (status == PlayerStatus.Dead) { respawnDelay -= (float)dt; if (respawnDelay <= 2) { for (int i = 0; i < eBullets.Count; i++) { explosions.Add(new Explosion("bulletexplode", eBullets[i].pos, 5.0f, 0.0f, 0.2f, eBullets[i].color)); eBullets.RemoveAt(i); i--; } } if (respawnDelay <= 0) { respawnDelay = 5.0f; pos = gameDim / 2; status = PlayerStatus.Spawning; } } else { //Player is alive after invulnerability period runs out if (status == PlayerStatus.Spawning) { if (respawnDelay >= 2) for (int i = 0; i < eBullets.Count; i++) { explosions.Add(new Explosion("bulletexplode", eBullets[i].pos, 5.0f, 0.0f, 0.2f, eBullets[i].color)); eBullets.RemoveAt(i); i--; } respawnDelay -= (float)dt; if (respawnDelay <= 0) { respawnDelay = 3.0f; status = PlayerStatus.Alive; } } //Move the player pos += dir * (float)dt; //Keep the player on screen pos.X = MathHelper.Clamp(pos.X, 0, gameDim.X); pos.Y = MathHelper.Clamp(pos.Y, 0, gameDim.Y); //Determine animations based on movement and current animation if (img == reimuTextures[0]) img = reimuTextures[1]; if (img == reimuTextures[1] && img.willFinish(dt)) img = reimuTextures[2]; if (dir.X < 0 && playerEffect == SpriteEffects.FlipHorizontally) { img = reimuTextures[1]; playerEffect = SpriteEffects.None; } if (dir.X > 0 && playerEffect == SpriteEffects.None) { img = reimuTextures[1]; playerEffect = SpriteEffects.FlipHorizontally; } if (dir.X == 0) img = reimuTextures[0]; //Spin focus glyph fAngle += 0.02f; //Auto-collect items at full power if (pos.Y < 150 && power == 128) for (int i = 0; i < items.Count; i++) items[i].autoCollect = true; } }
public TrailProjectile(Character _character, Vector2 _start, Vector2 _end, float _damage, float _speed, AnimatedTexture _endTexture) : base(_character, _start, _end, _damage, _speed) { endTexture = _endTexture; centered = false; }
public Sprite(AnimatedTexture t, Vector2 p, float a, float s, Color c, drawType ty) { imgA = t; pos = p; angle = a - 90.0f; speed = s; type = ty; radians = MathHelper.ToRadians(angle); dir = new Vector2((float)Math.Cos(radians), (float)Math.Sin(radians)); dim = t.dim; color = c; }
public FireEmitter(Vector2 position, int lifetime, AnimatedTexture texture, ParticleSystem particleSystem, float xDirection) :base(position, lifetime, texture, particleSystem) { this.xDirection = xDirection; }
protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); graphicsDevice = GraphicsDevice; //Load all textures for (int i = 0; i < texFiles.Length; i++) textures.Add(texFiles[i], Content.Load<Texture2D>(texFiles[i])); //Load bullet textures into dictionary for (int i = 0; i < bulletTexFiles.Length; i++) { bulletTextures.Add(bulletTexFiles[i], new Dictionary<Color, Texture2D>()); bulletTextures[bulletTexFiles[i]].Add(Color.Gray, Content.Load<Texture2D>(bulletTexFiles[i])); } //Load all sounds for (int i = 0; i < soundFiles.Length; i++) sounds.Add(soundFiles[i], new SoundManager(Content.Load<SoundEffect>(soundFiles[i]))); //Load all music for (int i = 0; i < musicFiles.Length; i++) songs.Add(musicFiles[i], Content.Load<Song>(musicFiles[i])); //Load all conversations for (int i = 0; i < convFiles.Length; i++) conversations.Add(convFiles[i], System.IO.File.ReadAllLines("Content/conv1.txt")); //Load conversation colors convColors.Add("reimu", Color.Crimson); convColors.Add("marisa", Color.Gold); //Load fonts font = Content.Load<SpriteFont>("SpriteFont1"); fontfps = Content.Load<SpriteFont>("SpriteFont2"); fontconv = Content.Load<SpriteFont>("SpriteFont3"); //Create Reimu animations reimuTextures.Add(new AnimatedTexture(textures["reimufly"], 4, 0.2)); reimuTextures.Add(new AnimatedTexture(textures["reimumoveleft"], 3, 0.1)); reimuTextures.Add(new AnimatedTexture(textures["reimuleft"], 4, 0.2)); //Create blue enemy animations enemyTextures.Add(new AnimatedTexture(textures["enemy1fly"], 4, 0.2)); enemyTextures.Add(new AnimatedTexture(textures["enemy1moveright"], 3, 0.1)); enemyTextures.Add(new AnimatedTexture(textures["enemy1right"], 1, 1)); //Create red enemy animations enemyTextures.Add(new AnimatedTexture(textures["enemy2fly"], 4, 0.2)); enemyTextures.Add(new AnimatedTexture(textures["enemy2moveright"], 3, 0.1)); enemyTextures.Add(new AnimatedTexture(textures["enemy2right"], 1, 1)); //Load boss data bossTexture = new AnimatedTexture(textures["marisafly"], 4, 0.3); //Load scripts level = new Level("A New Dawn", "The pieces of Gensokyo are finally coming together. What picture will they reveal?", new Background[] { new Background(textures["sky"], new Vector2(0, 30), 1.0f) }, songs["Fall of Fall"], new Script[] { new Script( new Enemy(enemyTextures[0], Vector2.Zero, 0.0f, 50.0f, Color.Red, 3.0f, new Script(new Bullet(getColoredTexture("B1", Color.Red), Vector2.Zero, 0.0f, 100.0f, Color.Red, drawType.Normal), new Loop[] {new Loop(1000, 1.0, 0)}), new string[]{"itempower","itempoint"}), new Loop[] {new Loop(30, 0.5, -1)}) }); //enemyScript1 = new Script(new Bullet(getColoredTexture("B1", Color.Red), // Vector2.Zero, 0.0f, 100.0f, Color.Red, drawType.Normal), // new Loop[] {new Loop(1000, 1.0, 0)}); //enemyScript2 = new Script(new Bullet(getColoredTexture("B2", Color.Blue), // Vector2.Zero, 0.0f, 100.0f, Color.Blue, drawType.Directional), // new Loop[] {new Loop(10, 0.5, 1), new Loop(5, 0.0, 2)}); //enemyScript3 = new Script[]{ // new Script(new Bullet(getColoredTexture("B3", Color.Green), // Vector2.Zero, 0.0f, 200.0f, Color.Green, drawType.Normal), // new Loop[] {new Loop(20, 1.0, 3), new Loop(20, 0.0, 4)}), // new Script(new Bullet(getColoredTexture("B4", Color.Yellow), // Vector2.Zero, 0.0f, 100.0f, Color.Yellow, drawType.Directional), // new Loop[] {new Loop(500, 0.02, 5)}) // }; //bossScript1 = new Script(new Bullet(getColoredTexture("B2", Color.Purple), // Vector2.Zero, 0.0f, 100.0f, Color.Purple, drawType.Directional), // new Loop[] {new Loop(1000, 0.5, 6), new Loop(20, 0.0, 7)}); //bossScript2 = new Script[]{ // new Script(new Bullet(getColoredTexture("B2", Color.Yellow), // Vector2.Zero, 0.0f, 100.0f, Color.Yellow, drawType.Directional), // new Loop[] {new Loop(1000, 0.5, 8), new Loop(6, 0.0, 9)}), // new Script(new Bullet(getColoredTexture("B8", Color.Yellow), // Vector2.Zero, 240.0f, 10.0f, Color.Yellow, drawType.Spinning), // new Loop[] {new Loop(1000, 10.0, 10), new Loop(6, 0.5, 11), new Loop(15, 0.1, 12)}) // }; //Starting Reimu texture Player.img = reimuTextures[0]; //Starting background level.backgrounds = new Background[] {new Background(textures["sky"], new Vector2(0,30), 1.0f)}; //Set screen boundaries screenDim = new Vector2(GraphicsDevice.DisplayMode.Width, GraphicsDevice.DisplayMode.Height); foregroundDim = screenDim - gameDim; Player.pos = gameDim / 2; //Play BGM MediaPlayer.IsRepeating = true; MediaPlayer.Play(songs["Fall of Fall"]); }
public Sprite(AnimatedTexture t, Vector2 p, Vector2 d, Color c, drawType ty) { imgA = t; pos = p; dir = d; type = ty; angle = MathHelper.ToDegrees((float)Math.Atan2(dir.Y, dir.X)) + 90.0f; speed = (float)Math.Sqrt(d.X * d.X + d.Y * d.Y); dim = t.dim; color = c; }
private void UpdateTexture() { if (swimming && !Crouching) currentTexture = texSwim; currentTexture.Update(); if (swimming && currentTexture.Frame == texSwim.Length - 1) { texSwim.Frame = 0; swimming = false; } if (!onGround && !Crouching && !inWater) { if (currentTexture != texJump) currentTexture = texJump; int frame = (int)(torso.LinearVelocity.Y * MainGame.METER_TO_PIXEL) / 16 + 3; if (frame < 0) frame = 0; else if (frame > 8) frame = 8; texJump.Frame = frame; } }
//Constructor given vector direction public Enemy(AnimatedTexture t, Vector2 p, Vector2 d, Color c, float h, Script[] scr, string[] dr) : base(t, p, d, c, drawType.Animated) { health = h; scripts = scr; drops = dr; }
//Constructor given angular direction public Enemy(AnimatedTexture t, Vector2 p, float a, float s, Color c, float h, Script scr, string[] dr) : base(t, p, a, s, c, drawType.Animated) { health = h; scripts = new Script[1]; scripts[0] = scr; drops = dr; }
public FireSmokeParticle(Vector2 position, Vector2 direction, float mass, int lifetime, float scale, AnimatedTexture at, int firetime) : base(position, direction, mass, lifetime, scale, at) { this.firetime = firetime; }
public Floor(Vector2 position, AnimatedTexture at) { this.position = position; this.texture = at; }
public Bullet(AnimatedTexture t, Vector2 p, float a, float s, Color c, drawType ty) : base(t, p, a, s, c, ty) { }
//Constructor given vector direction public Bullet(AnimatedTexture t, Vector2 p, Vector2 d, Color c, drawType ty) : base(t, p, d, c, ty) { }
public void damage(int dmg) { this.healthDiff += dmg; this.health -= dmg; if (this.healthDiff > 10) { removePart(); this.healthDiff = 0; if (rand.Next(7) == 1) { Vector2 posTmp = this.position; posTmp.X += rand.Next(10, 70); posTmp.Y += rand.Next(10, 70); int x = -1; if(isMirrored) x *=-1; EffectUtil.createFire(posTmp, 300 + rand.Next(400), x); } } if (health < 60 && !isBackDamaged) { this.isBackDamaged = true; this.backTexture = GraphicsUtil.getBuildingBack(); //pos schieb //this.position.X -= rand.Next(1, 16); //this.midTexture.Origin.X -= rand.Next(1, 16); //this.backTexture.Origin.X -= rand.Next(1, 16); /*foreach(AnimatedTexture at in this.textures) { at.Origin.X -= rand.Next(1, 7); }*/ } }
//Constructor given vector direction public Boss(AnimatedTexture t, Vector2 p, Vector2 d, Color c, float h, Script[] scr, string[] dr) : base(t, p, d, c, h, scr, dr) { imgA = t; pos = p; dir = d; health = h; scripts = scr; angle = MathHelper.ToDegrees((float)Math.Atan2(dir.Y, dir.X)) + 90.0f; speed = (float)Math.Sqrt(d.X * d.X + d.Y * d.Y); dim = imgA.dim; color = c; }
private void UpdateMovement() { if (Crouching) currentTexture = texRoll; if (MovingLeft) { facingLeft = true; axis.MotorEnabled = true; axis.MaxMotorTorque = Crouching ? 0.3f : 10.0f; axis.MotorSpeed = -MOTOR_SPEED; if (!Crouching) { if (onGround) currentTexture = texRun; else if (inWater) swimming = true; } if (!onGround && torso.LinearVelocity.X > -MAX_AIRSPEED * (inWater ? 1.5f : 1f)) torso.ApplyForce(inWater ? left_waterForce : left_airForce); } else if (MovingRight) { facingLeft = false; axis.MotorEnabled = true; axis.MaxMotorTorque = Crouching ? 0.3f : 10.0f; axis.MotorSpeed = MOTOR_SPEED; if (!Crouching) { if (onGround) currentTexture = texRun; else if (inWater) swimming = true; } if (!onGround && torso.LinearVelocity.X < MAX_AIRSPEED * (inWater ? 1.5f : 1f)) torso.ApplyForce(inWater ? right_waterForce : right_airForce); } else { if (onGround) { if (Crouching) { axis.MotorEnabled = false; axis.MaxMotorTorque = 0.0f; } else { currentTexture = texIdle; axis.MotorEnabled = true; axis.MaxMotorTorque = 10.0f; axis.MotorSpeed = 0; } } else { if (inWater && !Crouching) { currentTexture = texWaterIdle; if (Math.Abs(torso.LinearVelocity.X) > 0) torso.ApplyForce(-Math.Sign(torso.LinearVelocity.X) * Vector2.UnitX * 3); } } } if (!onGround) axis.MotorEnabled = false; else axis.MotorEnabled = true; }
//Constructor given angular direction public Boss(AnimatedTexture t, Vector2 p, float a, float s, Color c, float h, Script[] scr, string[] dr) : base(t, p, a, s, c, h, scr, dr) { imgA = t; pos = p; angle = a - 90.0f; speed = s; health = h; scripts = scr; radians = MathHelper.ToRadians(angle); dir = new Vector2((float)Math.Cos(radians), (float)Math.Sin(radians)); dim = imgA.dim; color = c; }
//Constructor making a new instance as a copy. Use this to make several instances of //AnimatedTexture to animate seperately. public AnimatedTexture(AnimatedTexture a) { img = a.img; frames = a.frames; delay = a.delay; speed = a.speed; delay = speed; dim = a.dim; }
public ShockwaveEmitter(Vector2 position, int lifetime, AnimatedTexture texture, ParticleSystem particleSystem) :base(position, lifetime, texture, particleSystem) { this.left = position; this.right = position; }