public SmallMarioFlagSlide(IPlayableObject playableObject)
 {
     this.playableObject = playableObject;
     this.playableObject.StarPower = false;
     sprite = AnimatedSpriteFactory.Instance.BuildSmallFlagSlideMarioSprite();
     this.playableObject.CollisionRectangle = sprite.SpriteDestinationRectangle;
 }
Exemplo n.º 2
0
        public static void Initialize(GraphicsDevice device, ContentManager content)
        {
            HillSprite = new AnimatedSprite(content.Load<Texture2D>("Art/Z3 Art/Hill"));
            HillSprite.SetOriginToCenter();
            HillSprite.StartAnimation();
            HillSprite.DrawArgs.Scale *= 0.5f;

            ConfusedSprite = new AnimatedSprite(content.Load<Texture2D>("Art/Z3 Art/Stunned"), 2, TimeSpan.FromSeconds(0.25), true, -1, 0);
            ConfusedSprite.SetOriginToCenter();
            ConfusedSprite.StartAnimation();

            DogHouseSprite = new AnimatedSprite(content.Load<Texture2D>("Art/Z3 Art/doghouse"));
            DogHouseSprite.SetOriginToCenter();
            DogHouseLowerSprite = new AnimatedSprite(content.Load<Texture2D>("Art/Z3 Art/doghouse lower"));
            DogHouseLowerSprite.SetOriginToCenter();

            HarmonyJousterStill = new AnimatedSprite(content.Load<Texture2D>("Art/Z3 Art/dog_still"), 8, TimeSpan.FromSeconds(0.1), true);
            HarmonyJousterStill.SetOriginToCenter();
            HarmonyJousterStill.StartAnimation();

            DischordJousterStill = new AnimatedSprite(content.Load<Texture2D>("Art/Z3 Art/baddog_still"), 8, TimeSpan.FromSeconds(0.1), true);
            DischordJousterStill.SetOriginToCenter();
            DischordJousterStill.StartAnimation();

            TennisBall = new AnimatedSprite(content.Load<Texture2D>("Art/Z3 Art/tennisball"));
            TennisBall.SetOriginToCenter();
            TennisBall.StartAnimation();
        }
Exemplo n.º 3
0
        //!---CONSTRUCTORS---!
        public Main(ContentManager Content)
            : base()
        {
            bBackground = new GUIItems.Background(Content);

            sPixel = new AnimatedSprite(Content, "pixel");
            sPixel.Colour = Color.Black;
            sPixel.FrameHeight = 544;
            sPixel.FrameWidth = 260;
            sPixel.Alpha = 0.7f;
            sPixel.Position = new Vector2(700, 0);

            sLine = new AnimatedSprite(Content, "pixel");
            sLine.Colour = Color.White;
            sLine.FrameHeight = 544;
            sLine.FrameWidth = 2;
            sLine.Alpha = 0.7f;
            sLine.Position = new Vector2(700, 0);

            float XOffset = 32;
            float YOffset = Dimensions.Height / 10;

            bPlay = new GUIItems.Button(Content, new Vector2(XOffset, YOffset * 4), "Play");
            bEditor = new GUIItems.Button(Content, new Vector2(XOffset, YOffset * 5), "Editor");
            bOptions = new GUIItems.Button(Content, new Vector2(XOffset, YOffset * 6), "Options");
            bHelp = new GUIItems.Button(Content, new Vector2(XOffset, YOffset * 7), "Help");
            bQuit = new GUIItems.Button(Content, new Vector2(XOffset, YOffset * 8), "Quit");
            bTest = new GUIItems.Button(Content, new Vector2(960 - 256 - 64, 544 - 128), "Test");
        }
Exemplo n.º 4
0
        public Options(ContentManager Content)
            : base()
        {
            bBackground = new GUIItems.Background(Content);

            sPixel = new AnimatedSprite(Content, "pixel");
            sPixel.Colour = new Color(Color.Black, 1.0f);
            sPixel.FrameHeight = 544;
            sPixel.FrameWidth = 960;
            sPixel.Alpha = 0.7f;

            XOffset = 32;
            YOffset = Dimensions.Height / 10;

            #if DESKTOP
            bMusic = new GUIItems.Button(Content, new Vector2(XOffset, YOffset * 3), "Music");
            #endif
            //  Buttons
            tbMinRooms  = new Neuroleptic.Editor.GUI.Textbox(Content, new Vector2(XOffset, YOffset * 5),"Min Rooms");
            tbMaxRooms  = new Neuroleptic.Editor.GUI.Textbox(Content, new Vector2(XOffset, YOffset * 6),"Max Rooms");
            tbMinRooms.CurrentString = Option.RoomsMin.ToString();
            tbMaxRooms.CurrentString = Option.RoomsMax.ToString();

            bControls   = new GUIItems.Button(Content , new Vector2(XOffset, YOffset * 7), "Controls");
            bBack       = new GUIItems.Button(Content , new Vector2(XOffset, YOffset * 8), "Back");
        }
Exemplo n.º 5
0
 public Fire(int x, int y)
     : base(null, TileType.Fire)
 {
     sprite = new AnimatedSprite(texture, 26, 26, 0.1f);
     this.x = x;
     this.y = y;
 }
 public void Initialize()
 {
     parent.IsYoshi = true;
     sprite = AnimatedSpriteFactory.Instance.BuildYoshiIdleSprite(parent.Position);
     CollisionRectangle = sprite.SpriteDestinationRectangle;
     ScoreSprite = new ScoreSprite("", parent.Position, false);
 }
Exemplo n.º 7
0
 public static void Initialize(GraphicsDevice gd, Microsoft.Xna.Framework.Content.ContentManager content)
 {
     DirtCloud = new AnimatedSprite(content.Load<Texture2D>("Art/Z3 Art/Dirt Particle"));
     DirtCloud.DrawArgs.Scale = new Vector2(Scale * 0.25f);
     DirtCloud.SetOriginToCenter();
     DirtCloud.StartAnimation();
 }
Exemplo n.º 8
0
        public override void Initialize(Vector2 position)
        {
            Active = true;

            if(cType == CrystalType.blue)
            {
                SpriteAnimation = new AnimatedSprite(Globals.content.Load<Texture2D>("Sprites/Collectables/bluerelic"));
                FrameAnimation relic = new FrameAnimation(1, 32, 32, 0, 0);
                relic.FramesPerSecond = 1;
                SpriteAnimation.Animations.Add("Relic", relic);
            }
            if(cType == CrystalType.red)
            {
                SpriteAnimation = new AnimatedSprite(Globals.content.Load<Texture2D>("Sprites/Collectables/redrelic"));
                FrameAnimation relic = new FrameAnimation(1, 32, 32, 0, 0);
                relic.FramesPerSecond = 1;
                SpriteAnimation.Animations.Add("Relic", relic);
            }
            if(cType == CrystalType.green)
            {
                SpriteAnimation = new AnimatedSprite(Globals.crysTex = Globals.content.Load<Texture2D>("Sprites/Collectables/greenrelic"));
                FrameAnimation relic = new FrameAnimation(1, 32, 32, 0, 0);
                relic.FramesPerSecond = 1;
                SpriteAnimation.Animations.Add("Relic", relic);
            }
            SpriteAnimation.CurrentAnimationName = "Relic";
            SpriteAnimation.Position = position;

            collectedEffect = Globals.content.Load<SoundEffect>("Sounds/Collect_Item");
        }
 public void Initialize()
 {
     ScoreValue = GameValues.FloatingCoinScoreValue;
     sprite = AnimatedSpriteFactory.Instance.BuildFloatingCoinSprite(parent.Position);
     CollisionRectangle = sprite.SpriteDestinationRectangle;
     ScoreSprite = new ScoreSprite(ScoreValue.ToString(), parent.Position, false);
 }
 public BigRightCrouchingMario(IPlayableObject playableObject)
 {
     this.playableObject = playableObject;
     sprite = AnimatedSpriteFactory.Instance.BuildBigRightCrouchingMarioSprite();
     this.playableObject.CollisionRectangle = sprite.SpriteDestinationRectangle;
     crouchPressed = true;
 }
 public ComingOutOfShellKoopa(Vector2 position, Enemy parent)
 {
     this.parent = parent;
     ScoreValue = GameValues.ComingOutOfShellKoopaScoreValue;
     sprite = AnimatedSpriteFactory.Instance.BuildEnemyComingOutOfShellKoopaSprite(position);
     CollisionRectangle = sprite.SpriteDestinationRectangle;
     ScoreSprite = new ScoreSprite(ScoreValue.ToString(), position, false);
 }
Exemplo n.º 12
0
 public void PopAnimation(AnimatedSprite[] anim)
 {
     if (AnimationStack.Count > 0 && AnimationStack.Peek() == anim)
     {
         AnimationStack.Pop();
         UpdateAnimation();
     }
 }
Exemplo n.º 13
0
 public void PushAnimation(AnimatedSprite[] anim)
 {
     if (AnimationStack.Count == 0 || AnimationStack.Peek() != anim)
     {
         AnimationStack.Push(anim);
         UpdateAnimation();
     }
 }
Exemplo n.º 14
0
 public void Initialize()
 {
     ScoreValue = GameValues.StarScoreValue;
     sprite = AnimatedSpriteFactory.Instance.BuildStarSprite(parent.Position);
     CollisionRectangle = sprite.SpriteDestinationRectangle;
     ScoreSprite = new ScoreSprite(ScoreValue.ToString(), parent.Position, false);
     stoppingPosition = parent.Position.Y - CollisionRectangle.Height;
 }
Exemplo n.º 15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Switch"/> class.
 /// </summary>
 /// <param name="spriteBatch">The sprite batch to render sprites with.</param>
 /// <param name="contentManager">The content manager to load assets with.</param>
 /// <param name="physicsWorld">The game's physics world.</param>
 /// <param name="position">The position of the switch.</param>
 /// <param name="mineCart">The mine cart to activate.</param>
 public Switch(SpriteBatch spriteBatch, ContentManager contentManager, ref World physicsWorld, Vector2 position, MineCart mineCart)
 {
     this.sprite = new AnimatedSprite();
     this.activated = false;
     this.mineCart = mineCart;
     this.InitializeAndLoadSprites(spriteBatch, contentManager);
     this.SetUpPhysics(ref physicsWorld, position);
 }
 public SmallRightToBig(IPlayableObject playableObject)
 {
     this.playableObject = playableObject;
     sprite = AnimatedSpriteFactory.Instance.BuildSmallRightMarioToBigMarioSprite();
     growthBuffer = GameValues.MarioStateSmallToBigGrowthBuffer;
     this.playableObject.CollisionRectangle = sprite.SpriteDestinationRectangle;
     GameStateMachine.Instance.GameState = new MarioFreezeGameAnimationState();
 }
