Beispiel #1
0
        protected override void WndProc(ref Message message)
        {
            switch (message.Msg)
            {
            case 15:
            {
                var paintStruct = new PaintStruct();
                var targetDc    = NativeMethods.BeginPaint(message.HWnd, ref paintStruct);
                var rectangle   = new Rectangle(paintStruct.RcPaint_left, paintStruct.RcPaint_top,
                                                paintStruct.RcPaint_right - paintStruct.RcPaint_left,
                                                paintStruct.RcPaint_bottom - paintStruct.RcPaint_top);
                if ((rectangle.Width > 0) && (rectangle.Height > 0))
                {
                    using (
                        var graphics = BufferedGraphicsManager.Current.Allocate(targetDc,
                                                                                ClientRectangle))
                    {
                        var hdc = graphics.Graphics.GetHdc();
                        var m   = Message.Create(Handle, 0x318, hdc, IntPtr.Zero);
                        DefWndProc(ref m);
                        graphics.Graphics.ReleaseHdc(hdc);
                        graphics.Render();
                    }
                }
                NativeMethods.EndPaint(message.HWnd, ref paintStruct);
                message.Result = IntPtr.Zero;
                return;
            }

            case 20:
                message.Result = (IntPtr)1;
                return;
            }
            base.WndProc(ref message);
        }
Beispiel #2
0
 void addPaint(PaintStruct paintIN)
 {
     for (int x = 0; x <= ammoType.Length; x++)
     {
         if (ammoType[x] == null)
         {
             ammoType[x] = paintIN;
             //currentActivePaint = ammoType[x];
             break;
         }
     }
 }
Beispiel #3
0
    void ShootPaint(PaintStruct ammoType)
    {
        if (WorldGlobal.isReadyToFireGrowth || (pickObj == null && currentActivePaint.paintType != typeof(GrowSplotch)))
        {
            if (currentActivePaint.paintType == typeof(GrowSplotch))
            {
                WorldGlobal.hasFiredGrowth = true;
            }
            //		Vector3 dir = cam.transform.forward;
            //
            //		GameObject paint = Instantiate(blob, transform.position + transform.TransformDirection(Vector3.forward), Quaternion.identity) as GameObject;
            //		//paint.SendMessage("SetPaint", );
            //		Physics.IgnoreCollision(paint.collider, collider);
            //		paint.rigidbody.AddForce(cam.transform.TransformDirection(Vector3.forward)*700);

            //		Vector3 dir = paintSpawn.forward;
            GameObject paint = Instantiate(blob, paintSpawn.position, Quaternion.identity) as GameObject;
            paint.SendMessage("setMyPaint", ammoType);

            Physics.IgnoreCollision(paint.collider, collider);
            paint.rigidbody.AddForce(paintSpawn.TransformDirection(Vector3.left) * 700);

            AudioSource tempSource = audio;
            tempSource.pitch  = 3.0f;
            tempSource.volume = 0.5f;
            tempSource.PlayOneShot(WorldGlobal.audioClips["shoot"]);

            //shootSfx.Play();

            //		RaycastHit hit;
            //
            //
            //		if(Physics.Raycast(transform.position, dir, out hit, 1000))
            //		{
            //			GameObject decal;
            ////			Debug.Log("Hit: " + hit.rigidbody.name);
            ////			Debug.Log(cam.transform.position);
            //			Debug.DrawLine(transform.position, hit.point, Color.red, 10);
            //
            //			decal = Instantiate(splatter, hit.point + (hit.normal * 0.001f), Quaternion.FromToRotation(Vector3.up, hit.normal)) as GameObject;
            //			decal.transform.localScale = new Vector3(Random.Range(0.7f, 2.0f), Random.Range(0.7f, 2.0f), 1);
            //			decal.transform.parent = hit.rigidbody.gameObject.transform;
            //			decal.renderer.material.color = Color.blue;
            //
            //			hit.rigidbody.collider.material = physicsMats[1];
            //			hit.rigidbody.AddForce(new Vector3(0,500,0));
            //		}
        }
    }
