Example #1
0
        public override void Initialize(Section owner)
        {
            base.Initialize(owner);
            graphics = (ComplexGraphicsObject)ContentPackageManager.GetGraphicsResource("SMBBuzzyBeetle");

            HealthComponent health = new HealthComponent(1, 1, new string[] { SpriteDamageTypes.PlayerFireball, SpriteDamageTypes.PlayerStomp });
            health.SpriteKilled += Health_SpriteKilled;

            SpriteDirection initialDirection = ResolveDirection(this, Direction, Owner);
            facingDirection = (initialDirection == SpriteDirection.Left) ? SMLimitless.Direction.Left : SMLimitless.Direction.Right;
            Components.Add(health);
            Components.Add(new WalkerComponent(this, initialDirection, WalkingSpeed.Value));
            Components.Add(new DamageComponent());
            Components.Add(new ChasePlayerComponent(this, 60));

            ShelledEnemyComponent shelledEnemy = new ShelledEnemyComponent(this, WalkingSpeed.Value, ShellSpinningSpeed.Value, FramesUntilBeginEmerge.Value, FramesUntilEmerge.Value);
            shelledEnemy.StateChanged += ShelledEnemy_StateChanged;
            Components.Add(shelledEnemy);
        }
        /// <summary>
        ///   Returns a deep copy of this ComplexGraphicsObject. With the
        ///   texture, only its reference is copied.
        /// </summary>
        /// <returns>A deep copy of this object.</returns>
        public IGraphicsObject Clone()
        {
            ComplexGraphicsObject result = new ComplexGraphicsObject();
            Dictionary<string, IGraphicsObject> cloneObjects = new Dictionary<string, IGraphicsObject>();
            foreach (var graphicsObjectPair in graphicsObjects)
            {
                result.graphicsObjects.Add(graphicsObjectPair.Key, graphicsObjectPair.Value.Clone());
            }

            result.CurrentObjectName = CurrentObjectName;
            result.configFilePath = configFilePath;
            result.FilePath = FilePath;
            result.FrameSize = FrameSize;
            result.isContentLoaded = true;
            result.isLoaded = true;
            result.texture = texture;

            return result;
        }
Example #3
0
        public override void Initialize(Section owner)
        {
            base.Initialize(owner);
            graphics = (ComplexGraphicsObject)ContentPackageManager.GetGraphicsResource("SMBSpiny");

            graphics.CurrentObjectName = (SpinyState == SpinyState.Spiny) ? "walking" : "egg";

            HealthComponent health = new HealthComponent(1, 1, new string[] { SpriteDamageTypes.PlayerStomp });
            health.SpriteKilled += Health_SpriteKilled;

            Components.Add(new WalkerComponent(this, ResolveDirection(this, Direction, Owner), WalkingSpeed.Value));
            Components.Add(health);
            Components.Add(new DamageComponent());
        }