Exemplo n.º 17
0
 public void AddExplosion(Vector position)
 {
     AnimatedSprite explosion = new AnimatedSprite();
     explosion.Texture = _textureManager.Get("explosion");
     explosion.SetAnimation(4, 4);
     explosion.SetPosition(position);
     _effects.Add(explosion);
 }
 public FlippedKoopaShell(Vector2 position, Enemy parent)
 {
     this.parent = parent;
     ScoreValue = GameValues.KoopaShellScoreValue;
     sprite = AnimatedSpriteFactory.Instance.BuildEnemyFlippedKoopaShellSprite(position);
     CollisionRectangle = sprite.SpriteDestinationRectangle;
     ScoreSprite = new ScoreSprite(ScoreValue.ToString(), position, true);
 }
Exemplo n.º 19
0
 public MetalBlock(Vector2 position, Block parent)
 {
     this.parent = parent;
     sprite = AnimatedSpriteFactory.Instance.BuildMetalBlockSprite(position);
     sprite.UpdateSpritePosition(position);
     CollisionRectangle = sprite.SpriteDestinationRectangle;
     BlockStateTransitionMachine = new BlockStateTransitionMachine();
 }
Exemplo n.º 20
0
        public Bandit(IEnemy enemyObject)
        {
            this.parent = enemyObject;
            this.Position = parent.Position;

            sprite = AnimatedSpriteFactory.Instance.BuildBanditSprite(parent.Position);
            this.CollisionRectangle = sprite.SpriteDestinationRectangle;
        }
 public void Initialize()
 {
     ScoreValue = GameValues.RotatingCoinScoreValue;
     sprite = AnimatedSpriteFactory.Instance.BuildRotatingCoinSprite(parent.Position);
     CollisionRectangle = sprite.SpriteDestinationRectangle;
     ScoreSprite = new ScoreSprite(ScoreValue.ToString(), parent.Position, false);
     stoppingPosition = parent.Position.Y - GameValues.BlockRotatingCoinStoppingYPosition;
 }
Exemplo n.º 22
0
        public King(IPlayableObject playableObject)
        {
            this.parent = playableObject;
            this.Position = parent.Position;

            sprite = AnimatedSpriteFactory.Instance.BuildKingSprite(parent.Position);
            this.CollisionRectangle = sprite.SpriteDestinationRectangle;
        }
 public void Initialize()
 {
     ScoreValue = GameValues.Mushroom1UPScoreValue;
     sprite = AnimatedSpriteFactory.Instance.BuildMushroom1UpSprite(parent.Position);
     CollisionRectangle = sprite.SpriteDestinationRectangle;
     ScoreSprite = new ScoreSprite(GameValues.Mushroom1UPScoreSpriteName, parent.Position, false);
     stoppingPosition = parent.Position.Y - CollisionRectangle.Height;
 }
Exemplo n.º 24
0
 public BowserDead(Vector2 position, Enemy parent)
 {
     this.parent = parent;
     ScoreValue = GameValues.BowserScoreValue;
     sprite = AnimatedSpriteFactory.Instance.BuildBowserDeadSprite(position);
     CollisionRectangle = sprite.SpriteDestinationRectangle;
     ScoreSprite = new ScoreSprite(ScoreValue.ToString(), position, true);
     timeout = GameValues.EnemyDeadEnemyTimeout;
 }
Exemplo n.º 25
0
 public void Initialize()
 {
     ScoreValue = GameValues.PowerUpScoreValue;
     ScoreSprite = new ScoreSprite(ScoreValue.ToString(), parent.Position, false);
     mushroomSprite = AnimatedSpriteFactory.Instance.BuildMushroomSprite(parent.Position);
     fireFlowerSprite = AnimatedSpriteFactory.Instance.BuildFireFlowerSprite(parent.Position);
     stoppingPosition = parent.Position.Y - mushroomSprite.Texture.Height;
     CollisionRectangle = mushroomSprite.SpriteDestinationRectangle;
 }
Exemplo n.º 26
0
 //!---CONSTRUCTORS---!
 public Splash(ContentManager Content)
     : base()
 {
     dTime = 0.0d;
     sSplashOverlay = new AnimatedSprite(Content, "Menus/SplashOverlay");
     sSplashOverlay.Alpha = 0.8f;
     sSplash = new AnimatedSprite(Content, "Menus/Splash");
     sSplash.Alpha = 0.0f;
 }
 public RightWalkingKoopa(Vector2 position, Enemy parent)
 {
     this.parent = parent;
     ScoreValue = GameValues.KoopaScoreValue;
     ScoreSprite = new ScoreSprite(ScoreValue.ToString(), position, false);
     Velocity = GameValues.RightWalkingKoopaInitialVelocity;
     sprite = AnimatedSpriteFactory.Instance.BuildEnemyRightWalkingKoopaSprite(new Vector2(position.X, position.Y));
     CollisionRectangle = sprite.SpriteDestinationRectangle;
 }
 public HidingInsideShellKoopa(Vector2 position, Enemy parent)
 {
     this.parent = parent;
     ScoreValue = GameValues.KoopaShellScoreValue;
     ScoreSprite = new ScoreSprite(ScoreValue.ToString(), position, false);
     Velocity = Vector2.Zero;
     sprite = AnimatedSpriteFactory.Instance.BuildEnemyHidingInsideShellKoopaSprite(position);
     CollisionRectangle = sprite.SpriteDestinationRectangle;
 }
 public CrawfisDead(Vector2 position, Enemy parent)
 {
     this.parent = parent;
     ScoreValue = GameValues.CrawfisScoreValue;
     sprite = AnimatedSpriteFactory.Instance.BuildCrawfisDeadSprite(position);
     CollisionRectangle = GameValues.EmptyCollisionRectangle;
     ScoreSprite = new ScoreSprite(ScoreValue.ToString(), position, true);
     timeout = GameValues.EnemyDeadEnemyTimeout;
 }
 public void Initialize()
 {
     parent.IsYoshi = true;
     ScoreValue = GameValues.YoshiGreenEggScoreValue;
     sprite = AnimatedSpriteFactory.Instance.BuildYoshiGreenEggSprite(parent.Position);
     CollisionRectangle = sprite.SpriteDestinationRectangle;
     ScoreSprite = new ScoreSprite("", parent.Position, false);
     stoppingPosition = parent.Position.Y - CollisionRectangle.Height;
 }
Exemplo n.º 31
0
        public override void ShouldAttack(AnimatedSprite sprite)
        {
            float distance = Vector2.Distance(sprite.Center, Sprite.Center);

            if (distance < sprite.Width * 2 && attackTimer >= 1.25 && !isAttacking)
            {
                isAttacking = true;
                attackTimer = 0;

                if (Sprite.Position.X < sprite.Position.X)
                {
                    attackingDirection = 1;
                }
                else if (Sprite.Position.X > sprite.Position.X)
                {
                    attackingDirection = 3;
                }
                else if (Sprite.Position.Y < sprite.Position.Y)
                {
                    attackingDirection = 2;
                }
                else
                {
                    attackingDirection = 0;
                }

                switch (attackingDirection)
                {
                case 0:
                    sword = new Rectangle(
                        (int)Sprite.Position.X + (32 - swordUp.Width) / 2,
                        (int)Sprite.Position.Y - swordUp.Height,
                        swordUp.Width,
                        swordUp.Height);
                    break;

                case 2:
                    sword = new Rectangle(
                        (int)Sprite.Position.X + (32 - swordDown.Width) / 2,
                        (int)Sprite.Position.Y + 32,
                        swordDown.Width,
                        swordDown.Height);
                    break;

                case 1:
                    sword = new Rectangle(
                        (int)Sprite.Position.X + 32,
                        (int)Sprite.Position.Y + (32 - swordRight.Height) / 2,
                        swordRight.Width,
                        swordRight.Height);
                    break;

                case 3:
                    sword = new Rectangle(
                        (int)Sprite.Position.X - swordLeft.Width,
                        (int)Sprite.Position.Y + (32 - swordLeft.Height) / 2,
                        swordLeft.Width,
                        swordLeft.Height);
                    break;
                }
            }
        }
 public ModelChangeEffect(AnimatedSprite model, string modelName, AoeMode aoeMode)
     : base(aoeMode)
 {
     newModel     = model;
     newModelName = modelName;
 }
Exemplo n.º 33
0
 public override void _Ready()
 {
     base._Ready();
     sprite = GetNode <AnimatedSprite>("AnimatedSprite");
     Juni.Connect(nameof(Juni.Jumped), this, nameof(juniJumped));
 }