Beispiel #4
0
        protected override void OnGlPaint(ref PaintStruct ps)
        {
            Gl.Clear(ClearBufferMask.ColorBufferBit);
            var size = this.GetClientSize();

            Gl.Viewport(0, 0, size.Width, size.Height);
            Gl.Begin(PrimitiveType.Triangles);
            Gl.Color3(1.0f, 0.0f, 0.0f);
            Gl.Vertex2(0.0f, 0.0f);
            Gl.Color3(0.0f, 1.0f, 0.0f);
            Gl.Vertex2(0.5f, 1.0f);
            Gl.Color3(0.0f, 0.0f, 1.0f);
            Gl.Vertex2(1.0f, 0.0f);
            Gl.End();
            this.DeviceContext.SwapBuffers();
        }
Beispiel #5
0
    // Use this for initialization
    void Start()
    {
        WorldGlobal.Narrator.shootsNLadders = this;

        ammoType[0] = new PaintStruct(typeof(BlueSplotch), Color.blue, WorldGlobal.Materials["default"]);
//		ammoType[1] = new PaintStruct(typeof(GreenSplotch), Color.green, WorldGlobal.Materials["default"]);
//		ammoType[2] = new PaintStruct(typeof(RedSplotch), Color.red, WorldGlobal.Materials["default"]);
//		ammoType[3] = new PaintStruct(typeof(GrowSplotch), WorldGlobal.currentColor, WorldGlobal.Materials["default"]);
//		ammoType[4] = new PaintStruct(typeof(GravityPaint), new Color(0.211f, 0, 0.16f), WorldGlobal.Materials["default"]);
//		ammoType[5] = new PaintStruct(typeof(BananaSplotch), Color.yellow, WorldGlobal.Materials["default"]);

        cleanAmmo = new PaintStruct(typeof(CleanSplotch), new Color(0, 0, 0, 0), WorldGlobal.Materials["bubble"]);

        //Set the current active color to our inital paint (Blue paint)
        currentActivePaint = ammoType[0];

        //physicsMats = Resources.LoadAll("PhysMats") as PhysicMaterial;
        //cam = GetComponentInChildren<Camera>() as Camera;
        cam = Camera.main;
//		blob = Resources.Load("Prefabs/paintBlob") as GameObject;
//		ball = Resources.Load("Prefabs/SphereZ") as GameObject;
        blob = WorldGlobal.Prefabs["paintBlob"];
        ball = WorldGlobal.Prefabs["SphereZ"];

        painGun = cam.transform.Find("PaintGun").gameObject;

        floatyBall   = painGun.transform.Find("b_gun_root/b_gun_ball");
        paintSpawn   = painGun.transform.Find("b_gun_root/b_gun_Shooter");
        coreObject   = WorldGlobal.Prefabs["PaintGunCore"];
        coreInstance = Instantiate(coreObject, floatyBall.position, floatyBall.rotation) as GameObject;
        coreInstance.transform.parent        = floatyBall;
        coreInstance.renderer.material.color = currentActivePaint.ballColor;

        flashLight = new GameObject("Light");
        flashLight.AddComponent <Light>();
        flashLight.light.type         = LightType.Spot;
        flashLight.light.range        = 100;
        flashLight.light.spotAngle    = 40;
        flashLight.light.intensity    = 0.5f;
        flashLight.light.enabled      = false;
        flashLight.transform.position = paintSpawn.position + Vector3.Scale(paintSpawn.TransformDirection(Vector3.left), paintSpawn.position / 6);
        flashLight.transform.rotation = Quaternion.LookRotation(paintSpawn.TransformDirection(Vector3.left));
        flashLight.transform.parent   = paintSpawn;
    }
Beispiel #6
0
 // Use this for initialization
 void Start()
 {
     //Blue paint
     if (myBallColor == new Color(0, 0, 1, 0))
     {
         myPaintType = typeof(BlueSplotch);
     }
     //Green paint
     if (myBallColor == new Color(0, 1, 0, 0))
     {
         myPaintType = typeof(GreenSplotch);
     }
     //Red paint
     if (myBallColor == new Color(1, 0, 0, 0))
     {
         myPaintType = typeof(RedSplotch);
     }
     //Yellow paint
     if (myBallColor == new Color(1, 1, 0, 0))
     {
         myPaintType = typeof(BananaSplotch);
     }
     //Grow paint
     if (myBallColor == new Color(0, 0, 0, 0))
     {
         myPaintType = typeof(GrowSplotch);
     }
     //Gravity paint
     if (myBallColor == new Color(1, 1, 1, 0))
     {
         Debug.Log("Gravity Paint");
         myPaintType = typeof(GravityPaint);
         myBallColor = new Color(0.211f, 0, 0.16f);
     }
     myPaint = new PaintStruct(myPaintType, myBallColor, myMaterial);
 }
