示例#1
0
        public Wall(ContentManager content, Vector2 position)
            : base(content)
        {
            Texture2D texture = null;

            texture = LoadingUtils.load <Texture2D>(content, "Fence");

            StaticDrawable2DParams wallParams = new StaticDrawable2DParams {
                Position = position,
                Texture  = texture,
                Scale    = new Vector2(.5f),
                Origin   = new Vector2(Constants.TILE_SIZE)
            };

            this.idleImage = new StaticDrawable2D(wallParams);

            Animated2DSpriteLoadSingleRowBasedOnTexture parms = new Animated2DSpriteLoadSingleRowBasedOnTexture();
            BaseAnimationManagerParams animationParms         = new BaseAnimationManagerParams();

            animationParms.AnimationState  = AnimationState.PlayForwardOnce;
            animationParms.FrameRate       = 100f;
            animationParms.TotalFrameCount = 3;
            parms.Position        = position;
            parms.Scale           = new Vector2(.25f);
            parms.Texture         = LoadingUtils.load <Texture2D>(content, "FenceOpening");
            parms.Origin          = new Vector2(Constants.TILE_SIZE);
            parms.AnimationParams = animationParms;
            this.spawnSprite      = new Animated2DSprite(parms);
            base.init(spawnSprite);

            BaseParticle2DEmitterParams emitterParams = new BaseParticle2DEmitterParams()
            {
                ParticleTexture = LoadingUtils.load <Texture2D>(content, "Dust"),
            };

            this.dustEmitter = new DustParticleEmitter(emitterParams, base.Position);
            for (int i = 0; i < 5; i++)
            {
                this.dustEmitter.createParticle();
            }

            this.crumpleSFX = LoadingUtils.load <SoundEffect>(content, SFX_NAME_CRUMPLE);
            SoundEmitterParams sfxEmitterParms = new SoundEmitterParams {
                SFXEngine   = SoundManager.getInstance().SFXEngine,
                EmittRadius = SFX_EMITT_RADIUS,
                Position    = this.spawnSprite.Position
            };

            this.sfxEmitter = new SoundEmitter(sfxEmitterParms);
            SoundManager.getInstance().addEmitter(this.sfxEmitter);
            SoundManager.getInstance().playSoundEffect(this.sfxEmitter, this.crumpleSFX);
            this.stage = Stage.Opening;
        }
示例#2
0
        public Food(ContentManager content, Random rand, int points, float speedMultiplier, List <string> dyingCharacterTextureNames, string deathParticleTextureName,
                    string idleTextureName, string spawnTextureName, string spawnSFXName, string idleSFXName, string dyingSFXName, float spawnPositionYOffset = 0f)
            : base(content)
        {
            this.Points          = points;
            this.SpeedMultiplier = speedMultiplier;
            this.LifeStage       = Stage.Spawn;

            this.dyingCharacterTextures = new List <Texture2D>();
            foreach (string texture in dyingCharacterTextureNames)
            {
                this.dyingCharacterTextures.Add(LoadingUtils.load <Texture2D>(content, texture));
            }
            this.deathParticleTexture = LoadingUtils.load <Texture2D>(content, deathParticleTextureName);

            Animated2DSpriteLoadSingleRowBasedOnTexture parms = new Animated2DSpriteLoadSingleRowBasedOnTexture();
            BaseAnimationManagerParams animationParms         = new BaseAnimationManagerParams();

            animationParms.AnimationState  = AnimationState.PlayForward;
            animationParms.FrameRate       = 100f;
            animationParms.TotalFrameCount = 4;
            parms.Position        = PositionGenerator.getInstance().generateSpawn();
            parms.Texture         = LoadingUtils.load <Texture2D>(content, idleTextureName);
            parms.Scale           = new Vector2(.5f);
            parms.Origin          = new Vector2(Constants.TILE_SIZE);
            parms.AnimationParams = animationParms;
            this.idleSprite       = new Animated2DSprite(parms);

            animationParms.AnimationState = AnimationState.PlayForwardOnce;
            parms.AnimationParams         = animationParms;
            parms.Texture    = LoadingUtils.load <Texture2D>(content, spawnTextureName);
            parms.Scale      = new Vector2(1f);
            parms.Position   = new Vector2(parms.Position.X, parms.Position.Y + spawnPositionYOffset);
            this.spawnSprite = new Animated2DSprite(parms);

            base.init(this.spawnSprite);

            this.spawnSFX = LoadingUtils.load <SoundEffect>(content, spawnSFXName);
            this.idleSFX  = LoadingUtils.load <SoundEffect>(content, idleSFXName);
            this.dyingSFX = LoadingUtils.load <SoundEffect>(content, dyingSFXName);

            SoundEmitterParams sfxEmitterParms = new SoundEmitterParams {
                SFXEngine   = SoundManager.getInstance().SFXEngine,
                EmittRadius = SFX_EMITT_RADIUS,
                Position    = this.spawnSprite.Position
            };

            this.sfxEmitter = new SoundEmitter(sfxEmitterParms);
            SoundManager.getInstance().addEmitter(this.sfxEmitter);
        }