Exemplo n.º 34
0
        public Player(Game1 game1) : base("player", new Vector2(5f, 1.18f), new Vector2(0.5f, 0.5f), 120f, Enumerable.Range(0, 9).Select(n => game1.Content.Load <Texture2D>($"playersprites/Stand/{n}")).ToArray())
        {
            _instance   = this;
            _idleFrames = _textures; // loaded by the base construtor
            _walkFrames = Enumerable.Range(0, 9).Select(n => game1.Content.Load <Texture2D>($"playersprites/Walk/{n}")).ToList();
            _castFrames = Enumerable.Range(0, 9).Select(n => game1.Content.Load <Texture2D>($"playersprites/Cast1H/{n}")).ToList();
            _dieFrames  = Enumerable.Range(0, 9).Select(n => game1.Content.Load <Texture2D>($"playersprites/Die/{n}")).ToList();
            _game       = game1;
            _bullet     = _game.Content.Load <Texture2D>("fireball");
            _objects    = new List <ITempObject>();


            crystals = 3;
            _coins   = 1;

            AddRectangleBody(
                _game.Services.GetService <World>(), _size.X * 1.6f, _size.Y * 2.4f //Some magic numbers cause collider was offset
                );                                                                  // kinematic is false by default

            Fixture top = FixtureFactory.AttachRectangle(
                _size.X, _size.Y * 0.05f,
                1, new Vector2(0, +_size.Y + 0.1f),
                Body);

            top.IsSensor    = true;
            top.OnCollision = (a, b, contact) =>
            {
                if (b.GameObject().Name == "spikes big" || b.GameObject().Name == "spikes small")
                {
                    if (!_damaged)
                    {
                        _damaged = true;
                        _hp      = _hp - 10;
                    }
                }
            };

            Fixture Bottom = FixtureFactory.AttachRectangle(
                _size.X, _size.Y * 0.05f,
                1, new Vector2(0, -_size.Y - 0.1f),
                Body);

            Bottom.IsSensor = true;

            Bottom.OnCollision = (a, b, contact) =>
            {
                if (b.GameObject().Name == "platform")
                {
                    _isGrounded = true;
                }
                if (b.GameObject().Name == "npc")
                {
                    Body.ApplyForce(new Vector2(0, 150f));
                }
            };
            Bottom.OnSeparation = (a, b, contact) => _isGrounded = false;


            Fixture left = FixtureFactory.AttachRectangle(
                _size.X * 0.2f, _size.Y / 2,
                1, new Vector2(-_size.X * 0.8f, 0),
                Body);

            left.IsSensor = true;

            left.OnCollision = (a, b, contact) =>
            {
                if (b.GameObject().Name == "brick")
                {
                    canwalljumpright = true;
                }
                if (b.GameObject().Name == "npc" && !_damaged)
                {
                    _hp      = _hp - 30;
                    _damaged = true;
                }
            };
            left.OnSeparation = (a, b, contact) => canwalljumpright = false;

            Fixture right = FixtureFactory.AttachRectangle(
                _size.X * 0.2f, _size.Y / 2,
                1, new Vector2(_size.X * 0.8f, 0),
                Body);

            right.IsSensor = true;

            right.OnCollision = (a, b, contact) =>
            {
                if (b.GameObject().Name == "brick")
                {
                    canwalljumpleft = true;
                }
                if (b.GameObject().Name == "npc" && !_damaged)
                {
                    _hp      = _hp - 30;
                    _damaged = true;
                }
            };
            right.OnSeparation = (a, b, contact) => canwalljumpleft = false;

            KeyboardManager.Register(
                Keys.Space,
                KeysState.GoingDown,
                () =>
                { if (_status != Status.Dead)
                  {
                      if (_isGrounded)
                      {
                          Body.ApplyForce(new Vector2(0, 375f));
                          candoublejump = true;
                      }
                      else if (candoublejump)
                      {
                          candoublejump = false;
                          Body.ApplyForce(new Vector2(0, 285f));
                      }
                      else if (canwalljumpleft && KeyboardManager.IsKeyDown(Keys.A))
                      {
                          Body.ApplyForce(new Vector2(-80f, 550f));
                      }
                      else if (canwalljumpright && KeyboardManager.IsKeyDown(Keys.D))
                      {
                          Body.ApplyForce(new Vector2(80f, 550f));
                      }
                  }
                });
            KeyboardManager.Register(
                Keys.A,
                KeysState.Down,
                () => { if (_status != Status.Dead)
                        {
                            Body.ApplyForce(new Vector2(-12.5f, 0));
                        }
                });
            KeyboardManager.Register(
                Keys.D,
                KeysState.Down,
                () => { if (_status != Status.Dead)
                        {
                            Body.ApplyForce(new Vector2(12.5f, 0));
                        }
                });

            KeyboardManager.Register(
                Keys.F, KeysState.GoingDown,
                () =>
            {
                if (crystals > 0 && _status != Status.Dead)
                {
                    Vector2 pixelClick  = Mouse.GetState().Position.ToVector2();
                    Vector2 pixelPlayer = Camera.Position2Pixels(_position);
                    Vector2 delta       = pixelClick - pixelPlayer;
                    delta.Normalize();
                    delta.Y     = -delta.Y; // Invert for "virtual" world
                    Vector2 dir = 5f * delta;

                    Bullet bullet = new Bullet(_bullet, _position,
                                               dir, game1.Services.GetService <World>());
                    _objects.Add(bullet);
                    crystals--;
                }
            }
                );
            KeyboardManager.Register(
                Keys.R,
                KeysState.Down,
                () => {
                if (_mana > 0 && _status != Status.Dead)
                {
                    Body.ApplyForce(new Vector2(0, 30f));
                    _status = Status.Cast;
                }
            });
            KeyboardManager.Register(
                Keys.R,
                KeysState.GoingUp,
                () => {
                _status = Status.Idle;
            });

            Aura = new AnimatedSprite("aura", _position, _size, 32f, Enumerable.Range(0, 31).Select(n => game1.Content.Load <Texture2D>($"aura/aura{n}")).ToArray());
        }
Exemplo n.º 35
0
 public override void reloadSprite()
 {
     Sprite = new AnimatedSprite("Characters\\Monsters\\Skeleton");
     Sprite.SpriteHeight = 32;
     Sprite.UpdateSourceRect();
 }
Exemplo n.º 36
0
        //Generates a random SpeedScale for a wave
        //Speed will make the wave last duration +/- 10%
        private float GenerateWaveSpeed(AnimatedSprite wave)
        {
            float baseSpeed = (wave.Frames.GetFrameCount("default") / duration) / wave.Frames.GetAnimationSpeed("default");

            return((float)Command.Random(baseSpeed - (baseSpeed / 10), baseSpeed + (baseSpeed) / 10));
        }
Exemplo n.º 37
0
 private void DrawAnimatedSprite(AnimatedSprite sprite)
 {
     sprite.Animate();
     spriteBatch.Draw(sprite.CurrentFrame, sprite.Rect, null, Color.White, sprite.Rotation, sprite.Center, SpriteEffects.None, 0);
 }
Exemplo n.º 38
0
 public override void _Ready()
 {
     base._Ready();
     sprite = GetNode <AnimatedSprite>("Sprite");
 }
Exemplo n.º 39
0
        private void CreateWorld()
        {
            Texture2D tilesetTexture = Game.Content.Load <Texture2D>(@"Tilesets\tileset1");
            Tileset   tileset1       = new Tileset(tilesetTexture, 8, 8, 32, 32);

            tilesetTexture = Game.Content.Load <Texture2D>(@"Tilesets\tileset2");

            Tileset  tileset2 = new Tileset(tilesetTexture, 8, 8, 32, 32);
            MapLayer layer    = new MapLayer(100, 100);

            for (int y = 0; y < layer.Height; y++)
            {
                for (int x = 0; x < layer.Width; x++)
                {
                    Tile tile = new Tile(0, 0);
                    layer.SetTile(x, y, tile);
                }
            }

            MapLayer splatter = new MapLayer(100, 100);
            Random   random   = new Random();

            for (int i = 0; i < 100; i++)
            {
                int x     = random.Next(0, 100);
                int y     = random.Next(0, 100);
                int index = random.Next(2, 14);

                Tile tile = new Tile(index, 0);

                splatter.SetTile(x, y, tile);
            }

            splatter.SetTile(1, 0, new Tile(0, 1));
            splatter.SetTile(2, 0, new Tile(2, 1));
            splatter.SetTile(3, 0, new Tile(0, 1));

            TileMap map = new TileMap(tileset1, layer);

            map.AddTileset(tileset2);
            map.AddLayer(splatter);

            map.CollisionLayer.Collisions.Add(new Point(1, 0), CollisionType.Impassable);
            map.CollisionLayer.Collisions.Add(new Point(3, 0), CollisionType.Impassable);

            Level level = new Level(map);

            ChestData chestData = Game.Content.Load <ChestData>(@"Game\Chests\Plain Chest");
            Chest     chest     = new Chest(chestData);

            BaseSprite chestSprite = new BaseSprite(
                containers,
                new Rectangle(0, 0, 32, 32),
                new Point(10, 10));

            ItemSprite itemSprite = new ItemSprite(
                chest,
                chestSprite);

            level.Chests.Add(itemSprite);

            World world = new World(GameRef, GameRef.ScreenRectangle);

            world.Levels.Add(level);
            world.CurrentLevel = 0;

            AnimatedSprite s = new AnimatedSprite(
                GameRef.Content.Load <Texture2D>(@"SpriteSheets\Eliza"),
                AnimationManager.Instance.Animations);

            s.Position = new Vector2(5 * Engine.TileWidth, 5 * Engine.TileHeight);
            EntityData ed = new EntityData("Eliza", 10, 10, 10, 10, 10, 10, "20|CON|12", "16|WIL|16", "0 | 0 | 0");
            Entity     e  = new Entity("Eliza", ed, EntityGender.Female, EntityType.NPC);

            NonPlayerCharacter npc = new NonPlayerCharacter(e, s);

            npc.SetConversation("eliza1");

            world.Levels[world.CurrentLevel].Characters.Add(npc);

            GamePlayScreen.World = world;

            CreateConversation();
        }
Exemplo n.º 40
0
 private void createSprite()
 {
     sprite             = entity.addComponent(new AnimatedSprite <Animations>(_texture, default(Animations)));
     sprite.renderLayer = _renderLayer;
     sprite.flipX       = FlipX;
 }
 public NonPlayerCharacter(Entity entity, AnimatedSprite sprite)
     : base(entity, sprite)
 {
     quests = new List <Quest>();
 }
Exemplo n.º 42
0
        public override void Load()
        {
            int n = 10000;

            Console.WriteLine("-------------Greitaveikos tyrimas-----------------------");
            Console.WriteLine(n + " objektu");
            Console.WriteLine("--------------------------------------------------------");

            Stopwatch       stopwatch = new Stopwatch();
            ParticleFactory factory   = new ParticleFactory();

            stopwatch.Start();
            for (int i = 0; i < n; i++)
            {
                ParticleEmitter particleEmitter = null;
                particleEmitter = factory.Create("explosion") as ParticleEmitter;
            }
            stopwatch.Stop();
            Console.WriteLine("Su flyweight: " + stopwatch.ElapsedMilliseconds + " ms");
            Console.WriteLine("Total Memory: {0}", GC.GetTotalMemory(true));

            Stopwatch stopwatchNF = new Stopwatch();

            stopwatchNF.Start();
            for (int i = 0; i < n; i++)
            {
                ParticleEmitter particleEmitter = null;
                string          path            = "../../res/particles/";
                Image           image;
                image = Image.FromFile(path + "explosion_spritesheet.png");
                AnimatedSprite explosionSprite = new AnimatedSprite(image, new Vector2(), new Vector2(100, 100), 4, 4);
                FrameAnimation animation       = new FrameAnimation(1f, false, 0, 12);
                particleEmitter = new AnimatedParticleEmitter(16, explosionSprite, animation,
                                                              new ParticleProperties()
                {
                    startSize     = new Range(48, 84),
                    startAngle    = new Range(225f, 315f),
                    startLifetime = new Range(0.75f, 1.5f),
                    startSpeed    = new Range(100f, 400f),
                    sizeGrow      = -32,
                },
                                                              new ParticlesOneShotMode(),
                                                              true);
            }
            stopwatchNF.Stop();
            Console.WriteLine("--------------------------------------------------------");
            Console.WriteLine("Be flyweight: " + stopwatchNF.ElapsedMilliseconds + " ms");
            Console.WriteLine("Total Memory: {0}", GC.GetTotalMemory(true));
            Console.WriteLine("--------------------------------------------------------");

            //TankBuilder builder = new UsaTankBuilder(false);
            //Tank usaTank = builder.Build();
            //    /*new TankBuilder(true)
            //    .SetChassis(1, 1)
            //    .SetTurret(1)
            //    .SetTracks(0)
            //    .Build();*/
            //CreateEntity(usaTank);
            //usaTank.transform.SetPosition(new Vector2(500, 100));

            //usaTank.ApplyCamouflage(0);
            //usaTank.ApplySideskirt(0);
            //usaTank.ApplyAccessory(1);



            //explosion = new ParticleFactory().Create("explosion") as ParticleEmitter;
            //explosion.transform.SetPosition(usaTank.transform.position);
            //explosion2 = explosion.Clone();
            //explosion2.transform.SetPosition(usaTank.transform.position + new Vector2(200, 200));
        }