Example #4
0
        /// <summary>
        ///   Loads an instance of IGraphicsObject from a given file path. If a
        ///   text file with the same name is in the same folder, that will be
        ///   used to determine what kind of graphics object it is. If no text
        ///   file is present, the object is assumed to be static. Otherwise, the
        ///   type (animated, complex) depends on what the first line of the file is.
        /// </summary>
        /// <param name="filePath">
        ///   The path to the image of the graphics object.
        /// </param>
        /// <returns>A loaded IGraphicsObject instance.</returns>
        public static IGraphicsObject LoadGraphicsObject(string filePath)
        {
            if (!loadedObjects.ContainsKey(filePath))
            {
                // We'll assume we have the right path (considering graphics overrides).
                string fileNameWithoutExt = Path.GetFileNameWithoutExtension(filePath);
                string directoryName = new FileInfo(filePath).DirectoryName;
                string configPath = Path.Combine(directoryName, string.Concat(fileNameWithoutExt, ".txt"));

                if (!File.Exists(configPath))
                {
                    // No configuration, so the object is probably static
                    var result = new StaticGraphicsObject();
                    result.Load(filePath);
                    loadedObjects.Add(filePath, result);
                    return result;
                }
                else
                {
                    // A configuration! Let's read it to find out what it is.
                    DataReader config = new DataReader(configPath);
                    if (config[0] == "[Animated]" || config[0] == "[Animated_RunOnce]")
                    {
                        var result = new AnimatedGraphicsObject();
                        result.Load(filePath, config);
                        loadedObjects.Add(filePath, result);
                        return result;
                    }
                    else if (config[0] == "[Complex]")
                    {
                        var result = new ComplexGraphicsObject();
                        result.Load(filePath, config);
                        loadedObjects.Add(filePath, result);
                        return result;
                    }
                }
            }
            else
            {
                return loadedObjects[filePath].Clone();
            }

            return null;
        }
        /// <summary>
        ///   Loads an AnimatedGraphicsObjects from a configuration section in a ComplexGraphicsObject.
        /// </summary>
        /// <param name="section">
        ///   The section from the CGO configuration that specifies this object.
        /// </param>
        /// <param name="owner">The CGO that owns this object.</param>
        internal void Load(Dictionary<string, string> section, ComplexGraphicsObject owner)
        {
            if (!isLoaded)
            {
                int frames = int.Parse(section["Frames"]);
                Vector2 frameSize = owner.FrameSize;
                filePath = owner.FilePath;
                for (int i = 0; i < frames; i++)
                {
                    CgoSourceRects.Add(Vector2Extensions.Parse(section[string.Concat("Frame", i)]).ToRectangle(frameSize));
                }

                if (section["Type"] == "animated_runonce")
                {
                    IsRunOnce = true;
                }

                AnimationCycleLength = decimal.Parse(section["CycleLength"]);
                cgoOwner = owner;
                frameCount = frames - 1;
                isLoaded = true;
            }
        }
Example #6
0
        public override void Initialize(Section owner)
        {
            column = new PlayerSensingColumn(owner, SpawnBandStart, SpawnBandEnd);
            graphics = (ComplexGraphicsObject)ContentPackageManager.GetGraphicsResource("SMBLakitu");

            ActiveState = SpriteActiveState.AlwaysActive;
            TileCollisionMode = SpriteCollisionMode.NoCollision;

            var health = new HealthComponent(1, 1, new string[] { });
            health.SpriteKilled += Health_SpriteKilled;

            Components.Add(health);
            Components.Add(new DamageComponent());

            base.Initialize(owner);
        }
Example #7
0
        public override void Initialize(Section owner)
        {
            base.Initialize(owner);
            graphics = (ComplexGraphicsObject)ContentPackageManager.GetGraphicsResource("SMBKoopaTroopa");

            graphics.CurrentObjectName = AppendTypeSuffix("walking");

            HealthComponent healthComponent = new HealthComponent(1, 1, new string[] { SpriteDamageTypes.PlayerStomp });
            healthComponent.SpriteKilled += HealthComponent_SpriteKilled;

            SpriteDirection initialDirection = ResolveDirection(this, Direction, Owner);
            facingDirection = (initialDirection == SpriteDirection.Left) ? SMLimitless.Direction.Left : SMLimitless.Direction.Right;
            Components.Add(healthComponent);
            Components.Add(new WalkerComponent(this, initialDirection, WalkingSpeed.Value));
            Components.Add(new DamageComponent());

            ChasePlayerComponent chasePlayer = new ChasePlayerComponent(this, 60);
            chasePlayer.NearestPlayerDirectionUpdated += ChasePlayer_NearestPlayerDirectionUpdated;
            Components.Add(chasePlayer);

            ShelledEnemyComponent shelledEnemy = new ShelledEnemyComponent(this, WalkingSpeed.Value, ShellSpinningSpeed.Value, FramesUntilBeginEmerge.Value, FramesUntilEmerge.Value);
            shelledEnemy.StateChanged += ShelledEnemy_StateChanged;
            Components.Add(shelledEnemy);
            SetBehavior();
        }
Example #8
0
        public override void Initialize(Section owner)
        {
            base.Initialize(owner);
            graphics = (ComplexGraphicsObject)ContentPackageManager.GetGraphicsResource("SMBGoomba");

            graphics.CurrentObjectName = AppendPaletteNameSuffix("walking");

            HealthComponent healthComponent = new HealthComponent(1, 1, new string[] { });
            healthComponent.SpriteKilled += HealthComponent_SpriteKilled;

            Components.Add(new WalkerComponent(this, ResolveDirection(this, Direction, owner), 32f));
            Components.Add(healthComponent);
            Components.Add(new DamageComponent());
        }