示例#3
0
        public Portal(ContentManager content, Random rand) : base(content)
        {
            this.lifeStage = Stage.Spawn;

            Animated2DSpriteLoadSingleRowBasedOnTexture parms = new Animated2DSpriteLoadSingleRowBasedOnTexture();
            BaseAnimationManagerParams animationParms         = new BaseAnimationManagerParams();

            animationParms.AnimationState  = AnimationState.PlayForward;
            animationParms.FrameRate       = 100f;
            animationParms.TotalFrameCount = 7;
            parms.Position        = PositionGenerator.getInstance().generateSpawn();
            parms.Texture         = LoadingUtils.load <Texture2D>(content, "PortalOpen");
            parms.Origin          = new Vector2(Constants.TILE_SIZE);
            parms.AnimationParams = animationParms;
            this.idleSprite       = new Animated2DSprite(parms);

            animationParms.AnimationState  = AnimationState.PlayForwardOnce;
            animationParms.TotalFrameCount = 6;
            parms.AnimationParams          = animationParms;
            parms.Texture    = LoadingUtils.load <Texture2D>(content, "PortalSpawn");
            parms.Position   = new Vector2(parms.Position.X, parms.Position.Y);
            this.spawnSprite = new Animated2DSprite(parms);

            base.init(this.spawnSprite);

            BaseParticle2DEmitterParams emitterParams = new BaseParticle2DEmitterParams {
                ParticleTexture = LoadingUtils.load <Texture2D>(content, "Lightning"),
                SpawnDelay      = 500f
            };

            this.lightningEmitter = new LightningParticleEmitter(emitterParams, parms.Position);

            this.spawnSFX   = LoadingUtils.load <SoundEffect>(content, SPAWN_SFX_NAME);
            this.idleSFX    = LoadingUtils.load <SoundEffect>(content, IDLE_SFX_NAME);
            this.closingSFX = LoadingUtils.load <SoundEffect>(content, CLOSING_SFX_NAME);

            SoundEmitterParams sfxEmitterParms = new SoundEmitterParams {
                SFXEngine   = SoundManager.getInstance().SFXEngine,
                EmittRadius = SFX_EMITT_RADIUS,
                Position    = this.spawnSprite.Position
            };

            this.sfxEmitter = new SoundEmitter(sfxEmitterParms);
            SoundManager.getInstance().addEmitter(this.sfxEmitter);
            SoundManager.getInstance().playSoundEffect(this.sfxEmitter, this.spawnSFX);
        }
示例#4
0
        public Tail(ContentManager content, Vector2 position, Vector2 heading)
            : base(content, true)
        {
            Animated2DSpriteLoadSingleRowBasedOnTexture tailParms = new Animated2DSpriteLoadSingleRowBasedOnTexture();
            BaseAnimationManagerParams animationParms             = new BaseAnimationManagerParams();

            animationParms.AnimationState  = AnimationState.PlayForward;
            animationParms.FrameRate       = 100f;
            animationParms.TotalFrameCount = 4;
            tailParms.Position             = position;
            tailParms.Rotation             = MathHelper.ToRadians(180);
            tailParms.Texture         = LoadingUtils.load <Texture2D>(content, "SnakeTail");
            tailParms.Scale           = new Vector2(.5f);
            tailParms.Origin          = new Vector2(Constants.TILE_SIZE);
            tailParms.LightColour     = Constants.SNAKE_LIGHT;
            tailParms.AnimationParams = animationParms;
            base.init(new Animated2DSprite(tailParms));

            this.heading         = heading;
            this.targetPositions = new List <TargetPosition>();
        }
示例#5
0
        public static Base2DSpriteDrawable generateWaveEffect(ContentManager content, Vector2 position, Color light, out float effectLife)
        {
            int   frames = 6;
            float speed  = 15f;
            BaseAnimationManagerParams animationParms = new BaseAnimationManagerParams()
            {
                AnimationState  = AnimationState.PlayForwardOnce,
                TotalFrameCount = frames,
                FrameRate       = speed,
            };
            Animated2DSpriteLoadSingleRowBasedOnTexture parms = new Animated2DSpriteLoadSingleRowBasedOnTexture()
            {
                AnimationParams = animationParms,
                Position        = Vector2.Subtract(position, new Vector2(Constants.TILE_SIZE)),
                LightColour     = light,
                Origin          = new Vector2(Constants.TILE_SIZE),
                Texture         = LoadingUtils.load <Texture2D>(content, "WaveEffect")
            };

            effectLife = frames * speed;
            return(new Animated2DSprite(parms));
        }
