Example #1
0
 public void init(EditorCreator objectCreator)
 {
     this.objectCreator  = objectCreator;
     this.createdObjects = new List <CreatedType>();
 }
Example #2
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
        }