Пример #1
0
 //这个方法会在道具发动时调用
 protected override bool ItemStart()
 {
     go = resources;
     pi = owner.GetComponent <PlayerInfo>();
     //go.AddComponent<DestroyForTime>().time = parameters.TryGet("CD");
     go.transform.parent = owner.GetComponent <PlayerInfo>().Player.Reference.transform;
     go.SetActive(true);
     go.transform.position = Position;
     go.tag = "Fish";
     test   = owner.GetComponent <VisualTest>();
     if (test != null)
     {
         go.AddComponent <VisualTest>();
     }
     else
     {
         VisualProvider vp = go.AddComponent <VisualProvider>();
         vp.noOcclusion = true;
         vp.visualRange = parameters.TryGet("Range");
     }
     if (pi.VisualTest != null)
     {
         if (pi.VisualTest.InVisual())
         {
             GameFacade.Instance.PlaySound("Tower");
         }
     }
     else
     {
         GameFacade.Instance.PlaySound("Tower");
     }
     return(true);
 }
Пример #2
0
        private IntPtr MouseHookProc(int code, IntPtr wParam, IntPtr lParam)
        {
            try
            {
                if (code >= 0 && IsDragging)
                {
                    if ((Win32.MouseMessages)wParam == Win32.MouseMessages.WM_LBUTTONDOWN)
                    {
                        Win32.MSLLHOOKSTRUCT hookStruct = (Win32.MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(Win32.MSLLHOOKSTRUCT));
                        Console.WriteLine("DOWN: " + hookStruct.pt.x + ", " + hookStruct.pt.y);
                    }
                    else if ((Win32.MouseMessages)wParam == Win32.MouseMessages.WM_MOUSEMOVE)
                    {
                        Win32.MSLLHOOKSTRUCT hookStruct = (Win32.MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(Win32.MSLLHOOKSTRUCT));
                        Console.WriteLine("MOVE: " + hookStruct.pt.x + ", " + hookStruct.pt.y);

                        VisualProvider?.UpdateVisualPosition(new Point(hookStruct.pt.x, hookStruct.pt.y));
                    }
                    else if ((Win32.MouseMessages)wParam == Win32.MouseMessages.WM_LBUTTONUP)
                    {
                        Win32.MSLLHOOKSTRUCT hookStruct = (Win32.MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(Win32.MSLLHOOKSTRUCT));
                        Console.WriteLine("UP: " + hookStruct.pt.x + ", " + hookStruct.pt.y);

                        DragRelease(new Point(hookStruct.pt.x, hookStruct.pt.y));
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("MouseHookProc: " + ex.ToString());
            }

            return(Win32.CallNextHookEx(hMouseHook, code, wParam, lParam));
        }
Пример #3
0
 public void TryToLogout(VisualProvider vp)
 {
     if (vp.id == 0)
     {
         return;
     }
     IDs[vp.id] = false;
     vp.id      = 0;
     visualProviders.Remove(vp.id);
 }
Пример #4
0
 private bool IsInTrueVision(VisualProvider vp)
 {
     if (TrueVisionCheck == false)
     {
         isInTrueVision = false;
         return(false);
     }
     isInTrueVision = vp.IsTrueVision;
     return(vp.IsTrueVision);
 }
Пример #5
0
        public async Task <DropEventArgs> DoDragDrop(object data)
        {
            dragDropTcs = new TaskCompletionSource <DropEventArgs>();

            this.IsDragging = true;
            this.dragObject = data;

            VisualProvider?.ShowVisual(data, CursorHelper.GetRawCursorPosition());

            return(await dragDropTcs.Task);
        }
Пример #6
0
 public void Logout(VisualProvider vp)
 {
     if (vp.id == 0)
     {
         Debug.Log("You are trying to logout a visual provider which has not been registered yet.");
         return;
     }
     IDs[vp.id] = false;
     vp.id      = 0;
     visualProviders.Remove(vp.id);
 }
Пример #7
0
        private async Task DragRelease(Point dropPoint)
        {
            this.IsDragging = false;

            VisualProvider?.UpdateVisualPosition(dropPoint);

            // Fire relevant callback function if dropped in a dropSurface
            foreach (var dropSurface in dropSurfaces)
            {
                if (dropSurface.IsMouseOver)
                {
                    var dpi                    = VisualTreeHelper.GetDpi(dropSurface);
                    var scaledPoint            = new Point(dropPoint.X / dpi.DpiScaleX, dropPoint.Y / dpi.DpiScaleY);
                    var dropSurfaceScreenPoint = dropSurface.PointToScreen(new Point(0, 0));
                    var relativePoint          = new Point(scaledPoint.X - dropSurfaceScreenPoint.X,
                                                           scaledPoint.Y - dropSurfaceScreenPoint.Y);

                    var dropArgs = new DropEventArgs
                    {
                        Result = DragDropResult.DroppedToExistingWindow,
                        Data   = this.dragObject,
                        RelativeMousePosition = relativePoint,
                        DropSurface           = dropSurface,
                    };

                    dropSurfaceData[dropSurface].DropCallback(dropArgs);
                    VisualProvider?.CloseVisual(dropArgs);
                    dragDropTcs.SetResult(dropArgs);
                    return;
                }
            }

            // Fire event if dropped was not in any dropSurface

            var newWindowDropArgs = new DropEventArgs
            {
                Result                = DragDropResult.NewWindowRequested,
                Data                  = this.dragObject,
                DropSurface           = null,
                RelativeMousePosition = dropPoint,
            };

            if (VisualProvider != null)
            {
                var newWindowPosition = await VisualProvider.CloseVisual(newWindowDropArgs);

                newWindowDropArgs.RelativeMousePosition = newWindowPosition;
            }

            dragDropTcs.SetResult(newWindowDropArgs);
        }
Пример #8
0
    public void Register(VisualProvider vp)
    {
        if (vp.id != 0)
        {
            return;
        }
        ushort id = (ushort)Random.Range(1, 65536);

        while (IDs[id] == true)
        {
            id += 1;
        }
        IDs[id] = true;
        vp.id   = id;

        visualProviders.Add(id, vp);
    }
Пример #9
0
    void FixedUpdate()
    {
        if (!active_)
        {
            return;
        }
        if (remainTime > 0)
        {
            remainTime -= Time.deltaTime;
            return;
        }
        remainTime = refreshInterval;

        ViewProvider[] viewProviders;
        {
            List <ViewProvider> vPList = new List <ViewProvider>();
            Matrix4x4           mvp_mt = occlusionCamera.projectionMatrix * occlusionCamera.worldToCameraMatrix;
            foreach (var keyValuePair in visualProviders)
            {
                VisualProvider vp = keyValuePair.Value;
                if (!vp.active)
                {
                    continue;
                }
                ViewProvider pos = vp.transform.position;
                pos.w = 1;
                pos   = mvp_mt * pos;
                pos.w = vp.visualRange;
                if (pos.w != 0)
                {
                    if (pos.x > 1.2 || pos.y > 1.2 || pos.x < -1.2 || pos.y < -1.2)
                    {
                        continue;
                    }
                    if (vp.noOcclusion)
                    {
                        pos.z = 0;
                    }
                    vPList.Add(pos);
                }
            }
            viewProviders = vPList.ToArray();
        }//generate data
        if (viewProviders.Length != 0)
        {
            ComputeBuffer cb = new ComputeBuffer(viewProviders.Length, 16);
            cb.SetData(viewProviders);
            fogCalculator.SetBuffer(MainHandle, "viewProviders", cb);
            fogCalculator.SetTexture(MainHandle, "_OcclusionMap", miniMapTexture);
            fogCalculator.SetTexture(MainHandle, "_FogMap", fogMap);
            fogCalculator.SetFloat("scale", 0.5f / occlusionCamera.orthographicSize);
            fogCalculator.SetFloat("resolution", mapResolution);
            ViewProvider[] output = new ViewProvider[5];
            int            size   = Mathf.Clamp(viewProviders.Length / 32, 1, 1000);

            fogCalculator.Dispatch(MainHandle, size, 1, 1);
            cb.GetData(output);
            cb.Dispose();
            if (openGaussian)
            {
                Filter(fogMap);
            }
        }

        fogCalculator.SetTexture(ProduceFinalMapHandle, "_FogMap", fogMap);
        fogCalculator.Dispatch(ProduceFinalMapHandle, mapResolution / 8, mapResolution / 8, 1);

        Matrix4x4 m = occlusionCamera.projectionMatrix * occlusionCamera.worldToCameraMatrix;

        fogMaterial.SetMatrix("_OcclusionCamera_MVP", m);
    }