示例#6
0
        public Nuke(ContentManager content, SFXEngine sfxEngine)
        {
            int frames = 6;
            BaseAnimationManagerParams animationParms = new BaseAnimationManagerParams();

            animationParms.AnimationState  = AnimationState.PlayForward;
            animationParms.FrameRate       = 100f;
            animationParms.TotalFrameCount = frames;
            BaseAnimated2DSpriteParams spriteParms = new Animated2DSpriteLoadSingleRowBasedOnTexture();

            spriteParms.Position        = new Vector2(-200f);
            spriteParms.Rotation        = 0f;
            spriteParms.Origin          = new Vector2(32f);
            spriteParms.Scale           = new Vector2(.75f);
            spriteParms.Texture         = LoadingUtils.load <Texture2D>(content, "NukeSprite");
            spriteParms.AnimationParams = animationParms;

            this.bomb  = new Animated2DSprite(spriteParms);
            this.State = SpriteState.InActive;
            this.textureColourDatas = new List <Color[, ]>();
            Rectangle frame;

            for (int i = 0; i < frames; i++)
            {
                frame = this.bomb.Frames[i];
                this.textureColourDatas.Add(
                    TextureUtils.getColourData2D(this.bomb.Texture, startX: frame.X, width: frame.X + frame.Width));
            }

            // Smoke emitter
            BaseParticle2DEmitterParams particleEmitterParms = new BaseParticle2DEmitterParams();

            particleEmitterParms.ParticleTexture = LoadingUtils.load <Texture2D>(content, "Smoke");
            particleEmitterParms.SpawnDelay      = SmokeParticleEmitter.SPAWN_DELAY;
            this.emitter = new SmokeParticleEmitter(content, particleEmitterParms);

            // sfx
            this.sfxEngine = sfxEngine;
        }
示例#7
0
        public Snake(ContentManager content, Vector2 heading, float xOffSet, Controls controls) : base(content, true)
        {
            this.heading      = heading;
            this.currentSpeed = STARTING_SPEED;
            this.controls     = controls;

            Animated2DSpriteLoadSingleRowBasedOnTexture headParms = new Animated2DSpriteLoadSingleRowBasedOnTexture();
            BaseAnimationManagerParams animationParms             = new BaseAnimationManagerParams();

            animationParms.AnimationState  = AnimationState.PlayForward;
            animationParms.FrameRate       = 100f;
            animationParms.TotalFrameCount = 4;
            headParms.Position             = new Vector2(xOffSet + PositionUtils.getPosition(Constants.MAX_X_TILES / 2), PositionUtils.getPosition(Constants.MAX_Y_TILES / 2 - 1));
            headParms.Texture         = LoadingUtils.load <Texture2D>(content, "SnakeHead");
            headParms.Scale           = new Vector2(.5f);
            headParms.Origin          = new Vector2(Constants.TILE_SIZE);
            headParms.LightColour     = Constants.SNAKE_LIGHT;
            headParms.AnimationParams = animationParms;
            base.init(new Animated2DSprite(headParms));

            this.body = new Body(content, new Vector2(headParms.Position.X, headParms.Position.Y + Constants.TILE_SIZE - Constants.OVERLAP), this.heading);

            this.tail        = new Tail(content, new Vector2(headParms.Position.X, headParms.Position.Y + (Constants.TILE_SIZE - Constants.OVERLAP) * 2), this.heading);
            this.cornerParms = new StaticDrawable2DParams {
                Texture = LoadingUtils.load <Texture2D>(content, "SnakeBody"),
                Origin  = new Vector2(Constants.TILE_SIZE / 2),
                Scale   = new Vector2(.8f),
            };
            this.corners = new List <StaticDrawable2D>();

            this.portalEnteredSFX = LoadingUtils.load <SoundEffect>(content, "PortalTakenSFX");
#if DEBUG
            this.debugPivotPoints       = new List <StaticDrawable2D>();
            this.pivotParms             = new StaticDrawable2DParams();
            this.pivotParms.Texture     = LoadingUtils.load <Texture2D>(content, "Chip");
            this.pivotParms.LightColour = Constants.DEBUG_PIVOT_Color;
            this.pivotParms.Scale       = new Vector2(4f);
#endif
        }