Beispiel #7
0
    public virtual int CallBack(int wnd, int msg, int w, int l)
    {
        Rect        rect = new Rect();
        PaintStruct ps   = new PaintStruct();
        TextMetric  tm   = new TextMetric();
        int         dc;

        switch (msg)
        {
        case WinMsg.Create:
            return(0);

        case WinMsg.Size:
            return(0);

        case WinMsg.Char:
            switch (w)
            {
            case '\b':
                if (b.Length > 0)
                {
                    b = b.Remove(b.Length - 1, 1);
                }
                break;

            case '\r':
                Notify();
                break;

            default:
                b = b.Append((char)w);
                break;
            }

            User.InvalidateRect(wnd, null, true);
            return(0);

        case WinMsg.Paint: {
            int    charX, charY, maxX, maxY;
            String s;

            if (b.Length == 0)
            {
                s = "";
            }
            else
            {
                s = b.ToString();
            }

            dc = User.BeginPaint(wnd, ps);
            User.GetClientRect(wnd, rect);

            ps.paint.left   = rect.left;
            ps.paint.top    = rect.top;
            ps.paint.right  = rect.right;
            ps.paint.bottom = rect.bottom;

            GDI.SetTextAlign(dc, TextAlign.Left | TextAlign.Top);
            GDI.SelectObject(dc, GDI.GetStockObject(SystemFont.FixedFont));

            GDI.GetTextMetrics(dc, tm);
            charX = tm.MaxCharWidth;
            charY = (tm.Height + tm.ExternalLeading);
            maxX  = (rect.right / charX);
            maxY  = (rect.bottom / charY);

            GDI.SetTextColor(dc, 0);
            GDI.TextOut(dc, 0, 0, s, s.Length);

            rect.left   = (s.Length * charX);
            rect.top    = 0;
            rect.right  = ((s.Length + 1) * charX);
            rect.bottom = charY;
            User.FillRect(dc, rect, GDI.GetStockObject(Brush.Black));

            User.EndPaint(wnd, ps);
            return(0);
        }

        case WinMsg.Destroy:
            User.PostQuitMessage(0);
            return(0);
        }

        return(User.DefWindowProc(wnd, msg, w, l));
    }
 public IntPtr BeginPaint(out PaintStruct ps)
 {
     return(User32Methods.BeginPaint(this.Handle, out ps));
 }
 public void EndPaint(ref PaintStruct ps)
 {
     User32Methods.EndPaint(this.Handle, ref ps);
 }
Beispiel #10
0
 public static extern IntPtr BeginPaint(IntPtr hwnd, out PaintStruct lpPaint);
Beispiel #11
0
 public static extern bool EndPaint(IntPtr hWnd, [In] ref PaintStruct lpPaint);
Beispiel #12
0
 public static extern HDc BeginPaint([In] HWnd hWnd, [Out] out PaintStruct lpPaint);
Beispiel #13
0
 public static extern int EndPaint(int wnd,
                                   [In, Out] PaintStruct ps);
 internal PaintObject(PaintStruct ps)
 {
     this._PaintStruct = ps;
 }
