示例#1
0
        public void Init()
        {
            TextureData textureData = ResourceManager.GetTextureData(TextureName);

            if (textureData == null)
            {
                throw new Exception("Texture data '" + TextureName + "' does not exist for sprite '" + Name + "'");
            }
            if (Width <= 0)
            {
                Width = textureData.Width;
                if (OriginX <= 0)
                {
                    OriginX = (int)textureData.OriginX;
                }
            }
            if (Height <= 0)
            {
                Height = textureData.Height;
                if (OriginY <= 0)
                {
                    OriginY = (int)textureData.OriginY;
                }
            }
            populateAnimationsFromAnimationData();
        }
        private void drawMap(Renderer renderer)
        {
            TileData    testTile        = Area.Data.OverworldTileTextureNamesToList()[0];
            TextureData testTextureData = ResourceManager.GetTextureData(testTile.TextureDataName);
            //TextureData pixelTexture = ResourceManager.GetTextureData("white_pixel");

            Rectangle cameraBoundingBox = camera.GetBoundingBox();
            int       startX            = Math.Max((cameraBoundingBox.Left / Map.TileSize) - 1, 0);
            int       finishX           = Math.Min(((cameraBoundingBox.Left + cameraBoundingBox.Width) / Map.TileSize) + 2, Map.TileWidth - 1);
            int       startY            = Math.Max((cameraBoundingBox.Top / Map.TileSize) - 1, 0);
            int       finishY           = Math.Min(((cameraBoundingBox.Top + cameraBoundingBox.Height) / Map.TileSize) + 2, Map.TileHeight - 1);

            /*for (int x = startX; x <= finishX; ++x)
             * {
             *  for (int y = startY; y <= finishY; ++y)
             *  {
             *      if (Map.CollisionMap[x, y])
             *          renderer.Draw(pixelTexture, new Vector2(x, y) * Map.TileSize, Color.Black * 0.5f, 0.0f, new Vector2(Map.TileSize));
             *  }
             * }*/

            for (int x = startX; x <= finishX; ++x)
            {
                for (int y = startY; y <= finishY; ++y)
                {
                    if (Map.CollisionMap[x, y])// && x % 2 == 0 && y % 2 == 0)
                    {
                        renderer.Draw(testTextureData, new Vector2(x, y) * Map.TileSize, Color.White);
                    }
                }
            }
        }
示例#3
0
        public Battle(Party playerParty, Party enemyParty, Encounter overworldEncounter)
        {
            if (playerParty == null)
            {
                throw new Exception("Party playerParty cannot be null");
            }
            if (enemyParty == null)
            {
                throw new Exception("Party enemyParty cannot be null");
            }

            PlayerParty = playerParty.Tap(party => party.StartBattle(this));
            EnemyParty  = enemyParty.Tap(party => party.StartBattle(this));

            states = new Stack <BattleState>();
            states.Push(new BattleStates.Intro(this));
            stateChanged = true;

            OverworldEncounter = overworldEncounter;

            Camera            = new Camera(Game1.ScreenSize);
            Camera.Position   = Camera.Size / 2.0f;
            cameraUpdateDelay = 0.0f;

            RepositionPartyMembers();
            updateCamera();
            Camera.Scale = Camera.TargetScale;
            updateCamera();
            Camera.Position = Camera.TargetPosition;

            generateBackground();
            generateBackgroundScenery();
            generateFloorScenery();

            whitePixelTextureData         = ResourceManager.GetTextureData("white_pixel");
            arrowTextureData              = ResourceManager.GetTextureData("arrow_down");
            CharacterClassHeadTextureData = new Dictionary <CharacterClass, TextureData> {
                { CharacterClass.Warrior, ResourceManager.GetTextureData("battle_ui/warrior_head") },
                { CharacterClass.Marksman, ResourceManager.GetTextureData("battle_ui/marksman_head") },
                { CharacterClass.Medic, ResourceManager.GetTextureData("battle_ui/medic_head") },
                { CharacterClass.Thief, ResourceManager.GetTextureData("battle_ui/thief_head") }
            };
            keyboardButtonTextureData = ResourceManager.GetTextureData("battle_ui/buttons/key");
            gamepadButtonTextureData  = new Dictionary <InputButton, TextureData> {
                { InputButton.A, ResourceManager.GetTextureData("battle_ui/buttons/gamepad_a") },
                { InputButton.B, ResourceManager.GetTextureData("battle_ui/buttons/gamepad_b") },
                { InputButton.LeftTrigger, ResourceManager.GetTextureData("battle_ui/buttons/gamepad_lt") }
            };

            BorderTextureData = new TextureData[Directions.Length];
            for (int i = 0; i < Directions.Length; ++i)
            {
                BorderTextureData[i] = ResourceManager.GetTextureData("battle_ui/borders/" + Directions[i]);
            }

            PlayerPartyItemsUsed     = 0;
            LastUsedThinkActionTypes = new ConditionalWeakTable <PartyMember, Wrapper <BattleStates.ThinkActionType> >();
        }
示例#4
0
 public Item(ItemData itemData)
 {
     if (itemData == null)
     {
         throw new Exception("ItemData cannot be null");
     }
     Data        = itemData;
     TextureData = ResourceManager.GetTextureData(Data.TextureName);
 }
示例#5
0
 public Weapon(WeaponData weaponData, string fullName)
     : base(fullName)
 {
     if (weaponData == null)
     {
         throw new Exception("WeaponData cannot be null");
     }
     Data        = weaponData;
     TextureData = ResourceManager.GetTextureData(Data.TextureName);
 }
