public override void LoadContent() { int currentFrame = r.Next(8); animationTimer = new AnimationTimer(intervals, m_AnimationName, HandleAnimation, true, currentFrame); Texture = TextureBank.GetTexture(textures[currentFrame]); base.LoadContent(); }
public void Trigger() { animationTimer = new AnimationTimer(intervals, m_AnimationName, HandleAnimation, false); canDraw = true; Texture = TextureBank.GetTexture(textures[0]); ObjectManager.GetCell(Position).Add(this); Origin = new Vector2(Texture.Width / 2, Texture.Height / 2); }
public bool CheckCollision(GameObject ob) { if (Bounds.Intersects(ob.Bounds) && m_State == BulletState.Flying) { PlasmaHitAnimationTimer = new AnimationTimer(hitIntervals, m_HitAnimation, HandlePlasmaHitAnimation, false); Texture = TextureBank.GetTexture(hitTextures[0]); //play the bullet explosion animation here, make sure to remove bounds, it should be fast enough that nothing clips m_State = BulletState.Contact; return(true); } return(false); }
public Shroom() : base() { LifeTotal = 40; m_BlinkingIntervals[0] = 2500; m_BlinkingIntervals[1] = 1000; m_BlinkingTextures[0] = "ShroomEyeClosed"; m_BlinkingTextures[1] = "ShroomEyeOpen"; m_BlinkingTimer = new AnimationTimer(m_BlinkingIntervals, BlinkAnimationName, HandleAnimation, true); circleRadius = 65; pufftime = 5; }
public override void Update(Player player, TimeSpan elapsedTime) { if (animationTimer != null) { animationTimer.Update(elapsedTime); if (animationTimer.Done) { animationTimer.IntervalOcccured -= HandleAnimation; animationTimer = null; canDraw = false; ObjectManager.GetCell(Position).Remove(this); } } }
public void Update(TimeSpan elapsedTime) { switch (m_State) { case BulletState.Flying: if (animationTimer != null) { animationTimer.Update(elapsedTime); if (animationTimer.Done) { animationTimer.IntervalOcccured -= HandleAnimation; animationTimer = null; CanDelete = true; return; } } float t = Vector2.DistanceSquared(Position, m_InitialPosition); if (t > 250000) { animationTimer.IntervalOcccured -= HandleAnimation; animationTimer = null; CanDelete = true; return; } Move((Velocity * m_Heading) + playerVelocity, elapsedTime); m_Bounds.X = (int)Position.X - Width / 2; m_Bounds.Y = (int)Position.Y - Height / 2; break; case BulletState.Contact: PlasmaHitAnimationTimer.Update(elapsedTime); if (PlasmaHitAnimationTimer.Done) { CanDelete = true; } break; } }
public void LoadContent(World world) { m_Direction = new Vector2(0, 0); m_Texture = TextureBank.GetTexture("WolfBody"); Width = m_Texture != null ? m_Texture.Width : 0; Height = m_Texture != null ? m_Texture.Height : 0; if (m_Texture != null) { m_Bounds.Width = Width; m_Bounds.Height = Height; m_Bounds.X = (int)Position.X - Width / 2; m_Bounds.Y = (int)Position.Y - Height / 2; m_Origin.X = Width / 2; m_Origin.Y = Height / 2; } _circleBody = BodyFactory.CreateCircle(world, ConvertUnits.ToSimUnits(35 / 2f), 1f, ConvertUnits.ToSimUnits(Position)); _circleBody.BodyType = BodyType.Dynamic; _circleBody.Mass = 5f; _circleBody.LinearDamping = 3f; _circleBody.Restitution = .5f; Lefthand = new WolfHand(WolfHand.LeftOrRightHand.Left, this); Righthand = new WolfHand(WolfHand.LeftOrRightHand.Right, this); Lefthand.LoadContent(); Righthand.LoadContent(); moveHandsIntervals = new float[5]; moveHandsIntervals[0] = 1000; moveHandsIntervals[1] = 1000; moveHandsIntervals[2] = 1000; moveHandsIntervals[3] = 1000; moveHandsIntervals[4] = 1000; MoveHandsTimer = new AnimationTimer(moveHandsIntervals, m_MoveHandsString, AnimationHandler, false); }