示例#8
0
        public Person(ContentManager content, string fileStartsWith, Placement startingLocation, float movementSpeed)
        {
            BaseAnimationManagerParams animationParams = new BaseAnimationManagerParams();

            animationParams.AnimationState  = AnimationState.PlayForward;
            animationParams.FrameRate       = FRAME_RATE;
            animationParams.TotalFrameCount = 4;
            BaseAnimated2DSpriteParams spriteParams = new Animated2DSpriteLoadSingleRowBasedOnTexture();

            spriteParams.Origin          = new Vector2(ResourceManager.TILE_SIZE / 2, ResourceManager.TILE_SIZE / 2);
            spriteParams.Texture         = LoadingUtils.load <Texture2D>(content, fileStartsWith + "Right");
            spriteParams.AnimationParams = animationParams;;
            // we actually want his feet in the middle, not his chest which is where the origin is
            spriteParams.Position     = new Vector2(startingLocation.worldPosition.X + spriteParams.Origin.X, startingLocation.worldPosition.Y);
            this.rightSprite          = new Animated2DSprite(spriteParams);
            spriteParams.SpriteEffect = SpriteEffects.FlipHorizontally;
            this.leftSprite           = new Animated2DSprite(spriteParams);
            this.Placement            = startingLocation;
            this.direction            = Direction.None;
            this.movementSpeed        = movementSpeed;
            this.activeSprite         = this.rightSprite;
            this.BoundingBox          = Helper.getPersonBBox(this.activeSprite.Position);
            this.previousTypeOfSpace  = AIManager.getInstance().Board[this.Placement.index.Y, this.Placement.index.X];
        }
示例#9
0
        private void initDelegates()
        {
            this.mobDeathFinish = delegate(Character character) {
                String texture = "Monster1";
                if (character.GetType() == typeof(Yeti))
                {
                    texture = "Monster2";
                }
                texture += "Death";
                Vector2 position = character.Position;
                int     frames   = 10;
                float   speed    = 100f;
                BaseAnimationManagerParams animationParms = new BaseAnimationManagerParams()
                {
                    AnimationState  = AnimationState.PlayForwardOnce,
                    TotalFrameCount = frames,
                    FrameRate       = speed,
                };
                Animated2DSpriteLoadSingleRowBasedOnTexture parms = new Animated2DSpriteLoadSingleRowBasedOnTexture()
                {
                    AnimationParams = animationParms,
                    Position        = position,
                    LightColour     = Color.White,
                    Texture         = LoadingUtils.load <Texture2D>(content, texture)
                };


                Animated2DSprite deathSprite = new Animated2DSprite(parms);
                this.recentlySpawned.Add(new Ghost(content, position, this.ghostObserverHandler, this.mobsInRange, this.ghostDeathFinish));
                this.theDead.Add(deathSprite);
            };
            this.ghostDeathFinish = delegate(Character character) {
                String  texture  = "GhostDeath";
                Vector2 position = character.Position;
                int     frames   = 10;
                float   speed    = 100f;
                BaseAnimationManagerParams animationParms = new BaseAnimationManagerParams()
                {
                    AnimationState  = AnimationState.PlayForwardOnce,
                    TotalFrameCount = frames,
                    FrameRate       = speed,
                };
                Animated2DSpriteLoadSingleRowBasedOnTexture parms = new Animated2DSpriteLoadSingleRowBasedOnTexture()
                {
                    AnimationParams = animationParms,
                    Position        = position,
                    LightColour     = Color.White,
                    Texture         = LoadingUtils.load <Texture2D>(content, texture)
                };
                Ghost ghost = (Ghost)character;
                ghost.Selected = false;
                this.selectedGhosts.Remove(ghost);
                this.allGhosts.Remove(ghost);
                this.theDead.Add(new Animated2DSprite(parms));
            };
            this.ghostsInRange = delegate(Character character) {
                return(getCharactersInRange <Ghost>(character, this.allGhosts));
            };
            this.mobsInRange = delegate(Character character) {
                return(getCharactersInRange <Mob>(character, this.mobs));
            };
            this.collisionCheck = delegate(Vector2 newPosition) {
                bool        safe           = true;
                BoundingBox newBoundingBox = CollisionGenerationUtils.getBBox(newPosition);
                foreach (Wall wall in map.Walls)
                {
                    if (wall.BBox.Intersects(newBoundingBox))
                    {
                        safe = false;
                        break;
                    }
                }
                return(safe);
            };
#if DEBUG
            this.editorsCreator = delegate(MapEditor.MappingState type, MonsterType monsterType, Vector2 position) {
                switch (type)
                {
                case MapEditor.MappingState.Monster:
                    if (monsterType == MonsterType.Devil)
                    {
                        this.mobs.Add(new Devil(content, position, this.ghostsInRange, this.mobDeathFinish, this.collisionCheck));
                    }
                    else if (monsterType == MonsterType.Yeti)
                    {
                        this.mobs.Add(new Yeti(content, position, this.ghostsInRange, this.mobDeathFinish, this.collisionCheck));
                    }
                    break;
                }
                ;
            };
#endif
        }