Esempio n. 1
0
        public static Texture2D LoadTexture(string file)
        {
            foreach (Sprite s in list)
            {
                if (s.file == file)
                {
                    return(s.texture);
                }
            }

            if (File.Exists(file))
            {
                ToolBox.IsProperFilenameCase(file);
                return(TextureLoader.FromFile(file));
            }
            else
            {
                DebugConsole.ThrowError("Sprite \"" + file + "\" not found!");
            }

            return(null);
        }
Esempio n. 2
0
        //public VertexPositionTexture[] WallVertices;
        //public VertexPositionColor[] BodyVertices;

        public LevelRenderer(Level level)
        {
            if (shaftTexture == null)
            {
                shaftTexture = TextureLoader.FromFile("Content/Map/iceWall.png");
            }

            if (background == null)
            {
                background    = new Sprite("Content/Map/background2.png", Vector2.Zero);
                backgroundTop = new Sprite("Content/Map/background.png", Vector2.Zero);
                dustParticles = new Sprite("Content/Map/dustparticles.png", Vector2.Zero);
            }

            if (wallEdgeEffect == null)
            {
                wallEdgeEffect = new BasicEffect(GameMain.Instance.GraphicsDevice)
                {
                    DiffuseColor       = new Vector3(0.8f, 0.8f, 0.8f),
                    VertexColorEnabled = true,
                    TextureEnabled     = true,
                    Texture            = shaftTexture
                };
                wallEdgeEffect.CurrentTechnique = wallEdgeEffect.Techniques["BasicEffect_Texture"];
            }

            if (wallCenterEffect == null)
            {
                wallCenterEffect = new BasicEffect(GameMain.Instance.GraphicsDevice)
                {
                    VertexColorEnabled = true,
                    TextureEnabled     = true,
                    Texture            = backgroundTop.Texture
                };
                wallCenterEffect.CurrentTechnique = wallCenterEffect.Techniques["BasicEffect_Texture"];
            }

            this.level = level;
        }
Esempio n. 3
0
        public Map(string seed, int size)
        {
            this.seed = seed;

            this.size = size;

            levels = new List <Level>();

            locations = new List <Location>();

            connections = new List <LocationConnection>();

            if (iceTexture == null)
            {
                iceTexture = new Sprite("Content/Map/iceSurface.png", Vector2.Zero);
            }
            if (iceCraters == null)
            {
                iceCraters = TextureLoader.FromFile("Content/Map/iceCraters.png");
            }
            if (iceCrack == null)
            {
                iceCrack = TextureLoader.FromFile("Content/Map/iceCrack.png");
            }

            Rand.SetSyncedSeed(ToolBox.StringToInt(this.seed));

            GenerateLocations();

            currentLocation            = locations[locations.Count / 2];
            currentLocation.Discovered = true;
            GenerateDifficulties(currentLocation, new List <LocationConnection> (connections), 10.0f);

            foreach (LocationConnection connection in connections)
            {
                connection.Level = Level.CreateRandom(connection);
            }
        }
Esempio n. 4
0
        public WaterRenderer(GraphicsDevice graphicsDevice, ContentManager content)
        {
#if WINDOWS
            waterEffect = content.Load <Effect>("watershader");
#endif
#if LINUX
            waterEffect = content.Load <Effect>("watershader_opengl");
#endif

            waterTexture = TextureLoader.FromFile("Content/waterbump.png");
            waterEffect.Parameters["xWaveWidth"].SetValue(0.05f);
            waterEffect.Parameters["xWaveHeight"].SetValue(0.05f);

            waterEffect.Parameters["xWaterBumpMap"].SetValue(waterTexture);

            if (basicEffect == null)
            {
                basicEffect = new BasicEffect(GameMain.Instance.GraphicsDevice);
                basicEffect.VertexColorEnabled = false;

                basicEffect.TextureEnabled = true;
            }
        }
Esempio n. 5
0
        public GameScreen(GraphicsDevice graphics, ContentManager content)
        {
            cam = new Camera();
            cam.Translate(new Vector2(-10.0f, 50.0f));

            renderTargetBackground = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
            renderTarget           = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
            renderTargetWater      = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
            renderTargetAir        = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight);

            var files = GameMain.SelectedPackage.GetFilesOfType(ContentType.BackgroundCreaturePrefabs);

            if (files.Count > 0)
            {
                BackgroundCreatureManager = new BackgroundCreatureManager(files);
            }
            else
            {
                BackgroundCreatureManager = new BackgroundCreatureManager("Content/BackgroundSprites/BackgroundCreaturePrefabs.xml");
            }

#if LINUX
            var blurEffect = content.Load <Effect>("blurshader_opengl");
            damageEffect = content.Load <Effect>("damageshader_opengl");
