示例#1
0
    // Use this for initialization
    void OnEnable()
    {
        mDamageables = new Dictionary <int, ADamageable>();

        // Timer listener:
        if (!Timer)
        {
            Timer = GetComponent <DTimer>();
        }
        if (Timer)
        {
            Timer.OnTimerFired.AddListener(DealDamage);
        }

        // Target listeners:
        if (!Targets)
        {
            Targets = GetComponent <DTargetList>();
        }
        if (Targets)
        {
            Targets.OnTargetAdded.AddListener(GetDamageable);
            Targets.OnTargetRemoved.AddListener(RemoveDamageable);
        }
    }
示例#2
0
        public void Shutdown()
        {
            Timer  = null;
            Camera = null;

            // Release the Direct3D object.
            D3D?.ShutDown();
            D3D = null;
        }
        // Methods
        public bool Initialize(DSystemConfiguration configuration, IntPtr windowsHandle)
        {
            try
            {
                // Create the Direct3D object.
                D3D = new DDX11();

                // Initialize the Direct3D object.
                if (!D3D.Initialize(configuration, windowsHandle))
                {
                    return(false);
                }

                // Create the Timer
                Timer = new DTimer();

                // Initialize the Timer
                if (!Timer.Initialize())
                {
                    return(false);
                }

                // Create the camera object
                Camera = new DCamera();

                // Set the initial position of the camera.
                Camera.SetPosition(0, 0, -10);

                // Create the model object.
                Model = new DModel();

                // Initialize the model object.
                if (!Model.Initialize(D3D.Device, DSystemConfiguration.DataFilePath + "seafloor.bmp"))
                {
                    MessageBox.Show("Could not initialize the model object.");
                    return(false);
                }

                // Create the texture shader object.
                TextureShader = new DTextureShader();

                // Initialize the texture shader object.
                if (!TextureShader.Initialize(D3D.Device, windowsHandle))
                {
                    MessageBox.Show("Could not initialize the texture shader object.");
                    return(false);
                }

                return(true);
            }
            catch
            {
                return(false);
            }
        }
        // Methods
        public bool Initialize(DSystemConfiguration configuration, IntPtr windowsHandle)
        {
            try
            {
                // Create the Direct3D object.
                D3D = new DDX11();

                // Initialize the Direct3D object.
                if (!D3D.Initialize(configuration, windowsHandle))
                {
                    return(false);
                }

                // Create the Timer
                Timer = new DTimer();

                // Initialize the Timer
                if (!Timer.Initialize())
                {
                    return(false);
                }

                // Create the camera object
                Camera = new DCamera();

                // Set the initial position of the camera.  moved closer inTutorial 7
                Camera.SetPosition(0, 0, -10);

                // Create the texture shader object.
                TextureShader = new DTextureShader();

                // Initialize the texture shader object.
                if (!TextureShader.Initialize(D3D.Device, windowsHandle))
                {
                    MessageBox.Show("Could not initialize the texture shader object.");
                    return(false);
                }

                // Create the bitmap object.
                Bitmap = new DBitmap();

                // Initialize the bitmap object.
                if (!Bitmap.Initialize(D3D.Device, configuration.Width, configuration.Height, "seafloor.bmp", 256, 256))
                {
                    return(false);
                }

                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Could not initialize Direct3D\nError is '" + ex.Message + "'");
                return(false);
            }
        }
 public void ShutDown()
 {
     Camera = null;
     Timer  = null;
     ColorShader?.ShutDown();
     ColorShader = null;
     Model?.ShutDown();
     Model = null;
     D3D?.ShutDown();
     D3D = null;
 }
示例#6
0
        public bool Initialize(DSystemConfiguration consifguration, IntPtr windowsHandle)
        {
            bool result = false;

            D3D    = new DDX11();
            result = D3D.Initialize(consifguration, windowsHandle);
            Timer  = new DTimer();
            result = Timer.Initialize();

            return(result);
        }
