Ejemplo n.º 1
0
        public RTSRenderer(GraphicsDeviceManager gdm, ContentManager cm, RendererInitArgs ria, GameWindow w)
        {
            window    = w;
            gManager  = gdm;
            cManager  = cm;
            args      = ria;
            toDispose = new ConcurrentBag <IDisposable>();

            NonFriendlyUnitModels     = new List <RTSUnitModel>();
            FriendlyUnitModels        = new List <RTSUnitModel>();
            NonFriendlyBuildingModels = new List <RTSBuildingModel>();
            FriendlyBuildingModels    = new List <RTSBuildingModel>();
            IconLibrary = new Dictionary <string, Texture2D>();
            for (int i = 0; i < ria.Icons.Length; i += 2)
            {
                IconLibrary.Add(ria.Icons[i], LoadTexture2D(ria.Icons[i + 1]));
            }

            tPixel = CreateTexture2D(1, 1);
            tPixel.SetData(new Color[] { Color.White });
            IconLibrary.Add("None", tPixel);

            fxMap = new RTSFXMap(LoadEffect(ria.FXMap));

            fxSimple = CreateEffect();
            fxSimple.LightingEnabled    = false;
            fxSimple.FogEnabled         = false;
            fxSimple.TextureEnabled     = false;
            fxSimple.VertexColorEnabled = true;
            fxSimple.World   = Matrix.Identity;
            fxSimple.Texture = tPixel;

            fxAnim            = new RTSFXEntity(LoadEffect(ria.FXEntity));
            fxAnim.World      = Matrix.Identity;
            fxAnim.CPrimary   = Vector3.UnitX;
            fxAnim.CSecondary = Vector3.UnitY;
            fxAnim.CTertiary  = Vector3.UnitZ;
            tNoise            = LoadTexture2D(ria.FXBuildNoise);
            healthView        = new HealthViewer();
            healthView.Build(this, fxAnim, ria.FXHealthTechnique, ria.FXHealthPass, ria.FXHealthTexture);
            UseFOW = true;

            pRenderer = new ParticleRenderer(LoadEffect(ria.FXParticle), ria.ParticleConfig);
            Minimap   = new Minimap();

            CamPointer = new CameraPointer();
            CamPointer.Build(this, ria.CamPointerTexture, ria.CamPointerRadii, ria.CamPointerHeights);

            drawBox = false;
            MouseEventDispatcher.OnMousePress   += OnMousePress;
            MouseEventDispatcher.OnMouseRelease += OnMouseRelease;
            MouseEventDispatcher.OnMouseMotion  += OnMouseMove;
        }
Ejemplo n.º 2
0
        public RTSRenderer(GraphicsDeviceManager gdm, ContentManager cm, RendererInitArgs ria, GameWindow w)
        {
            window = w;
            gManager = gdm;
            cManager = cm;
            args = ria;
            toDispose = new ConcurrentBag<IDisposable>();

            NonFriendlyUnitModels = new List<RTSUnitModel>();
            FriendlyUnitModels = new List<RTSUnitModel>();
            NonFriendlyBuildingModels = new List<RTSBuildingModel>();
            FriendlyBuildingModels = new List<RTSBuildingModel>();
            IconLibrary = new Dictionary<string, Texture2D>();
            for(int i = 0; i < ria.Icons.Length; i += 2) {
                IconLibrary.Add(ria.Icons[i], LoadTexture2D(ria.Icons[i + 1]));
            }

                tPixel = CreateTexture2D(1, 1);
            tPixel.SetData(new Color[] { Color.White });
            IconLibrary.Add("None", tPixel);

            fxMap = new RTSFXMap(LoadEffect(ria.FXMap));

            fxSimple = CreateEffect();
            fxSimple.LightingEnabled = false;
            fxSimple.FogEnabled = false;
            fxSimple.TextureEnabled = false;
            fxSimple.VertexColorEnabled = true;
            fxSimple.World = Matrix.Identity;
            fxSimple.Texture = tPixel;

            fxAnim = new RTSFXEntity(LoadEffect(ria.FXEntity));
            fxAnim.World = Matrix.Identity;
            fxAnim.CPrimary = Vector3.UnitX;
            fxAnim.CSecondary = Vector3.UnitY;
            fxAnim.CTertiary = Vector3.UnitZ;
            tNoise = LoadTexture2D(ria.FXBuildNoise);
            healthView = new HealthViewer();
            healthView.Build(this, fxAnim, ria.FXHealthTechnique, ria.FXHealthPass, ria.FXHealthTexture);
            UseFOW = true;

            pRenderer = new ParticleRenderer(LoadEffect(ria.FXParticle), ria.ParticleConfig);
            Minimap = new Minimap();

            CamPointer = new CameraPointer();
            CamPointer.Build(this, ria.CamPointerTexture, ria.CamPointerRadii, ria.CamPointerHeights);

            drawBox = false;
            MouseEventDispatcher.OnMousePress += OnMousePress;
            MouseEventDispatcher.OnMouseRelease += OnMouseRelease;
            MouseEventDispatcher.OnMouseMotion += OnMouseMove;
        }