示例#6
0
 public Shield(ShieldData shieldData, string fullName)
     : base(fullName)
 {
     if (shieldData == null)
     {
         throw new Exception("ShieldData cannot be null");
     }
     Data        = shieldData;
     TextureData = ResourceManager.GetTextureData(Data.TextureName);
 }
示例#7
0
 public Sprite(SpriteData spriteData)
 {
     if (spriteData == null)
     {
         throw new Exception("SpriteData cannot be null");
     }
     Data        = spriteData;
     TextureData = ResourceManager.GetTextureData(spriteData.TextureName);
     currentAnimationFrameIndex = 0;
     CurrentAnimation           = null;
     Time = 0.0f;
 }
示例#8
0
        public PauseMenu()
        {
            pixelTextureData = ResourceManager.GetTextureData("white_pixel");
            options          = new List <string> {
                "Resume",
                "Exit"
            };
            currentOptionIndex = 0;

            inputButtonListener = new InputButtonListener(new Dictionary <InputButton, ButtonEventHandlers> {
                { InputButton.Down, new ButtonEventHandlers(down: nextOption) },
                { InputButton.Up, new ButtonEventHandlers(down: previousOption) },
                { InputButton.A, new ButtonEventHandlers(up: selectOption) }
            });
        }
        public static void AddExplosion(Vector2 position, Battle battle)
        {
            if (battle == null)
            {
                throw new Exception("Battle cannot be null");
            }

            TextureData cloudTextureData = ResourceManager.GetTextureData("particles/cloud_1");

            Scene.AddEntity(new ParticleEffect(position, Color.Red, 12, cloudTextureData, 800.0f, 500.0f, 0.8f, 0.6f, true));
            Scene.AddEntity(new ParticleEffect(position, Color.Orange, 12, cloudTextureData, 800.0f, 500.0f, 0.8f, 0.6f, true));
            Scene.AddEntity(new ParticleEffect(position, Color.White, 12, cloudTextureData, 800.0f, 500.0f, 0.8f, 0.6f, true));
            battle.Camera.Shake(new Vector2(4.0f), 0.1f);
            battle.SetCameraUpdateDelay(1.0f);
        }
示例#10
0
 public Entity(Vector2 position)
 {
     ResetManipulation();
     Position          = position;
     ZIndex            = 0;
     DepthOverride     = -1.0f;
     Altitude          = 0.0f;
     Alive             = true;
     Visible           = true;
     UpdateExtensions  = new List <UpdateExtension>();
     Shader            = null;
     PauseAnimation    = false;
     RenderShadow      = false;
     shadowTextureData = ResourceManager.GetTextureData("shadow");
 }
        private TextureData getTextureDataForStatus(Status status)
        {
            string searchString;

            switch (status)
            {
            case Status.Poisonous: searchString = "particles/poison_bubble"; break;

            case Status.Shocking: searchString = "particles/paralysis"; break;

            case Status.Scary: searchString = "particles/fear"; break;

            default: searchString = null; break;
            }
            return(ResourceManager.GetTextureData(searchString));
        }
示例#12
0
        private void _createParticleEffectOnPartyMember(object[] args)
        { // createParticleEffectOnPartyMember(string partyMemberSelector, int particleCount, string textureDataName, float speed, float gravity, float maxScale, float lifeTime, bool rotate)
            string partyMemberSelector = (string)args[0];
            int    particleCount       = (int)args[1];
            string textureDataName     = (string)args[2];
            float  speed    = (float)args[3];
            float  gravity  = (float)args[4];
            float  maxScale = (float)args[5];
            float  lifeTime = (float)args[6];
            bool   rotate   = (bool)args[7];

            PartyMember partyMember = getPartyMemberFromSelector(partyMemberSelector);
            TextureData textureData = ResourceManager.GetTextureData(textureDataName);

            Scene.AddEntity(new ParticleEffect(partyMember.BattleEntity.GetCenter(), Color.White, particleCount, textureData, speed, gravity, maxScale, lifeTime, rotate));
        }
示例#13
0
        private void generateBackground()
        {
            const int backgroundsToSampleCount = 10;

            backgroundTextureData = new List <TextureData>(backgroundsToSampleCount);
            List <string> battleBackgroundTextureNames = OverworldEncounter.Overworld.Area.Data.BattleBackgroundTextureNamesToList();

            lowestBackgroundTextureWidth = -1;
            for (int i = 0; i < backgroundsToSampleCount; ++i)
            {
                TextureData textureData = ResourceManager.GetTextureData(battleBackgroundTextureNames.Sample());
                backgroundTextureData.Add(textureData);
                if (textureData.Width < lowestBackgroundTextureWidth || lowestBackgroundTextureWidth < 0)
                {
                    lowestBackgroundTextureWidth = textureData.Width;
                }
            }
        }
示例#14
0
 public GameOver()
 {
     whitePixelTextureData = ResourceManager.GetTextureData("white_pixel");
     gameOverAlphaTimer    = 0.0f;
 }
        public static ParticleEffect AddSmokePuff(Vector2 position, Battle battle)
        {
            if (battle == null)
            {
                throw new Exception("Battle cannot be null");
            }
            ParticleEffect particleEffect = new ParticleEffect(position, Color.White, 20, ResourceManager.GetTextureData("particles/cloud_1"), 500.0f, 500.0f, 0.6f, 0.6f, true);

            Scene.AddEntity(particleEffect);
            battle.Camera.Shake(new Vector2(3.0f, 0.0f), 0.1f);
            return(particleEffect);
        }