Exemplo n.º 43
0
        private void SetTextureFromAnimatedSprite(AnimatedSprite animatedSprite)
        {
            var currentAnimation = animatedSprite.Animation;

            Texture = animatedSprite.Frames.GetFrame(currentAnimation, animatedSprite.Frame);
        }
            private void HandleSpawning(Microsoft.Xna.Framework.GameTime gameTime)
            {
                if (Map.UnitDeploymentScreen.ListSelectedUnit.Count > 0)
                {
                    List <EventPoint> PlayerSpawnPoint = Map.ListSingleplayerSpawns;

                    if (AnimationSprite == null)
                    {
                        Unit CurrentUnit = Map.UnitDeploymentScreen.ListSelectedUnit[0];
                        Map.UnitDeploymentScreen.ListSelectedUnit.RemoveAt(0);

                        string SpawnTexturePath = "Spawn_strip4";

                        foreach (EventPoint Spawn in PlayerSpawnPoint)
                        {
                            if (Spawn.LeaderName == null)
                            {
                                Spawn.LeaderName = CurrentUnit.FullName;
                                AnimationSprite  = new AnimatedSprite(Map.Content, "Animations/Bitmap Animations/" + SpawnTexturePath,
                                                                      new Microsoft.Xna.Framework.Vector2((Spawn.Position.X - Map.CameraPosition.X) * Map.TileSize.X, (Spawn.Position.Y - Map.CameraPosition.Y) * Map.TileSize.Y),
                                                                      0.5f);

                                Microsoft.Xna.Framework.Vector3 FinalPosition;

                                Map.GetEmptyPosition(Spawn.Position, out FinalPosition);

                                Squad NewSquad = new Squad("", CurrentUnit);

                                Map.SpawnSquad(0, NewSquad, 0, FinalPosition);

                                Map.MovementAnimation.Add(Spawn.Position.X, Spawn.Position.Y, NewSquad);
                            }
                        }
                    }
                    else
                    {
                        AnimationSprite.Update(gameTime);
                        if (AnimationSprite.AnimationEnded)
                        {
                            AnimationSprite = null;
                        }
                    }

                    if (ActiveSound != null)
                    {
                        if (!ActiveSound.IsPlaying())
                        {
                            if (ActiveSound != null)
                            {
                                SoundSystem.ReleaseSound(ActiveSound);
                                ActiveSound = null;
                            }
                        }
                    }

                    //If a Unit is moving, wait until it finished moving before spawning the next unit
                    if (Map.MovementAnimation.Count > 0)
                    {
                        Map.MoveSquad();

                        if (Map.MovementAnimation.Count == 0)
                        {
                            AnimationSprite = null;
                        }
                    }
                }
                else
                {
                    ExecuteEvent(this, 0);
                    IsEnded = true;
                }
            }
Exemplo n.º 45
0
 public SundropNPC(AnimatedSprite sprite, Vector2 position, int facingDir, string name) : base(sprite, position, facingDir, name)
 {
 }