示例#7
0
        // Mathods
        public bool Initialize(DSystemConfiguration configuration, IntPtr windowHandle)
        {
            try
            {
                // Create the Direct3D object.
                D3D = new DDX11();

                // I nitialize the Direct3D object.
                if (!D3D.Initialize(configuration, windowHandle))
                {
                    return(false);
                }

                // Create the camera object
                Camera = new DCamera();

                // Set the initial position of the camera.
                Camera.SetPosition(0, 0, -10);

                // Create the model object.
                Model = new DModel();

                // Initialize the model object.
                if (!Model.Initialize(D3D.Device))
                {
                    return(false);
                }

                // Create the color shader object.
                ColorShader = new DColorShader();

                // Initialize the color shader object.
                if (!ColorShader.Initialize(D3D.Device, windowHandle))
                {
                    return(false);
                }

                // Create the Timer
                Timer = new DTimer();

                // Initialize the Timer
                if (!Timer.Initialize())
                {
                    return(false);
                }

                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Could not initialize Direct3D\nError is '" + ex.Message + "'");
                return(false);
            }
        }
示例#8
0
 public void ShutDown()
 {
     Camera = null;
     Timer  = null;
     TextureShader?.ShutDown();
     TextureShader = null;
     Model?.ShutDown();
     Model = null;
     D3D?.ShutDown();
     D3D = null;
 }
示例#9
0
        public virtual void Initialize(string title, int width, int height, bool fullScreen, Surface surface)
        {
            if (Configuration == null)
            {
                Configuration = new DSystemConfiguration(title, width, height, fullScreen);
            }

            InitializeWindows(title);
            DApplication = new DApplication();
            DApplication.Initialize(Configuration, RenderForm.Handle, surface);
            Timer = new DTimer();
            Timer.Initialize();
        }
        public void ShutDown()
        {
            Timer  = null;
            Camera = null;

            // Release the color shader object.
            TextureShader?.ShutDown();
            TextureShader = null;
            // Release the model object.
            Bitmap?.Shutdown();
            Bitmap = null;
            // Release the Direct3D object.
            D3D?.ShutDown();
            D3D = null;
        }
示例#11
0
        // Methods.
        public bool Initialize(DSystemConfiguration configuration, IntPtr windowHandle)
        {
            try
            {
                // Create the Direct3D object.
                D3D = new DDX11();

                // Initialize the Direct3D object.
                if (!D3D.Initialize(configuration, windowHandle))
                {
                    return(false);
                }

                // Create the Timer
                Timer = new DTimer();

                // Initialize the Timer
                if (!Timer.Initialize())
                {
                    return(false);
                }

                // Create the camera object
                Camera = new DCamera();

                // Initialize a base view matrix the camera for 2D user interface rendering.
                Camera.SetPosition(0, 0, -1);
                Camera.Render();
                var baseViewMatrix = Camera.ViewMatrix;

                // Create the text object.
                Text = new DTextClass();

                if (!Text.Initialize(D3D.Device, D3D.DeviceContext, windowHandle, configuration.Width, configuration.Height, baseViewMatrix))
                {
                    return(false);
                }

                Camera.SetPosition(0, 0, -10.0f);

                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Could not initialize Direct3D\nError is '" + ex.Message + "'");
                return(false);
            }
        }
示例#12
0
        public bool Initialize(DSystemConfiguration consifguration, IntPtr windowsHandle)
        {
            bool result = false;

            D3D    = new DDX11();
            result = D3D.Initialize(consifguration, windowsHandle);
            Timer  = new DTimer();
            result = Timer.Initialize();
            Camera = new DCamera();
            Camera.SetPosition(0, 0, -10);
            Model         = new DModel();
            result        = Model.Initialize(D3D.Device, DSystemConfiguration.DataFilePath + "stone01.bmp");
            TextureShader = new DTextureShader();
            result        = TextureShader.Initialize(D3D.Device, windowsHandle);
            return(result);
        }
