public GameObject SpawnFire(float positionX, float positionY, int life) { int thisGameObjectType = (int)PyroGameObjectTypes.Fire; GameObject result = mGameObjectPool.Allocate(); result.SetPosition(positionX, positionY); result.ActivationRadius = mActivationRadius_AlwaysActive; result.width = 32; result.height = 32; result.life = life; result.team = GameObject.Team.NONE; FixedSizeArray <BaseObject> staticData = GetStaticData(thisGameObjectType); if (staticData == null) { ContentManager content = sSystemRegistry.Game.Content; int staticObjectCount = 10; staticData = new FixedSizeArray <BaseObject>(staticObjectCount); // Animation Data float animationDelay = 0.16f; const int fileImageSize = 64; Rectangle crop = new Rectangle(0, 0, fileImageSize, fileImageSize); SpriteAnimation fire100 = new SpriteAnimation((int)FireAnimation.Fire100, 2); fire100.Loop = true; fire100.AddFrame(new AnimationFrame(content.Load <Texture2D>(@"pics\fire1"), animationDelay, crop)); fire100.AddFrame(new AnimationFrame(content.Load <Texture2D>(@"pics\fire1"), animationDelay, crop, SpriteEffects.FlipHorizontally)); SpriteAnimation fire80 = new SpriteAnimation((int)FireAnimation.Fire80, 2); fire80.Loop = true; fire80.AddFrame(new AnimationFrame(content.Load <Texture2D>(@"pics\fire2"), animationDelay, crop)); fire80.AddFrame(new AnimationFrame(content.Load <Texture2D>(@"pics\fire2"), animationDelay, crop, SpriteEffects.FlipHorizontally)); SpriteAnimation fire60 = new SpriteAnimation((int)FireAnimation.Fire60, 2); fire60.Loop = true; fire60.AddFrame(new AnimationFrame(content.Load <Texture2D>(@"pics\fire3"), animationDelay, crop)); fire60.AddFrame(new AnimationFrame(content.Load <Texture2D>(@"pics\fire3"), animationDelay, crop, SpriteEffects.FlipHorizontally)); SpriteAnimation fire40 = new SpriteAnimation((int)FireAnimation.Fire40, 2); fire40.Loop = true; fire40.AddFrame(new AnimationFrame(content.Load <Texture2D>(@"pics\fire4"), animationDelay, crop)); fire40.AddFrame(new AnimationFrame(content.Load <Texture2D>(@"pics\fire4"), animationDelay, crop, SpriteEffects.FlipHorizontally)); SpriteAnimation fire20 = new SpriteAnimation((int)FireAnimation.Fire20, 2); fire20.Loop = true; fire20.AddFrame(new AnimationFrame(content.Load <Texture2D>(@"pics\fire5"), animationDelay, crop)); fire20.AddFrame(new AnimationFrame(content.Load <Texture2D>(@"pics\fire5"), animationDelay, crop, SpriteEffects.FlipHorizontally)); SpriteAnimation fire0 = new SpriteAnimation((int)FireAnimation.Fire0, 2); fire0.Loop = true; fire0.AddFrame(new AnimationFrame(content.Load <Texture2D>(@"pics\fire6"), animationDelay, crop)); fire0.AddFrame(new AnimationFrame(content.Load <Texture2D>(@"pics\fire6"), animationDelay, crop, SpriteEffects.FlipHorizontally)); //animations staticData.Add(fire100); staticData.Add(fire80); staticData.Add(fire60); staticData.Add(fire40); staticData.Add(fire20); staticData.Add(fire0); SetStaticData(thisGameObjectType, staticData); } RenderComponent render = (RenderComponent)AllocateComponent(typeof(RenderComponent)); render.Priority = PyroSortConstants.FIRE; render.CameraRelative = true; SpriteComponent sprite = (SpriteComponent)AllocateComponent(typeof(SpriteComponent)); sprite.SetSize((int)result.width, (int)result.height); sprite.SetRenderComponent(render); sprite.SetRenderMode(SpriteComponent.RenderMode.RotateToFacingDirection); LifetimeComponent lifetime = AllocateComponent <LifetimeComponent>(); result.Add(render); result.Add(lifetime); result.Add(sprite); AddStaticData(thisGameObjectType, result, sprite); sprite.PlayAnimation((int)FireAnimation.Fire100); return(result); }
public GameObject SpawnPlayerDead(float positionX, float positionY, Vector2 facingDir) { int thisGameObjectType = (int)PyroGameObjectTypes.PlayerDead; GameObject result = mGameObjectPool.Allocate(); result.SetPosition(positionX, positionY); result.ActivationRadius = mActivationRadius_AlwaysActive; result.width = 32; result.height = 32; result.facingDirection = facingDir; result.life = 1; result.team = GameObject.Team.NONE; FixedSizeArray <BaseObject> staticData = GetStaticData(thisGameObjectType); if (staticData == null) { ContentManager content = sSystemRegistry.Game.Content; int staticObjectCount = 1; staticData = new FixedSizeArray <BaseObject>(staticObjectCount); // Animation Data float animationDelay = 0.16f; Rectangle crop32 = new Rectangle(0, 0, 32, 32); //Idle SpriteAnimation idle = new SpriteAnimation((int)Animations.Idle, 2); idle.Loop = true; idle.AddFrame(new AnimationFrame(content.Load <Texture2D>(@"pics\player\001_Death"), animationDelay, crop32)); idle.AddFrame(new AnimationFrame(content.Load <Texture2D>(@"pics\player\001_Death"), animationDelay, crop32, SpriteEffects.FlipHorizontally)); //animations staticData.Add(idle); SetStaticData(thisGameObjectType, staticData); } RenderComponent render = (RenderComponent)AllocateComponent(typeof(RenderComponent)); render.Priority = PyroSortConstants.PLAYER; render.CameraRelative = true; SpriteComponent sprite = (SpriteComponent)AllocateComponent(typeof(SpriteComponent)); sprite.SetSize((int)result.width, (int)result.height); sprite.SetRenderComponent(render); sprite.SetRenderMode(SpriteComponent.RenderMode.RotateToFacingDirection); LifetimeComponent lifetime = AllocateComponent <LifetimeComponent>(); result.Add(render); result.Add(lifetime); result.Add(sprite); AddStaticData(thisGameObjectType, result, sprite); sprite.PlayAnimation((int)Animations.Idle); return(result); }