#else
            var blurEffect = content.Load <Effect>("blurshader");
            damageEffect = content.Load <Effect>("damageshader");
#endif

            damageStencil = TextureLoader.FromFile("Content/Map/walldamage.png");
            damageEffect.Parameters["xStencil"].SetValue(damageStencil);
            damageEffect.Parameters["aMultiplier"].SetValue(50.0f);
            damageEffect.Parameters["cMultiplier"].SetValue(200.0f);

            lightBlur = new BlurEffect(blurEffect, 0.001f, 0.001f);
        }
Esempio n. 6
0
        public CharacterInventory(int capacity, Character character)
            : base(character, capacity)
        {
            this.character = character;

            useOnSelfButton = new GUIButton[2];

            if (icons == null)
            {
                icons = TextureLoader.FromFile("Content/UI/inventoryIcons.png");
            }

            SlotPositions = new Vector2[limbSlots.Length];

            int rectWidth = 40, rectHeight = 40;
            int spacing = 10;

            for (int i = 0; i < SlotPositions.Length; i++)
            {
                switch (i)
                {
                //head, torso, legs
                case 0:
                case 1:
                case 2:
                    SlotPositions[i] = new Vector2(
                        spacing,
                        GameMain.GraphicsHeight - (spacing + rectHeight) * (3 - i));
                    break;

                //lefthand, righthand
                case 3:
                case 4:
                    SlotPositions[i] = new Vector2(
                        spacing * 2 + rectWidth + (spacing + rectWidth) * (i - 2),
                        GameMain.GraphicsHeight - (spacing + rectHeight) * 3);

                    useOnSelfButton[i - 3] = new GUIButton(
                        new Rectangle((int)SlotPositions[i].X, (int)(SlotPositions[i].Y - spacing - rectHeight),
                                      rectWidth, rectHeight), "Use", "")
                    {
                        UserData  = i,
                        OnClicked = UseItemOnSelf
                    };


                    break;

                case 5:
                    SlotPositions[i] = new Vector2(
                        spacing * 2 + rectWidth + (spacing + rectWidth) * (i - 5),
                        GameMain.GraphicsHeight - (spacing + rectHeight) * 3);

                    break;

                default:
                    SlotPositions[i] = new Vector2(
                        spacing * 2 + rectWidth + (spacing + rectWidth) * ((i - 6) % 5),
                        GameMain.GraphicsHeight - (spacing + rectHeight) * ((i > 10) ? 2 : 1));
                    break;
                }
            }
        }
Esempio n. 7
0
        partial void InitProjSpecific()
        {
            useOnSelfButton = new GUIButton[2];

            if (icons == null)
            {
                icons = TextureLoader.FromFile("Content/UI/inventoryIcons.png");
            }

            SlotPositions = new Vector2[limbSlots.Length];

            int rectWidth = 40, rectHeight = 40;
            int spacing = 10;

            for (int i = 0; i < SlotPositions.Length; i++)
            {
                switch (i)
                {
                //head, torso, legs
                case 0:
                case 1:
                case 2:
                    SlotPositions[i] = new Vector2(
                        spacing,
                        GameMain.GraphicsHeight - (spacing + rectHeight) * (3 - i));
                    break;

                //lefthand, righthand
                case 3:
                case 4:
                    SlotPositions[i] = new Vector2(
                        spacing * 2 + rectWidth + (spacing + rectWidth) * (i - 1),
                        GameMain.GraphicsHeight - (spacing + rectHeight) * 3);

                    useOnSelfButton[i - 3] = new GUIButton(
                        new Rectangle((int)SlotPositions[i].X, (int)(SlotPositions[i].Y - spacing - rectHeight),
                                      rectWidth, rectHeight), TextManager.Get("UseItemButton"), "")
                    {
                        UserData  = i,
                        OnClicked = UseItemOnSelf
                    };


                    break;

                //face
                case 5:
                    SlotPositions[i] = new Vector2(
                        spacing * 2 + rectWidth + (spacing + rectWidth) * (i - 5),
                        GameMain.GraphicsHeight - (spacing + rectHeight) * 3);

                    break;

                //id card
                case 6:
                    SlotPositions[i] = new Vector2(
                        spacing * 2 + rectWidth + (spacing + rectWidth) * (i - 5),
                        GameMain.GraphicsHeight - (spacing + rectHeight) * 3);

                    break;

                default:
                    SlotPositions[i] = new Vector2(
                        spacing * 2 + rectWidth + (spacing + rectWidth) * ((i - 7) % 5),
                        GameMain.GraphicsHeight - (spacing + rectHeight) * ((i > 11) ? 2 : 1));
                    break;
                }
            }
        }