示例#13
0
        public void ShutDown()
        {
            // Release the camera object.
            Camera = null;
            Timer  = null;

            // Release the color shader object.
            ColorShader?.ShutDown();
            ColorShader = null;
            // Release the model object.
            Model?.ShutDown();
            Model = null;
            // Release the Direct3D object.
            D3D?.ShutDown();
            D3D = null;
        }
        public bool Initialize(DSystemConfiguration consifguration, IntPtr windowsHandle)
        {
            bool result = false;

            D3D    = new DDX11();
            result = D3D.Initialize(consifguration, windowsHandle);
            Camera = new DCamera();
            Camera.SetPosition(0, 0, -10);
            Model       = new DModel();
            result      = Model.Initialize(D3D.Device);
            ColorShader = new DColorShader();
            result      = ColorShader.Initialize(D3D.Device, windowsHandle);
            Timer       = new DTimer();
            result      = Timer.Initialize();

            return(result);
        }
        public void ShutDown()
        {
            // Release the Timer object.
            Timer = null;
            // Release the camera object.
            Camera = null;

            // Release the TextureShader Object.
            TextureShader?.ShutDown();
            TextureShader = null;
            // Release the model object.
            Model?.ShutDown();
            Model = null;
            // Release the Direct3D object.
            D3D?.ShutDown();
            D3D = null;
        }
示例#16
0
    private static Ship GenerateMissile()
    {
        Ship missile = new Ship(2)
        {
            EntityName = "Missile"
        };

        DEngine engine = new DEngine()
        {
            EntityName = "engine", m_lookDirection = Vector3.forward, m_space = Space.Self
        };

        Device heatSeeker  = GenerateHeatSeeker(3f);
        Device timeBomb    = GenerateTimeBomb(5f);
        DTimer activeTimer = new DTimer()
        {
            EntityName = "activationtimer", m_timerSetUp = 2f
        };

        missile.IntegratedDevice.IntegrateDevice(engine);
        missile.IntegratedDevice.IntegrateDevice(timeBomb);
        missile.IntegratedDevice.IntegrateDevice(heatSeeker);
        missile.IntegratedDevice.IntegrateDevice(activeTimer);

        timeBomb.GetInternalDevice("warhead/ranger").m_isActive = false;
        heatSeeker.GetInternalDevice("ranger").m_isActive       = false;
        Job.make(timeBomb.DeactivateDevice(null), true);
        Job.make(heatSeeker.DeactivateDevice(null), true);


        BSEntry  onTimer           = missile.IntegratedDevice.Blueprint.CreateEntry("OnTimerComplete", activeTimer);
        BSAction toActivateWarhead = missile.IntegratedDevice.Blueprint.CreateAction("ActivateDevice", timeBomb);
        BSAction toActivateSeeker  = missile.IntegratedDevice.Blueprint.CreateAction("ActivateDevice", heatSeeker);

        missile.IntegratedDevice.Blueprint.ConnectElements(onTimer, toActivateWarhead);
        missile.IntegratedDevice.Blueprint.ConnectElements(onTimer, toActivateSeeker);

        return(missile);
    }
示例#17
0
        private void Timer_tick(object sender, EventArgs e)
        {
            seconds = seconds - 1;

            if (seconds == -1)
            {
                minutes = minutes - 1;
                seconds = 59;
            }

            if (minutes == -1)
            {
                hours   = hours - 1;
                minutes = 59;
            }

            if (hours == 0 && minutes == 0 && seconds == 0)
            {
                DTimer.Stop();

                NotificationBalloonTips.TimerPopUp();
                IsDone = true;
            }

            //Dispatcher.Invoke(() =>
            //{
            string hh = Convert.ToString(hours);
            string mm = Convert.ToString(minutes);
            string ss = Convert.ToString(seconds);

            main.TimerLabel.Content   = hh;
            main.TimerLabelMM.Content = mm;
            main.TimerLabelSS.Content = ss;
            // });
            if (!IsDone)
            {
                ActivateCounterMeasures();
            }
        }