Exemplo n.º 46
0
        public override void Load()
        {
            #region Weapons

            ListShopEquipment.Add(new WeaponMenuEquipment("AWP", SniperRifle, 1, 150,
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/AWP Text"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/AWP Icon"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/AWP Full")));

            ListShopEquipment.Add(new WeaponMenuEquipment("Bubble Gun", MachineGun, 1, 150,
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/Bubble Gun Text"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/Bubble Gun Icon"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/Bubble Gun Full")));

            ListShopEquipment.Add(new WeaponMenuEquipment("Colt Python", Pistol, 1, 150,
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/Colt Python Text"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/Colt Python Icon"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/Colt Python Full")));

            ListShopEquipment.Add(new WeaponMenuEquipment("Dragunov", SniperRifle, 1, 150,
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/Dragunov Text"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/Dragunov Icon"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/Dragunov Full")));

            ListShopEquipment.Add(new WeaponMenuEquipment("F2000", MachineGun, 1, 150,
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/F2000 Text"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/F2000 Icon"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/F2000 Full")));

            ListShopEquipment.Add(new WeaponMenuEquipment("FAMAS", MachineGun, 1, 150,
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/FAMAS Text"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/FAMAS Icon"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/FAMAS Full")));

            ListShopEquipment.Add(new WeaponMenuEquipment("FN Five-seveN", Pistol, 1, 150,
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/FN Five-seveN Text"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/FN Five-seveN Icon"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/FN Five-seveN Full")));

            ListShopEquipment.Add(new WeaponMenuEquipment("FN Minimi", MachineGun, 1, 150,
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/FN Minimi Text"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/FN Minimi Icon"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/FN Minimi Full")));

            ListShopEquipment.Add(new WeaponMenuEquipment("FN P-90", SubMachineGun, 1, 150,
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/FN P-90 Text"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/FN P-90 Icon"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/FN P-90 Full")));

            ListShopEquipment.Add(new WeaponMenuEquipment("G3 SG1", SniperRifle, 1, 150,
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/G3 SG1 Text"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/G3 SG1 Icon"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/G3 SG1 Full")));

            ListShopEquipment.Add(new WeaponMenuEquipment("Glock 18C", Pistol, 1, 150,
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/Glock 18C Text"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/Glock 18C Icon"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/Glock 18C Full")));

            ListShopEquipment.Add(new WeaponMenuEquipment("GM94", Shotgun, 1, 150,
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/GM94 Text"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/GM94 Icon"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/GM94 Full")));

            ListShopEquipment.Add(new WeaponMenuEquipment("HK69A1", GrenadeLauncher, 1, 150,
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/HK69A1 Text"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/HK69A1 Icon"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/HK69A1 Full")));

            ListShopEquipment.Add(new WeaponMenuEquipment("IMI Uzi", SubMachineGun, 1, 150,
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/IMI Uzi Text"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/IMI Uzi Icon"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/IMI Uzi Full")));

            ListShopEquipment.Add(new WeaponMenuEquipment("Laser Gun", MachineGun, 1, 150,
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/Laser Gun Text"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/Laser Gun Icon"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/Laser Gun Full")));

            ListShopEquipment.Add(new WeaponMenuEquipment("M16A1", MachineGun, 1, 150,
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/M16A1 Text"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/M16A1 Icon"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/M16A1 Full")));

            ListShopEquipment.Add(new WeaponMenuEquipment("M16A2", MachineGun, 1, 150,
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/M16A2 Text"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/M16A2 Icon"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/M16A2 Full")));

            ListShopEquipment.Add(new WeaponMenuEquipment("M3", Shotgun, 1, 150,
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/M3 Text"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/M3 Icon"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/M3 Full")));

            ListShopEquipment.Add(new WeaponMenuEquipment("M60E4", MachineGun, 1, 150,
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/M60E4 Text"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/M60E4 Icon"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/M60E4 Full")));

            ListShopEquipment.Add(new WeaponMenuEquipment("MGL Mk 1", GrenadeLauncher, 1, 150,
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/MGL Mk 1 Text"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/MGL Mk 1 Icon"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/MGL Mk 1 Full")));

            ListShopEquipment.Add(new WeaponMenuEquipment("MP5", SubMachineGun, 1, 150,
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/MP5 Text"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/MP5 Icon"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/MP5 Full")));

            ListShopEquipment.Add(new WeaponMenuEquipment("MX1014", Shotgun, 1, 150,
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/MX1014 Text"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/MX1014 Icon"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/MX1014 Full")));

            ListShopEquipment.Add(new WeaponMenuEquipment("PSG-1", SniperRifle, 1, 150,
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/PSG-1 Text"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/PSG-1 Icon"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/PSG-1 Full")));

            ListShopEquipment.Add(new WeaponMenuEquipment("Skorpion", SubMachineGun, 1, 150,
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/Skorpion Text"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/Skorpion Icon"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/Skorpion Full")));

            ListShopEquipment.Add(new WeaponMenuEquipment("SPAS-12", Shotgun, 1, 150,
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/SPAS-12 Text"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/SPAS-12 Icon"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/SPAS-12 Full")));

            ListShopEquipment.Add(new WeaponMenuEquipment("Steyr AUG", SniperRifle, 1, 150,
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/Steyr AUG Text"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/Steyr AUG Icon"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/Steyr AUG Full")));

            ListShopEquipment.Add(new WeaponMenuEquipment("Type 14 Nambu", Pistol, 1, 150,
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/Type 14 Nambu Text"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/Type 14 Nambu Icon"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/Type 14 Nambu Full")));

            ListShopEquipment.Add(new WeaponMenuEquipment("USAS-12", Shotgun, 1, 150,
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/USAS-12 Text"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/USAS-12 Icon"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/USAS-12 Full")));

            ListShopEquipment.Add(new WeaponMenuEquipment("X-MAS Gun", Shotgun, 1, 150,
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/X-MAS Gun Text"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/X-MAS Gun Icon"),
                                                          Content.Load <Texture2D>("Triple Thunder/Menus/Shop/Weapons/X-MAS Gun Full")));

            #endregion

            #region Ressources

            sndButtonOver  = new FMODSound(FMODSystem, "Content/Triple Thunder/Menus/SFX/Button Over.wav");
            sndButtonClick = new FMODSound(FMODSystem, "Content/Triple Thunder/Menus/SFX/Button Click.wav");

            fntText = Content.Load <SpriteFont>("Fonts/Arial10");

            sprMyWeaponsBackground = Content.Load <Texture2D>("Triple Thunder/Menus/Shop/My Weapons Background");

            BuyWeaponIcon = new AnimatedSprite(Content, "Triple Thunder/Menus/Shop/Buy Weapon Icon", Vector2.Zero, 0, 1, 4);

            MyWeaponOutline = new AnimatedSprite(Content, "Triple Thunder/Menus/Shop/My Weapon Outline", Vector2.Zero, 0, 1, 4);
            MyWeaponOutline.SetFrame(2);

            WeaponShopScrollbar      = new Scrollbar(Content.Load <Texture2D>("Triple Thunder/Menus/Common/Scrollbar 1"), new Vector2(310, 120), 380, ListShopEquipment.Count - 6, OnWeaponShopScrollbarChange);
            WeaponInventoryScrollbar = new Scrollbar(Content.Load <Texture2D>("Triple Thunder/Menus/Common/Scrollbar 1"), new Vector2(528, 115), 448, 0, OnWeaponInventoryScrollbarChange);

            ArrayMenuButton = new IUIElement[]
            {
                WeaponShopScrollbar, WeaponInventoryScrollbar,
            };

            #endregion
        }
Exemplo n.º 47
0
 /****
 ** Helpers
 ****/
 /// <summary>Reload the texture for an animated sprite.</summary>
 /// <param name="sprite">The animated sprite to update.</param>
 /// <param name="texture">The texture to set.</param>
 private void SetSpriteTexture(AnimatedSprite sprite, Texture2D texture)
 {
     this.Reflection.GetField <Texture2D>(sprite, "spriteTexture").SetValue(texture);
 }
 public SmallRightIdleMarioYoshi(IPlayableObject playableObject)
 {
     this.playableObject = playableObject;
     sprite = AnimatedSpriteFactory.Instance.BuildSmallRightIdleMarioYoshiSprite(playableObject.Position);
     playableObject.CollisionRectangle = sprite.SpriteDestinationRectangle;
 }
Exemplo n.º 49
0
 public void SetSprite(string name)
 {
     currentSprite = name;
     sprite        = IoCManager.Resolve <IResourceCache>().GetAnimatedSprite(name);
 }
Exemplo n.º 50
0
 /// <summary>
 ///     Shorthand check for current animation id
 /// </summary>
 /// <param name="animatedSprite"></param>
 /// <param name="animationID"></param>
 /// <returns></returns>
 public static bool Is(this AnimatedSprite animatedSprite, string animationID)
 {
     return(animatedSprite.Animation == animationID);
 }
Exemplo n.º 51
0
 /// <summary>Animate the current sprite.</summary>
 /// <param name="gameTime">The game time from Monogames/XNA</param>
 /// <param name="startFrame">The starting frame of the animation on the sprite sheet.</param>
 /// <param name="numberOfFrames">The number of frames to animate the sprite.</param>
 /// <param name="interval">The delay between frames in milliseconds.</param>
 /// <param name="sprite">The animated sprite from the npc.</param>
 /// <param name="loop">If true, the animation plays over and over again.</param>
 public virtual bool Animate(GameTime gameTime, int startFrame, int numberOfFrames, float interval, AnimatedSprite sprite, bool loop = true)
 {
     if (sprite.CurrentFrame >= startFrame + numberOfFrames + 1 || sprite.CurrentFrame < startFrame)
     {
         sprite.CurrentFrame = startFrame + sprite.CurrentFrame % numberOfFrames;
     }
     sprite.timer = sprite.timer + (float)gameTime.ElapsedGameTime.TotalMilliseconds;
     if ((double)sprite.timer > (double)interval)
     {
         sprite.CurrentFrame = sprite.CurrentFrame + 1;
         sprite.timer        = 0.0f;
         if (sprite.CurrentFrame == startFrame + numberOfFrames + 1 || sprite.currentFrame * sprite.SpriteWidth >= sprite.Texture.Width)
         {
             if (loop)
             {
                 sprite.CurrentFrame = startFrame;
             }
             sprite.UpdateSourceRect();
             return(true);
         }
     }
     this.UpdateSourceRect(sprite);
     return(false);
 }
Exemplo n.º 52
0
 public SignPost(Vector2 Position)
 {
     this.sprite = new AnimatedSprite("SignPost", Position, new AnimationManager(SeasideScramble.self.textureUtils.getExtendedTexture("Entities", "SignPost"), new Animation(0, 0, 16, 16)), Color.White);
 }
Exemplo n.º 53
0
 public override void _Ready()
 {
     animatedSprite      = GetNode("FireAnimatedSprite") as AnimatedSprite;
     shootSound          = GetNode("ShootSound") as AudioStreamPlayer;
     shootSound.VolumeDb = DataManager.GetMasterVolume() * DataManager.GetEffectsVolume();
 }
Exemplo n.º 54
0
 // Called when the node enters the scene tree for the first time.
 public override void _Ready()
 {
     horizontalVelocity = new Vector2(speed, 0);
     sprite             = GetNode <AnimatedSprite>("Sprite");
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="path">Full path to asset.</param>
 /// <param name="currentFrame">Starting animation frame.</param>
 /// <param name="spriteWidth">Sprite width.</param>
 /// <param name="spriteHeight">Sprite height</param>
 public AnimatedSpriteExtended(string path, int currentFrame, int spriteWidth, int spriteHeight)
 {
     this.path   = Class1.getRelativeDirectory(path);
     this.sprite = new AnimatedSprite(Class1.ModHelper.Content.Load <Texture2D>(this.path), currentFrame, spriteWidth, spriteHeight);
 }
Exemplo n.º 56
0
 public Player(Game game, AnimatedSprite sprite)
 {
     gameRef     = (Game1)game;
     camera      = new Camera(gameRef.ScreenRectangle);
     this.sprite = sprite;
 }
Exemplo n.º 57
0
 public ExplosionInstance(Texture2D texture, Vector2 position)
 {
     Position        = position;
     _animatedSprite = new AnimatedSprite(texture, 64, 64, 0, 0, 16, 0.8f, false, SpriteEffects.None);
     _animatedSprite.Play();
 }
Exemplo n.º 58
0
            /// <summary>Removes any invalid monster types and/or settings from a list.</summary>
            /// <param name="monsterTypes">A list of monster type data.</param>
            /// <param name="areaID">The UniqueAreaID of the related SpawnArea. Required for log messages.</param>
            /// <returns>A new list of MonsterTypes with any invalid monster types and/or settings removed.</returns>
            public static List <MonsterType> ValidateMonsterTypes(List <MonsterType> monsterTypes, string areaID = "")
            {
                if (monsterTypes == null || monsterTypes.Count <= 0) //if the provided list is null or empty
                {
                    return(new List <MonsterType>());                //return an empty list
                }

                List <MonsterType> validTypes = Clone(monsterTypes); //create a new copy of the list, to be validated and returned

                for (int x = validTypes.Count - 1; x >= 0; x--)      //for each monster type in the new list (iterating backward to allow safe removal)
                {
                    //validate monster names
                    bool validName = false;

                    //NOTE: these switch cases are copied from SpawnMonster.cs; update them manually when new monsters are added
                    switch (validTypes[x].MonsterName.ToLower()) //avoid any casing issues by making this lower-case
                    {
                    case "bat":
                    case "frostbat":
                    case "frost bat":
                    case "lavabat":
                    case "lava bat":
                    case "iridiumbat":
                    case "iridium bat":
                    case "doll":
                    case "curseddoll":
                    case "cursed doll":
                    case "skull":
                    case "hauntedskull":
                    case "haunted skull":
                    case "magmasprite":
                    case "magma sprite":
                    case "magmasparker":
                    case "magma sparker":
                    case "bigslime":
                    case "big slime":
                    case "biggreenslime":
                    case "big green slime":
                    case "bigblueslime":
                    case "big blue slime":
                    case "bigfrostjelly":
                    case "big frost jelly":
                    case "bigredslime":
                    case "big red slime":
                    case "bigredsludge":
                    case "big red sludge":
                    case "bigpurpleslime":
                    case "big purple slime":
                    case "bigpurplesludge":
                    case "big purple sludge":
                    case "bluesquid":
                    case "blue squid":
                    case "bug":
                    case "armoredbug":
                    case "armored bug":
                    case "dino":
                    case "dinomonster":
                    case "dino monster":
                    case "pepper":
                    case "pepperrex":
                    case "pepper rex":
                    case "rex":
                    case "duggy":
                    case "magmaduggy":
                    case "magma duggy":
                    case "dust":
                    case "sprite":
                    case "dustsprite":
                    case "dust sprite":
                    case "spirit":
                    case "dustspirit":
                    case "dust spirit":
                    case "dwarvishsentry":
                    case "dwarvish sentry":
                    case "dwarvish":
                    case "sentry":
                    case "ghost":
                    case "carbonghost":
                    case "carbon ghost":
                    case "putridghost":
                    case "putrid ghost":
                    case "slime":
                    case "greenslime":
                    case "green slime":
                    case "blueslime":
                    case "blue slime":
                    case "frostjelly":
                    case "frost jelly":
                    case "redslime":
                    case "red slime":
                    case "redsludge":
                    case "red sludge":
                    case "purpleslime":
                    case "purple slime":
                    case "purplesludge":
                    case "purple sludge":
                    case "tigerslime":
                    case "tiger slime":
                    case "prismaticslime":
                    case "prismatic slime":
                    case "grub":
                    case "cavegrub":
                    case "cave grub":
                    case "fly":
                    case "cavefly":
                    case "cave fly":
                    case "mutantgrub":
                    case "mutant grub":
                    case "mutantfly":
                    case "mutant fly":
                    case "metalhead":
                    case "metal head":
                    case "hothead":
                    case "hot head":
                    case "lavalurk":
                    case "lava lurk":
                    case "leaper":
                    case "mummy":
                    case "rockcrab":
                    case "rock crab":
                    case "lavacrab":
                    case "lava crab":
                    case "iridiumcrab":
                    case "iridium crab":
                    case "falsemagmacap":
                    case "false magma cap":
                    case "stickbug":
                    case "stick bug":
                    case "magmacap":
                    case "magma cap":
                    case "rockgolem":
                    case "rock golem":
                    case "stonegolem":
                    case "stone golem":
                    case "wildernessgolem":
                    case "wilderness golem":
                    case "serpent":
                    case "royalserpent":
                    case "royal serpent":
                    case "brute":
                    case "shadowbrute":
                    case "shadow brute":
                    case "shaman":
                    case "shadowshaman":
                    case "shadow shaman":
                    case "sniper":
                    case "shadowsniper":
                    case "shadow sniper":
                    case "skeleton":
                    case "skeletonmage":
                    case "skeleton mage":
                    case "spiker":
                    case "squidkid":
                    case "squid kid":
                        validName = true;     //the name is valid
                        break;

                    default:                                                                             //if the name doesn't match any directly known monster types
                        Type externalType = GetTypeFromName(validTypes[x].MonsterName, typeof(Monster)); //find a monster subclass with a matching name
                        if (externalType != null)                                                        //if a matching type was found
                        {
                            if (externalType.GetConstructor(new[] { typeof(Vector2) }) != null)          //if this type has a constructor that takes a Vector2
                            {
                                validName = true;                                                        //the name is valid
                            }

                            /* NOTE: Accepting monsters' default constructors would be dangerous and is not recommended.
                             * Many monsters' defaults create them without filling game-critical fields, and this code can't reasonably account for them.
                             * The game will often freeze or crash if they are used here.
                             */
                        }
                        break;
                    }

                    if (!validName) //if the name is invalid
                    {
                        Monitor.Log($"A listed monster (\"{validTypes[x].MonsterName}\") doesn't match any known monster types. Make sure that name isn't misspelled in your config file.", LogLevel.Info);
                        Monitor.Log($"Affected spawn area: {areaID}", LogLevel.Info);

                        validTypes.RemoveAt(x); //remove this type from the valid list
                        continue;               //skip to the next monster type
                    }

                    if (validTypes[x].Settings == null)                             //if no settings were provided at all
                    {
                        validTypes[x].Settings = new Dictionary <string, object>(); //create a blank list of settings
                    }

                    //validate HP
                    if (validTypes[x].Settings.ContainsKey("HP"))
                    {
                        if (validTypes[x].Settings["HP"] is long) //if this is a readable integer
                        {
                            int HP = Convert.ToInt32(validTypes[x].Settings["HP"]);
                            if (HP < 1) //if the setting is too low
                            {
                                Monitor.Log($"The \"HP\" setting for monster type \"{validTypes[x].MonsterName}\" is {HP}. Setting it to 1.", LogLevel.Trace);
                                validTypes[x].Settings["HP"] = (long)1; //set the validated setting to 1
                            }
                        }
                        else //if this isn't a readable integer
                        {
                            Monitor.Log($"The \"HP\" setting for monster type \"{validTypes[x].MonsterName}\" couldn't be parsed. Please make sure it's an integer.", LogLevel.Info);
                            Monitor.Log($"Affected spawn area: {areaID}", LogLevel.Info);

                            validTypes[x].Settings.Remove("HP"); //remove the setting
                        }
                    }

                    //validate damage
                    if (validTypes[x].Settings.ContainsKey("Damage"))
                    {
                        if (validTypes[x].Settings["Damage"] is long) //if this is a readable integer
                        {
                            int damage = Convert.ToInt32(validTypes[x].Settings["Damage"]);
                            if (damage < 0) //if the setting is too low
                            {
                                Monitor.Log($"The \"Damage\" setting for monster type \"{validTypes[x].MonsterName}\" is {damage}. Setting it to 0.", LogLevel.Trace);
                                validTypes[x].Settings["Damage"] = (long)0; //set the validated setting to 0
                            }
                        }
                        else //if this isn't a readable integer
                        {
                            Monitor.Log($"The \"Damage\" setting for monster type \"{validTypes[x].MonsterName}\" couldn't be parsed. Please make sure it's an integer.", LogLevel.Info);
                            Monitor.Log($"Affected spawn area: {areaID}", LogLevel.Info);

                            validTypes[x].Settings.Remove("Damage"); //remove the setting
                        }
                    }

                    //validate defense
                    if (validTypes[x].Settings.ContainsKey("Defense"))
                    {
                        if (validTypes[x].Settings["Defense"] is long) //if this is a readable integer
                        {
                            int defense = Convert.ToInt32(validTypes[x].Settings["Defense"]);
                            if (defense < 0) //if the setting is too low
                            {
                                Monitor.Log($"The \"Defense\" setting for monster type \"{validTypes[x].MonsterName}\" is {defense}. Setting it to 0.", LogLevel.Trace);
                                validTypes[x].Settings["Defense"] = (long)0; //set the validated setting to 1
                            }
                        }
                        else //if this isn't a readable integer
                        {
                            Monitor.Log($"The \"Defense\" setting for monster type \"{validTypes[x].MonsterName}\" couldn't be parsed. Please make sure it's an integer.", LogLevel.Info);
                            Monitor.Log($"Affected spawn area: {areaID}", LogLevel.Info);

                            validTypes[x].Settings.Remove("Defense"); //remove the setting
                        }
                    }

                    //validate dodge chance
                    if (validTypes[x].Settings.ContainsKey("DodgeChance"))
                    {
                        if (validTypes[x].Settings["DodgeChance"] is long) //if this is a readable integer
                        {
                            int dodge = Convert.ToInt32(validTypes[x].Settings["DodgeChance"]);
                            if (dodge < 1) //if the setting is too low
                            {
                                Monitor.Log($"The \"DodgeChance\" setting for monster type \"{validTypes[x].MonsterName}\" is {dodge}. Setting it to 1.", LogLevel.Trace);
                                validTypes[x].Settings["DodgeChance"] = (long)1; //set the validated setting to 1
                            }
                        }
                        else //if this isn't a readable integer
                        {
                            Monitor.Log($"The \"DodgeChance\" setting for monster type \"{validTypes[x].MonsterName}\" couldn't be parsed. Please make sure it's an integer.", LogLevel.Info);
                            Monitor.Log($"Affected spawn area: {areaID}", LogLevel.Info);

                            validTypes[x].Settings.Remove("DodgeChance"); //remove the setting
                        }
                    }

                    //validate experience points
                    if (validTypes[x].Settings.ContainsKey("EXP"))
                    {
                        if (validTypes[x].Settings["EXP"] is long) //if this is a readable integer
                        {
                            int exp = Convert.ToInt32(validTypes[x].Settings["EXP"]);
                            if (exp < 0) //if the setting is too low
                            {
                                Monitor.Log($"The \"EXP\" setting for monster type \"{validTypes[x].MonsterName}\" is {exp}. Setting it to 0.", LogLevel.Trace);
                                validTypes[x].Settings["EXP"] = (long)0; //set the validated setting to 0
                            }
                        }
                        else //if this isn't a readable integer
                        {
                            Monitor.Log($"The \"EXP\" setting for monster type \"{validTypes[x].MonsterName}\" couldn't be parsed. Please make sure it's an integer.", LogLevel.Info);
                            Monitor.Log($"Affected spawn area: {areaID}", LogLevel.Info);

                            validTypes[x].Settings.Remove("EXP"); //remove the setting
                        }
                    }

                    //validate the related skill setting
                    if (validTypes[x].Settings.ContainsKey("RelatedSkill"))
                    {
                        if (validTypes[x].Settings["RelatedSkill"] is string)                                        //if this is a readable string
                        {
                            string relatedSkill = ((string)validTypes[x].Settings["RelatedSkill"]).Trim().ToLower(); //parse the provided skill, trim whitespace, and lower case
                            bool   isSkill      = false;

                            foreach (string skill in Enum.GetNames(typeof(Skills)))          //for each known in-game skill
                            {
                                if (relatedSkill.Trim().ToLower() == skill.Trim().ToLower()) //if the provided skill name matches this known skill
                                {
                                    isSkill = true;                                          //the provided skill is valid
                                }
                            }

                            if (!isSkill) //if this isn't a known skill
                            {
                                Monitor.Log($"The \"RelatedSkill\" setting for monster type \"{validTypes[x].MonsterName}\" doesn't seem to be a known skill. Please make sure it's spelled correctly.", LogLevel.Info);
                                Monitor.Log($"Affected spawn area: {areaID}", LogLevel.Info);

                                validTypes[x].Settings.Remove("RelatedSkill"); //remove the setting
                            }
                        }
                        else //if this isn't a readable string
                        {
                            Monitor.Log($"The \"RelatedSkill\" setting for monster type \"{validTypes[x].MonsterName}\" couldn't be parsed. Please make sure it's a valid string (text inside quotation marks).", LogLevel.Info);
                            Monitor.Log($"Affected spawn area: {areaID}", LogLevel.Info);

                            validTypes[x].Settings.Remove("RelatedSkill"); //remove the setting
                        }
                    }

                    //validate minimum skill requirement
                    if (validTypes[x].Settings.ContainsKey("MinimumSkillLevel"))
                    {
                        if (validTypes[x].Settings["MinimumSkillLevel"] is long)    //if this is a readable integer
                        {
                            if (validTypes[x].Settings.ContainsKey("RelatedSkill")) //if a RelatedSkill has been provided
                            {
                                int required          = Convert.ToInt32(validTypes[x].Settings["MinimumSkillLevel"]);
                                int highestSkillLevel = 0;                                                                      //highest skill level among all existing farmers (not just the host)
                                Enum.TryParse((string)validTypes[x].Settings["RelatedSkill"], true, out Skills skill);          //parse the RelatedSkill setting into an enum (note: the setting should be validated earlier in this method)

                                foreach (Farmer farmer in Game1.getAllFarmers())                                                //for each farmer
                                {
                                    highestSkillLevel = Math.Max(highestSkillLevel, farmer.getEffectiveSkillLevel((int)skill)); //record the farmer's skill level if it's higher than before
                                }

                                if (required > highestSkillLevel) //if the skill requirement is higher than the farmers' highest skill
                                {
                                    Monitor.VerboseLog($"Skipping monster type \"{validTypes[x].MonsterName}\" in spawn area \"{areaID}\" due to minimum skill level.");
                                    validTypes.RemoveAt(x); //remove this type from the valid list
                                    continue;               //skip to the next monster type
                                }
                            }
                            else //if a RelatedSkill was not provided
                            {
                                Monitor.Log($"Monster type \"{validTypes[x].MonsterName}\" has a valid setting for \"MinimumSkillLevel\" but not \"RelatedSkill\". The requirement will be skipped.", LogLevel.Info);
                                Monitor.Log($"Affected spawn area: {areaID}", LogLevel.Info);

                                validTypes[x].Settings.Remove("MinimumSkillLevel"); //remove the setting
                            }
                        }
                        else //if this isn't a readable integer
                        {
                            Monitor.Log($"The \"MinimumSkillLevel\" setting for monster type \"{validTypes[x].MonsterName}\" couldn't be parsed. Please make sure it's an integer.", LogLevel.Info);
                            Monitor.Log($"Affected spawn area: {areaID}", LogLevel.Info);

                            validTypes[x].Settings.Remove("MinimumSkillLevel"); //remove the setting
                        }
                    }

                    //validate maximum skill requirement
                    if (validTypes[x].Settings.ContainsKey("MaximumSkillLevel"))
                    {
                        if (validTypes[x].Settings["MaximumSkillLevel"] is long)    //if this is a readable integer
                        {
                            if (validTypes[x].Settings.ContainsKey("RelatedSkill")) //if a RelatedSkill has been provided
                            {
                                int required          = Convert.ToInt32(validTypes[x].Settings["MaximumSkillLevel"]);
                                int highestSkillLevel = 0;                                                                      //highest skill level among all existing farmers (not just the host)
                                Enum.TryParse((string)validTypes[x].Settings["RelatedSkill"], true, out Skills skill);          //parse the RelatedSkill setting into an enum (note: the setting should be validated earlier in this method)

                                foreach (Farmer farmer in Game1.getAllFarmers())                                                //for each farmer
                                {
                                    highestSkillLevel = Math.Max(highestSkillLevel, farmer.getEffectiveSkillLevel((int)skill)); //record the farmer's skill level if it's higher than before
                                }

                                if (required < highestSkillLevel) //if the skill requirement is lower than the farmers' highest skill
                                {
                                    Monitor.VerboseLog($"Skipping monster type \"{validTypes[x].MonsterName}\" in spawn area \"{areaID}\" due to maximum skill level.");
                                    validTypes.RemoveAt(x); //remove this type from the valid list
                                    continue;               //skip to the next monster type
                                }
                            }
                            else //if a RelatedSkill was not provided
                            {
                                Monitor.Log($"Monster type \"{validTypes[x].MonsterName}\" has a valid setting for \"MaximumSkillLevel\" but not \"RelatedSkill\". The requirement will be skipped.", LogLevel.Info);
                                Monitor.Log($"Affected spawn area: {areaID}", LogLevel.Info);

                                validTypes[x].Settings.Remove("MaximumSkillLevel"); //remove the setting
                            }
                        }
                        else //if this isn't a readable integer
                        {
                            Monitor.Log($"The \"MaximumSkillLevel\" setting for monster type \"{validTypes[x].MonsterName}\" couldn't be parsed. Please make sure it's an integer.", LogLevel.Info);
                            Monitor.Log($"Affected spawn area: {areaID}", LogLevel.Info);

                            validTypes[x].Settings.Remove("MaximumSkillLevel"); //remove the setting
                        }
                    }

                    //validate HP multiplier
                    if (validTypes[x].Settings.ContainsKey("PercentExtraHPPerSkillLevel"))
                    {
                        if (!(validTypes[x].Settings["PercentExtraHPPerSkillLevel"] is long)) //if this isn't a readable integer
                        {
                            Monitor.Log($"The \"PercentExtraHPPerSkillLevel\" setting for monster type \"{validTypes[x].MonsterName}\" couldn't be parsed. Please make sure it's an integer.", LogLevel.Info);
                            Monitor.Log($"Affected spawn area: {areaID}", LogLevel.Info);

                            validTypes[x].Settings.Remove("PercentExtraHPPerSkillLevel"); //remove the setting
                        }
                    }

                    //validate damage multiplier
                    if (validTypes[x].Settings.ContainsKey("PercentExtraDamagePerSkillLevel"))
                    {
                        if (!(validTypes[x].Settings["PercentExtraDamagePerSkillLevel"] is long)) //if this isn't a readable integer
                        {
                            Monitor.Log($"The \"PercentExtraDamagePerSkillLevel\" setting for monster type \"{validTypes[x].MonsterName}\" couldn't be parsed. Please make sure it's an integer.", LogLevel.Info);
                            Monitor.Log($"Affected spawn area: {areaID}", LogLevel.Info);

                            validTypes[x].Settings.Remove("PercentExtraDamagePerSkillLevel"); //remove the setting
                        }
                    }

                    //validate defense multiplier
                    if (validTypes[x].Settings.ContainsKey("PercentExtraDefensePerSkillLevel"))
                    {
                        if (!(validTypes[x].Settings["PercentExtraDefensePerSkillLevel"] is long)) //if this isn't a readable integer
                        {
                            Monitor.Log($"The \"PercentExtraDefensePerSkillLevel\" setting for monster type \"{validTypes[x].MonsterName}\" couldn't be parsed. Please make sure it's an integer.", LogLevel.Info);
                            Monitor.Log($"Affected spawn area: {areaID}", LogLevel.Info);

                            validTypes[x].Settings.Remove("PercentExtraDefensePerSkillLevel"); //remove the setting
                        }
                    }

                    //validate dodge chance multiplier
                    if (validTypes[x].Settings.ContainsKey("PercentExtraDodgeChancePerSkillLevel"))
                    {
                        if (!(validTypes[x].Settings["PercentExtraDodgeChancePerSkillLevel"] is long)) //if this isn't a readable integer
                        {
                            Monitor.Log($"The \"PercentExtraDodgeChancePerSkillLevel\" setting for monster type \"{validTypes[x].MonsterName}\" couldn't be parsed. Please make sure it's an integer.", LogLevel.Info);
                            Monitor.Log($"Affected spawn area: {areaID}", LogLevel.Info);

                            validTypes[x].Settings.Remove("PercentExtraDodgeChancePerSkillLevel"); //remove the setting
                        }
                    }

                    //validate experience multiplier
                    if (validTypes[x].Settings.ContainsKey("PercentExtraEXPPerSkillLevel"))
                    {
                        if (!(validTypes[x].Settings["PercentExtraEXPPerSkillLevel"] is long)) //if this isn't a readable integer
                        {
                            Monitor.Log($"The \"PercentExtraEXPPerSkillLevel\" setting for monster type \"{validTypes[x].MonsterName}\" couldn't be parsed. Please make sure it's an integer.", LogLevel.Info);
                            Monitor.Log($"Affected spawn area: {areaID}", LogLevel.Info);

                            validTypes[x].Settings.Remove("PercentExtraEXPPerSkillLevel"); //remove the setting
                        }
                    }

                    //validate loot and parse the provided objects into IDs
                    if (validTypes[x].Settings.ContainsKey("Loot"))
                    {
                        List <object> rawList = null;

                        try
                        {
                            rawList = ((JArray)validTypes[x].Settings["Loot"]).ToObject <List <object> >(); //cast this list to catch formatting/coding errors
                        }
                        catch (Exception)
                        {
                            Monitor.Log($"The \"Loot\" setting for monster type \"{validTypes[x].MonsterName}\" couldn't be parsed. Please make sure it's a correctly formatted list.", LogLevel.Info);
                            Monitor.Log($"Affected spawn area: {areaID}", LogLevel.Info);

                            validTypes[x].Settings.Remove("Loot"); //remove the setting
                        }

                        if (validTypes[x].Settings.ContainsKey("Loot"))                    //if no exception happened
                        {
                            if (rawList == null)                                           //if a null list was provided
                            {
                                validTypes[x].Settings["Loot"] = new List <SavedObject>(); //use an empty list
                            }
                            else //if an actual list was provided
                            {
                                List <SavedObject> lootList = ParseSavedObjectsFromItemList(rawList, areaID); //parse the object list into a SavedObject list

                                foreach (SavedObject loot in lootList)
                                {
                                    //convert any "object" categories to "item" for the loot list
                                    string category = loot.ConfigItem?.Category?.ToLower();
                                    if (category == "object" || category == "objects")
                                    {
                                        loot.ConfigItem.Category = "item";
                                    }
                                }

                                validTypes[x].Settings["Loot"] = lootList;
                            }
                        }
                    }

                    //validate persistent HP
                    if (validTypes[x].Settings.ContainsKey("PersistentHP"))
                    {
                        if (!(validTypes[x].Settings["PersistentHP"] is bool)) //if this is NOT a readable boolean
                        {
                            Monitor.Log($"The \"PersistentHP\" setting for monster type \"{validTypes[x].MonsterName}\" couldn't be parsed. Please make sure it's true or false (without quotation marks).", LogLevel.Info);
                            Monitor.Log($"Affected spawn area: {areaID}", LogLevel.Info);

                            validTypes[x].Settings.Remove("PersistentHP"); //remove the setting
                        }
                    }

                    //validate current HP
                    if (validTypes[x].Settings.ContainsKey("CurrentHP"))
                    {
                        if (validTypes[x].Settings["CurrentHP"] is long) //if this is a readable integer
                        {
                            int currentHP = Convert.ToInt32(validTypes[x].Settings["CurrentHP"]);
                            if (currentHP < 1) //if the current HP setting is too low
                            {
                                Monitor.Log($"The \"CurrentHP\" setting for monster type \"{validTypes[x].MonsterName}\" is {currentHP}. Setting it to 1.", LogLevel.Trace);
                                monsterTypes[x].Settings["CurrentHP"] = (long)1; //set the original provided setting to 1
                                validTypes[x].Settings["CurrentHP"]   = (long)1; //set the validated setting to 1
                            }
                        }
                        else //if this isn't a readable integer
                        {
                            Monitor.Log($"The \"CurrentHP\" setting for monster type \"{validTypes[x].MonsterName}\" couldn't be parsed. Please make sure it's an integer.", LogLevel.Info);
                            Monitor.Log($"Affected spawn area: {areaID}", LogLevel.Info);

                            validTypes[x].Settings.Remove("CurrentHP"); //remove the setting
                        }
                    }

                    //validate seeing players at spawn
                    if (validTypes[x].Settings.ContainsKey("SeesPlayersAtSpawn"))
                    {
                        if (!(validTypes[x].Settings["SeesPlayersAtSpawn"] is bool)) //if this is NOT a readable boolean
                        {
                            Monitor.Log($"The \"SeesPlayersAtSpawn\" setting for monster type \"{validTypes[x].MonsterName}\" couldn't be parsed. Please make sure it's true or false (without quotation marks).", LogLevel.Info);
                            Monitor.Log($"Affected spawn area: {areaID}", LogLevel.Info);

                            validTypes[x].Settings.Remove("SeesPlayersAtSpawn"); //remove the setting
                        }
                    }

                    //validate color
                    if (validTypes[x].Settings.ContainsKey("Color")) //if color was provided
                    {
                        //try a trimmed copy of the color application code
                        try
                        {
                            string[]   colorText    = ((string)validTypes[x].Settings["Color"]).Trim().Split(' '); //split the color string into strings for each number
                            List <int> colorNumbers = new List <int>();
                            foreach (string text in colorText)                                                     //for each string
                            {
                                int num = Convert.ToInt32(text);                                                   //convert it to a number
                                if (num < 0)
                                {
                                    num = 0;
                                }                         //minimum 0
                                else if (num > 255)
                                {
                                    num = 255;
                                }                      //maximum 255
                                colorNumbers.Add(num); //add it to the list
                            }

                            //convert strings into RGBA values
                            int r = Convert.ToInt32(colorNumbers[0]);
                            int g = Convert.ToInt32(colorNumbers[1]);
                            int b = Convert.ToInt32(colorNumbers[2]);
                            int a;
                            if (colorNumbers.Count > 3) //if the setting included an "A" value
                            {
                                a = Convert.ToInt32(colorNumbers[3]);
                            }
                        }
                        catch (Exception)
                        {
                            Monitor.Log($"The \"Color\" setting for monster type \"{validTypes[x].MonsterName}\" couldn't be parsed. Please make sure it follows the correct format, e.g. \"255 255 255\" or \"255 255 255 255\".", LogLevel.Info);
                            Monitor.Log($"Affected spawn area: {areaID}", LogLevel.Info);

                            validTypes[x].Settings.Remove("Color"); //remove the setting
                        }
                    }
                    else if (validTypes[x].Settings.ContainsKey("MinColor") && validTypes[x].Settings.ContainsKey("MaxColor")) //if color wasn't provided, but mincolor & maxcolor were
                    {
                        //try a trimmed copy of the min/max color application code
                        try
                        {
                            string[]   minColorText    = ((string)validTypes[x].Settings["MinColor"]).Trim().Split(' '); //split the setting string into strings for each number
                            List <int> minColorNumbers = new List <int>();
                            foreach (string text in minColorText)                                                        //for each string
                            {
                                int num = Convert.ToInt32(text);                                                         //convert it to a number
                                if (num < 0)
                                {
                                    num = 0;
                                }                         //minimum 0
                                else if (num > 255)
                                {
                                    num = 255;
                                }                         //maximum 255
                                minColorNumbers.Add(num); //add it to the list
                            }

                            string[]   maxColorText    = ((string)validTypes[x].Settings["MaxColor"]).Trim().Split(' '); //split the setting string into strings for each number
                            List <int> maxColorNumbers = new List <int>();
                            foreach (string text in maxColorText)                                                        //for each string
                            {
                                int num = Convert.ToInt32(text);                                                         //convert it to a number
                                if (num < 0)
                                {
                                    num = 0;
                                }                         //minimum 0
                                else if (num > 255)
                                {
                                    num = 255;
                                }                         //maximum 255
                                maxColorNumbers.Add(num); //convert to number
                            }
                        }
                        catch (Exception)
                        {
                            Monitor.Log($"The \"MinColor\" and/or \"MaxColor\" settings for monster type \"{validTypes[x].MonsterName}\" couldn't be parsed. Please make sure they follow the correct format, e.g. \"255 255 255\".", LogLevel.Info);
                            Monitor.Log($"Affected spawn area: {areaID}", LogLevel.Info);

                            //remove the settings
                            validTypes[x].Settings.Remove("MinColor");
                            validTypes[x].Settings.Remove("MaxColor");
                        }
                    }

                    //validate sprite
                    if (validTypes[x].Settings.ContainsKey("Sprite"))
                    {
                        if (validTypes[x].Settings["Sprite"] is string spriteText) //if this is a readable string
                        {
                            try
                            {
                                AnimatedSprite sprite = new AnimatedSprite(spriteText);
                            }
                            catch (Exception)
                            {
                                Monitor.Log($"The \"Sprite\" setting for monster type \"{validTypes[x].MonsterName}\" failed to load. Please make sure the setting is spelled correctly.", LogLevel.Info);
                                Monitor.Log($"Affected spawn area: {areaID}", LogLevel.Info);

                                validTypes[x].Settings.Remove("Sprite"); //remove the setting
                            }
                        }
                        else //if this is NOT a readable string
                        {
                            Monitor.Log($"The \"Sprite\" setting for monster type \"{validTypes[x].MonsterName}\" couldn't be parsed. Please make sure it's a valid string (text inside quotation marks).", LogLevel.Info);
                            Monitor.Log($"Affected spawn area: {areaID}", LogLevel.Info);

                            validTypes[x].Settings.Remove("Sprite"); //remove the setting
                        }
                    }

                    //validate spawn weight
                    if (validTypes[x].Settings.ContainsKey("SpawnWeight"))
                    {
                        if (validTypes[x].Settings["SpawnWeight"] is long) //if this is a readable integer
                        {
                            int weight = Convert.ToInt32(validTypes[x].Settings["SpawnWeight"]);
                            if (weight < 1) //if the setting is too low
                            {
                                Monitor.Log($"The \"SpawnWeight\" setting for monster type \"{validTypes[x].MonsterName}\" is {weight} and will be ignored. Please use a number above 0.", LogLevel.Trace);
                                validTypes[x].Settings["SpawnWeight"] = (long)1; //set to 1
                            }
                        }
                        else //if this isn't a readable integer
                        {
                            Monitor.Log($"The \"SpawnWeight\" setting for monster type \"{validTypes[x].MonsterName}\" couldn't be parsed. Please make sure it's an integer.", LogLevel.Info);
                            Monitor.Log($"Affected spawn area: {areaID}", LogLevel.Info);

                            validTypes[x].Settings.Remove("SpawnWeight"); //remove the setting
                        }
                    }

                    //validate facing direction
                    if (validTypes[x].Settings.ContainsKey("FacingDirection"))
                    {
                        if (validTypes[x].Settings["FacingDirection"] is string direction) //if this is a string
                        {
                            switch (direction.Trim().ToLower())
                            {
                            case "up":
                            case "right":
                            case "down":
                            case "left":
                                break;

                            default:
                                Monitor.Log($"The \"FacingDirection\" setting for monster type \"{validTypes[x].MonsterName}\" was not recognized and will be ignored: \"{direction}\".", LogLevel.Info);
                                Monitor.Log($"Affected spawn area: {areaID}", LogLevel.Info);
                                validTypes[x].Settings.Remove("FacingDirection");     //remove the setting
                                break;
                            }
                        }
                        else //if this is NOT a string
                        {
                            Monitor.Log($"The \"FacingDirection\" setting for monster type \"{validTypes[x].MonsterName}\" couldn't be parsed. Please make sure it's a string.", LogLevel.Info);
                            Monitor.Log($"Affected spawn area: {areaID}", LogLevel.Info);

                            validTypes[x].Settings.Remove("FacingDirection"); //remove the setting
                        }
                    }

                    //validate segments
                    if (validTypes[x].Settings.ContainsKey("Segments"))
                    {
                        if (validTypes[x].Settings["Segments"] is long) //if this is a readable integer
                        {
                            //do nothing; minimum values will vary between monster types
                        }
                        else //if this isn't a readable integer
                        {
                            Monitor.Log($"The \"Segments\" setting for monster type \"{validTypes[x].MonsterName}\" couldn't be parsed. Please make sure it's an integer.", LogLevel.Info);
                            Monitor.Log($"Affected spawn area: {areaID}", LogLevel.Info);

                            validTypes[x].Settings.Remove("Segments"); //remove the setting
                        }
                    }
                }

                return(validTypes);
            }
Exemplo n.º 59
0
        public override Entity Create(EntityCreateArgs args)
        {
            //System.Console.WriteLine($"FACTORY ParticleFactory: Create()");
            ParticleEmitter particleEmitter = null;
            string          path            = "../../res/particles/";
            Image           image;

            string particleType = args.type.ToLower();

            if (cache.ContainsKey(particleType))
            {
                return(cache[particleType]);
            }
            else
            {
                switch (args.type.ToLower())
                {
                case "explosion":
                    System.Console.WriteLine($"\tCreating Explosion");
                    image = Image.FromFile(path + "explosion_spritesheet.png");
                    AnimatedSprite explosionSprite = new AnimatedSprite(image, new Vector2(), new Vector2(100, 100), 4, 4);
                    FrameAnimation animation       = new FrameAnimation(1f, false, 0, 12);
                    particleEmitter = new AnimatedParticleEmitter(16, explosionSprite, animation,
                                                                  new ParticleProperties()
                    {
                        startSize     = new Range(48, 84),
                        startAngle    = new Range(225f, 315f),
                        startLifetime = new Range(0.75f, 1.5f),
                        startSpeed    = new Range(100f, 400f),
                        sizeGrow      = -32,
                    },
                                                                  new ParticlesOneShotMode(),
                                                                  true);
                    break;

                case "shield":
                    System.Console.WriteLine($"\tCreating Shield");
                    image = Image.FromFile(path + "shield_particle.png");
                    Sprite shieldSprite = new Sprite(image, new Vector2(), new Vector2(100, 100));
                    particleEmitter = new ParticleEmitter(5, shieldSprite, new ParticleProperties()
                    {
                        startSize     = 128f,
                        sizeGrow      = -128f,
                        spawnRate     = 0.4f,
                        startLifetime = 1f
                    }, new ParticlesContinuousMode());
                    break;

                case "health":
                    System.Console.WriteLine($"\tCreating Health");
                    image = Image.FromFile(path + "health_particle.png");
                    Sprite healthSprite = new Sprite(image, new Vector2(), new Vector2(100, 100));
                    particleEmitter = new ParticleEmitter(8, healthSprite, new ParticleProperties()
                    {
                        startSpeed    = 700f,
                        speedDamping  = 0.7f,
                        startOffset   = new Vector2(20f, 0f),
                        startSize     = 64f,
                        sizeGrow      = -64f,
                        spawnRate     = 0.2f,
                        startAngle    = 270f,
                        startLifetime = 0.5f
                    }, new ParticlesContinuousMode());
                    break;

                default:
                    return(null);
                }
                cache.Add(particleType, particleEmitter);
            }

            return(SceneManager.Instance.CurrentScene.CreateEntity(particleEmitter));
        }
Exemplo n.º 60
0
 public override void reloadSprite()
 {
     Sprite = new AnimatedSprite("Characters\\Monsters\\Shadow Shaman");
 }