Beispiel #15
0
    // Update is called once per frame
    void Update()
    {
        if (currentActivePaint.paintType == typeof(GrowSplotch))
        {
            coreInstance.renderer.material.color = WorldGlobal.currentColor;
        }

        if (Input.GetKeyDown(KeyCode.Tab))
        {
            Screen.lockCursor = !(Screen.lockCursor);
        }

        if (Input.GetKeyDown(KeyCode.F))
        {
            flashLight.light.enabled = !flashLight.light.enabled;
        }

        //Debug.Log("Gun Vel: " + rigidbody.velocity);
        if (Input.GetMouseButtonDown(1) && WorldGlobal.isReadyToFire)
        {
            if (pickObj == null)
            {
                ShootPaint(cleanAmmo);
            }
            else
            {
                //Add force to cube and send it flying
                pickObj.rigidbody.AddForce(cam.transform.TransformDirection(Vector3.forward) * 300);
                pickObj = null;
            }
        }
        if (Input.GetMouseButtonDown(0) && WorldGlobal.isReadyToFire)
        {
            if (pickObj == null)
            {
                ShootPaint(currentActivePaint);
            }
            else
            {
                //Add force to cube and send it flying
                //shootOBJ();
                //pickObj.rigidbody.AddForce(cam.transform.TransformDirection(Vector3.forward) * 300);
                pickObj.rigidbody.AddForce(cam.transform.TransformDirection(Vector3.forward) * 300 + (characterValues.Vel * 20));
                pickObj = null;
            }
        }


        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            if (ammoType[0] != null)
            {
                currentActivePaint = ammoType[0];
                coreInstance.renderer.material.color = currentActivePaint.ballColor;
            }
        }
        else if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            if (ammoType[1] != null)
            {
                currentActivePaint = ammoType[1];
                coreInstance.renderer.material.color = currentActivePaint.ballColor;
            }
        }
        else if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            if (ammoType[2] != null)
            {
                currentActivePaint = ammoType[2];
                coreInstance.renderer.material.color = currentActivePaint.ballColor;
            }
        }
        else if (Input.GetKeyDown(KeyCode.Alpha4))
        {
            if (ammoType[3] != null)
            {
                currentActivePaint = ammoType[3];
                coreInstance.renderer.material.color = currentActivePaint.ballColor;
            }
        }
        else if (Input.GetKeyDown(KeyCode.Alpha5))
        {
            if (ammoType[4] != null)
            {
                currentActivePaint = ammoType[4];
                coreInstance.renderer.material.color = currentActivePaint.ballColor;
            }
        }
        else if (Input.GetKeyDown(KeyCode.Alpha6))
        {
            if (ammoType[5] != null)
            {
                currentActivePaint = ammoType[5];
                coreInstance.renderer.material.color = currentActivePaint.ballColor;
            }
        }

        if (Input.GetKeyDown(KeyCode.E))
        {
            toggleObject();
        }

        if (Input.GetKey(KeyCode.B))
        {
            painGun.SetActive(true);
        }

        if (Input.GetAxis("Mouse ScrollWheel") != 0)
        {
            if (pickObj != null)
            {
                if ((pickDist >= 1.3) && (Input.GetAxis("Mouse ScrollWheel") < 0))
                {
                    Debug.Log("Out");
                    pickDist += Input.GetAxis("Mouse ScrollWheel") * 3;
                }
                else if (pickDist <= 3 && (Input.GetAxis("Mouse ScrollWheel") > 0))
                {
                    Debug.Log("In");
                    pickDist += Input.GetAxis("Mouse ScrollWheel") * 3;
                }
            }
        }

        //Hold object in place
        if (pickObj != null)
        {
            //Make a new raycast to where we are pointing
            Ray pickRay = new Ray(paintSpawn.position, paintSpawn.TransformDirection(Vector3.left));
            //Move the object we've picked up to the previously defined ray position
            pickObj.rigidbody.MovePosition(pickRay.GetPoint(pickDist));
            if (pickHit.rigidbody && !pickHit.rigidbody.isKinematic)
            {
                pickHit.rigidbody.velocity = Vector3.zero;
            }
        }
    }
Beispiel #16
0
 public static extern bool EndPaint(IntPtr hWnd, ref PaintStruct ps);
Beispiel #17
0
 public static extern IntPtr BeginPaint(IntPtr hWnd, ref PaintStruct ps);
Beispiel #18
0
 void setMyPaint(PaintStruct paintIN)
 {
     myPaint                 = paintIN;
     renderer.material       = myPaint.material;
     renderer.material.color = myPaint.ballColor;
 }
Beispiel #19
0
 public static extern bool EndPaint([In] HWnd hWnd, [In] ref PaintStruct hDC);
Beispiel #20
0
 protected virtual void OnGlPaint(ref PaintStruct ps)
 {
 }