示例#18
0
        private void DTimer_Tick(object sender, EventArgs e)
        {
            try
            {
                if (frameScore >= Global.GameScore)
                {
                    Score_Result = "Score: " + Global.GameScore;
                    frameScore   = Global.GameScore;
                    bScore       = true;
                }
                else
                {
                    frameScore  += 1;
                    Score_Result = "Score: " + frameScore;
                }

                if (frameTime >= Global.GameTime)
                {
                    Time_Result = "Time: " + Global.GameTime;
                    frameTime   = Global.GameTime;
                    bTime       = true;
                }
                else
                {
                    frameTime  += 1;
                    Time_Result = "Time: " + frameTime;
                }

                if (bScore && bTime)
                {
                    BG_PlayerScore.Stop();
                    BG_Player.Play();
                    DTimer.Stop();
                }
            }
            catch { }
        }
示例#19
0
    private static Device GenerateTimeBomb(float time)
    {
        Device timeBomb = new Device()
        {
            EntityName = "timebomb"
        };

        Device warhead = GenerateWarhead(1f);
        DTimer timer   = new DTimer()
        {
            EntityName = "timer", m_timerSetUp = time
        };

        timeBomb.IntegrateDevice(warhead);
        timeBomb.IntegrateDevice(timer);

        // Generating warhead
        BSEntry  onTimer    = timeBomb.Blueprint.CreateEntry("OnTimerComplete", timer);
        BSAction toDetonate = timeBomb.Blueprint.CreateAction("Detonate", timeBomb.GetInternalDevice("warhead/detonator"));

        timeBomb.Blueprint.ConnectElements(onTimer, toDetonate);

        return(timeBomb);
    }
        // Methods
        public bool Initialize(DSystemConfiguration configuration, IntPtr windowsHandle)
        {
            try
            {
                // Create the Direct3D object.
                D3D = new DDX11();

                // Initialize the Direct3D object.
                if (!D3D.Initialize(configuration, windowsHandle))
                {
                    return(false);
                }

                // Create the Timer
                Timer = new DTimer();

                // Initialize the Timer
                if (!Timer.Initialize())
                {
                    return(false);
                }

                // Create the camera object
                Camera = new DCamera();

                // Set the initial position of the camera.  moved closer inTutorial 7
                Camera.SetPosition(0, 0, -10.0f);

                // Create the model object.
                Model = new DModel();

                // Initialize the model object.
                if (!Model.Initialize(D3D.Device, "Cube.txt", "seafloor.bmp"))
                {
                    MessageBox.Show("Could not initialize the model object.");
                    return(false);
                }

                // Create the texture shader object.
                LightShader = new DLightShader();

                // Initialize the texture shader object.
                if (!LightShader.Initialize(D3D.Device, windowsHandle))
                {
                    MessageBox.Show("Could not initialize the texture shader object.");
                    return(false);
                }

                // Create the light object.
                Light = new DLight();

                // Iniialize the light object.  Changed to white in Tutorial 7
                Light.SetDiffuseColour(1, 1, 1, 1);
                Light.SetDirection(0, 0, 1);

                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Could not initialize Direct3D\nError is '" + ex.Message + "'");
                return(false);
            }
        }
        // Methods
        public bool Initialize(DSystemConfiguration configuration, IntPtr windowsHandle)
        {
            try
            {
                // Create the Direct3D object.
                D3D = new DDX11();

                // Initialize the Direct3D object.
                if (!D3D.Initialize(configuration, windowsHandle))
                {
                    return(false);
                }

                // Create the Timer
                Timer = new DTimer();

                // Initialize the Timer
                if (!Timer.Initialize())
                {
                    return(false);
                }

                // Create the camera object
                Camera = new DCamera();
                // Set the initial position of the camera.  moved closer inTutorial 7
                Camera.SetPosition(0, 0, -10.0f);

                // Create the model object.
                Model = new DModel();

                // Initialize the model object.
                if (!Model.Initialize(D3D.Device, "Cube.txt", "seafloor.bmp"))
                {
                    MessageBox.Show("Could not initialize the model object.");
                    return(false);
                }

                // Create the texture shader object.
                LightShader = new DLightShader();

                // Initialize the texture shader object.
                if (!LightShader.Initialize(D3D.Device, windowsHandle))
                {
                    MessageBox.Show("Could not initialize the texture shader object.");
                    return(false);
                }

                // Create the light object.
                Light = new DLight();

                // Iniialize the light object.  Changed to white in Tutorial 7
                // Added Setting of Ambiant Light to 15& brightness and adjust the Light direction along the X-Axis instead of the Z to see the ambient effect easier.
                Light.SetAmbientColor(0.15f, 0.15f, 0.15f, 1.0f);
                Light.SetDiffuseColour(1, 1, 1, 1);
                Light.SetDirection(1, 0, 0);

                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Could not initialize Direct3D\nError is '" + ex.Message + "'");
                return(false);
            }
        }
示例#22
0
 public void ShutDown()
 {
     Timer = null;
     D3D?.ShutDown();
     D3D = null;
 }
        // Methods.
        public bool Initialize(DSystemConfiguration configuration, IntPtr windowHandle, string appTitle, int testTimeSeconds)
        {
            try
            {
                // Create the input object.
                Input = new DInput();

                // Initialize the input object.
                if (!Input.Initialize(configuration, windowHandle))
                {
                    return(false);
                }

                #region Initialize System
                // Create the Direct3D object.
                D3D = new DDX11();

                // Initialize the Direct3D object.
                if (!D3D.Initialize(configuration, windowHandle))
                {
                    return(false);
                }

                // Create the timer object.
                Timer = new DTimer();

                // Initialize the timer object.
                if (!Timer.Initialize())
                {
                    return(false);
                }

                // Create the position object.
                Position = new DPosition();

                // Set the initial position.
                Position.SetPosition(0.0f, 7.0f, -11.0f);
                Position.SetRotation(20.0f, 0.0f, 0.0f);
                #endregion

                #region Initialize Camera
                // Create the camera object
                Camera = new DCamera();

                // Create the light object.
                Light = new DLight();

                // Initialize the light object.
                Light.GenerateOrthoMatrix(15.0f, 15.0f, SHADOWMAP_DEPTH, SHADOWMAP_NEAR);
                #endregion

                // Create the ground model object.
                GroundModel = new DModel();

                // Initialize the ground model object.
                if (!GroundModel.Initialize(D3D.Device, "plane01.txt", "dirt.bmp", 2.0f))
                {
                    return(false);
                }

                // Set the position for the ground model.
                GroundModel.SetPosition(0.0f, 1.0f, 0.0f);

                // Create the tree object.
                TreeModel = new DTreeModel();

                // Initialize the shadow shader object.
                if (!TreeModel.Initialize(D3D.Device, "trunk001.txt", "trunk001.bmp", "leaf001.txt", "leaf001.bmp", 0.1f))
                {
                    return(false);
                }

                // Set the position for the tree model.
                TreeModel.SetPosition(0.0f, 1.0f, 0.0f);

                // Create the render to texture object.
                RenderTexture = new DRenderTexture();

                // Initialize the render to texture object.
                if (!RenderTexture.Initialize(D3D.Device, SHADOWMAP_WIDTH, SHADOWMAP_HEIGHT, SHADOWMAP_DEPTH, SHADOWMAP_NEAR))
                {
                    return(false);
                }

                // Create the depth shader object.
                DepthShader = new DDepthShader();

                // Initialize the depth shader object.
                if (!DepthShader.Initialize(D3D.Device, windowHandle))
                {
                    return(false);
                }

                // Create the transparent depth shader object.
                TransparentDepthShader = new DTransparentDepthShader();

                // Initialize the transparent depth shader object.
                if (!TransparentDepthShader.Initialize(D3D.Device, windowHandle))
                {
                    return(false);
                }

                // Create the shadow shader object.
                ShadowShader = new DShadowShader();

                // Initialize the shadow shader object.
                if (!ShadowShader.Initialize(D3D.Device, windowHandle))
                {
                    return(false);
                }

                DPerfLogger.Initialize("WinForms C# SharpDX: " + configuration.Width + "x" + configuration.Height + " VSync:" + DSystemConfiguration.VerticalSyncEnabled + " FullScreen:" + DSystemConfiguration.FullScreen + "   " + appTitle, testTimeSeconds, configuration.Width, configuration.Height);

                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Could not initialize Direct3D\nError is '" + ex.Message + "'");
                return(false);
            }
        }