Пример #1
0
        //private void BufGain(AIBaseClient sender, AIBaseClientBuffGainEventArgs args)
        //{
        //    if (sender.IsMe)
        //    {
        //        Game.Print(args.Buff.Name);
        //    }
        //}

        private static void DrawingOnOnDraw(EventArgs args)
        {
            var drawQ     = Menu["Drawing"].GetValue <MenuBool>("DrawQ");
            var drawE     = Menu["Drawing"].GetValue <MenuBool>("DrawE");
            var drawR     = Menu["Drawing"].GetValue <MenuBool>("DrawR");
            var drawRPred = Menu["Drawing"].GetValue <MenuBool>("DrawRPred");
            var p         = Player.Position;

            if (drawQ)
            {
                Render.Circle.DrawCircle(p, Q.Range, Q.IsReady() ? System.Drawing.Color.Aqua : System.Drawing.Color.Red);
            }

            if (drawE)
            {
                Render.Circle.DrawCircle(p, E.Range, E.IsReady() ? System.Drawing.Color.Aqua : System.Drawing.Color.Red);
            }

            if (drawR)
            {
                Render.Circle.DrawCircle(p, R.Range, R.IsReady() ? System.Drawing.Color.Aqua : System.Drawing.Color.Red);
            }

            if (drawRPred && R.IsReady() && DrawTarget.IsValidTarget())
            {
                RRectangle.Draw(System.Drawing.Color.CornflowerBlue, 3);
            }
        }
Пример #2
0
 /// <summary>
 /// 描画を行います。
 /// </summary>
 private static void Draw(object sender, EventArgs e)
 {
     if (Media.NextTarget != null)
     {
         //シングルスレッドで描画準備を行う
         Media.DrawTask.Enabled = false;
         Media.Target           = Media.NextTarget;
         Media.Init(Media.NextTarget.DrawDest);
         Media.Target.LoadMaterial();
         Media.NextTarget       = null;
         Media.DrawTask.Enabled = true;
     }
     else if (Media.Target != null && !Media.StopDraw)
     {
         Target.SetDXInterpolation();
         if (DX.GetASyncLoadNum() == 0 && Target.TargetControl.Visible)
         {
             //読み込みが完了している場合のみ描画
             Target.ClsScreen();
             Target.Draw();
             DX.ScreenFlip();
         }
         else
         {
             //非同期読み込みを続行
             DX.ProcessMessage();
         }
     }
 }
Пример #3
0
        private static void DrawingOnOnDraw(EventArgs args)
        {
            var drawQ     = Menu.Item("DrawQ").IsActive();
            var drawE     = Menu.Item("DrawE").IsActive();
            var drawR     = Menu.Item("DrawR").IsActive();
            var drawRPred = Menu.Item("DrawRPred").IsActive();
            var p         = Player.Position;

            if (drawQ)
            {
                Render.Circle.DrawCircle(p, Q.Range, Q.IsReady() ? Color.Aqua : Color.Red);
            }

            if (drawE)
            {
                Render.Circle.DrawCircle(p, E.Range, E.IsReady() ? Color.Aqua : Color.Red);
            }

            if (drawR)
            {
                Render.Circle.DrawCircle(p, R.Range, R.IsReady() ? Color.Aqua : Color.Red);
            }

            if (drawRPred && R.IsReady() && DrawTarget.IsValidTarget())
            {
                RRectangle.Draw(Color.CornflowerBlue, 3);
            }
        }
Пример #4
0
        private static void DrawingOnOnDraw(EventArgs args)
        {
            var drawQ     = drawMenu["DrawQ"].Cast <CheckBox>().CurrentValue;
            var drawE     = drawMenu["DrawE"].Cast <CheckBox>().CurrentValue;
            var drawR     = drawMenu["DrawR"].Cast <CheckBox>().CurrentValue;
            var drawRPred = drawMenu["DrawRPred"].Cast <CheckBox>().CurrentValue;
            var p         = Player.Position;

            if (drawQ)
            {
                Circle.Draw(Q.IsReady() ? Color.Aqua : Color.Red, Q.Range, p);
            }

            if (drawE)
            {
                Circle.Draw(E.IsReady() ? Color.Aqua : Color.Red, E.Range, p);
            }

            if (drawR)
            {
                Circle.Draw(R.IsReady() ? Color.Aqua : Color.Red, R.Range, p);
            }

            if (drawRPred && R.IsReady() && DrawTarget.IsValidTarget())
            {
                RRectangle.Draw(System.Drawing.Color.CornflowerBlue, 3);
            }
        }
        /// <summary>
        /// Draws a single Pixel
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="p">Pixel color (leave null for white)</param>
        /// <returns></returns>
        public virtual bool Draw(uint x, uint y, Pixel p)
        {
            if (DrawTarget == null)
            {
                return(false);
            }

            if (p == default(Pixel))
            {
                p = Pixel.WHITE;
            }

            if (PixelBlendMode == BlendMode.NORMAL)
            {
                return(DrawTarget.SetPixel(x, y, p));
            }

            if (PixelBlendMode == BlendMode.MASK)
            {
                if (p.a == 255)
                {
                    return(DrawTarget.SetPixel(x, y, p));
                }
            }

            if (PixelBlendMode == BlendMode.ALPHA)
            {
            }

            if (PixelBlendMode == BlendMode.CUSTOM)
            {
            }

            return(false);
        }
Пример #6
0
        //Kártya húzás: Modellből adatok lekérése és továbbítása a megfelelő játékos oldalnak.
        private void DrawTheCard(int key, DrawTarget target, DrawType drawType, SkillState newState)
        {
            Card cardData = null;

            if (target == DrawTarget.Hand && !controller.GetBlindMatchState())
            {
                cardData = modules.GetDataModule().GetPlayerWithKey(key).DrawCardFromDeck();
            }

            else if (controller.GetBlindMatchState() || target == DrawTarget.Field)
            {
                cardData = modules.GetDataModule().GetPlayerWithKey(key).BlindDraw();
            }

            //Ha a felhúzás sikeres
            if (cardData != null)
            {
                modules.GetClientModule().DrawNewCard(cardData, key, modules.GetDataModule().GetPlayerWithKey(key).GetPlayerStatus(), drawType, target, newState);

                //Ha a játékosról van szó továbbítjuk megjelenítésre a deck új méretét
                if (modules.GetDataModule().GetPlayerWithKey(key).GetPlayerStatus())
                {
                    int remainingDeckSize = modules.GetDataModule().GetPlayerWithKey(key).GetDeckSize();
                    modules.GetClientModule().RefreshDeckSize(key, remainingDeckSize);
                }
            }
        }
Пример #7
0
        private static void DrawingOnOnDraw(EventArgs args)
        {
            var drawQ     = Getcheckboxvalue(drawMenu, "DrawQ");
            var drawE     = Getcheckboxvalue(drawMenu, "DrawE");
            var drawR     = Getcheckboxvalue(drawMenu, "DrawR");
            var drawRPred = Getcheckboxvalue(drawMenu, "DrawRPred");
            var p         = Player.Position;

            if (drawQ)
            {
                Drawing.DrawCircle(p, Q.Range, Q.IsReady() ? Color.Aqua : Color.Red);
            }

            if (drawE)
            {
                Drawing.DrawCircle(p, E.Range, E.IsReady() ? Color.Aqua : Color.Red);
            }

            if (drawR)
            {
                Drawing.DrawCircle(p, R.Range, R.IsReady() ? Color.Aqua : Color.Red);
            }

            if (drawRPred && R.IsReady() && DrawTarget.IsValidTarget())
            {
                RRectangle.Draw(Color.CornflowerBlue, 3);
            }
        }
Пример #8
0
        private static void GameOnOnUpdate(EventArgs args)
        {
            DrawTarget = TargetSelector.GetTarget(R.Range, DamageType.Magical);

            if (DrawTarget.IsValidTarget())
            {
                RRectangle.Start = Player.Position.To2D();
                RRectangle.End   = R.GetPrediction(DrawTarget).CastPosition.To2D();
                RRectangle.UpdatePolygon();
            }

            if (!Player.CanCast)
            {
                return;
            }

            switch (Orbwalker.ActiveModesFlags)
            {
            case Orbwalker.ActiveModes.Harass:
                DoHarass();
                break;

            case Orbwalker.ActiveModes.Combo:
                DoCombo();
                break;

            case Orbwalker.ActiveModes.JungleClear:
                Jungleclear();
                break;

            case Orbwalker.ActiveModes.LaneClear:
                Laneclear();
                break;
            }
        }
Пример #9
0
        private static void GameOnOnUpdate(EventArgs args)
        {
            DrawTarget = TargetSelector.GetTarget(R.Range);

            if (DrawTarget.IsValidTarget())
            {
                RRectangle.Start = Player.Position.ToVector2();
                RRectangle.End   = R.GetPrediction(DrawTarget).CastPosition.ToVector2();
                RRectangle.UpdatePolygon();
            }

            if (!Player.CanCast)
            {
                return;
            }

            switch (Orbwalker.ActiveMode)
            {
            case OrbwalkerMode.Harass:
                DoHarass();
                break;

            case OrbwalkerMode.Combo:
                DoCombo();
                break;
            }
        }
Пример #10
0
        public DrawTarget[] GetDrawTargets()
        {
            var drawTarget = new DrawTarget
            {
                ImageWrapper = this,
            };

            return(new[] { drawTarget });
        }
Пример #11
0
        private IEnumerator DrawCardAction(int currentKey, int amount, DrawTarget target, DrawType drawType, SkillState newState)
        {
            for (var i = 0; i < amount; i++)
            {
                DrawTheCard(currentKey, target, drawType, newState);
                yield return(new WaitForSeconds(GameSettings_Controller.drawTempo));
            }

            controller.ActionFinished();
        }
        //Felhúz megadott számú lapot a megadott játékosnak
        public IEnumerator DrawCardsUp(int key, int amount = 1, DrawTarget target = DrawTarget.Hand, DrawType drawType = DrawType.Normal, SkillState newState = SkillState.NotDecided)
        {
            for (var i = 0; i < amount; i++)
            {
                DrawTheCard(key, target, drawType, newState);
                yield return(new WaitForSeconds(GameSettings_Controller.drawTempo));
            }

            ActionFinished();
        }
Пример #13
0
 /// <summary>
 /// 描画先を変更します。
 /// </summary>
 /// <param name="hdl">描画先のハンドル</param>
 public static void ChangeDest(DrawTarget obj)
 {
     Media.StopDraw   = false;
     Media.Target     = null;
     Media.NextTarget = obj;
     if (!Media.Setupped)
     {
         Media.Init(obj.DrawDest);
     }
     Media.DrawTask.Enabled = true;
 }
Пример #14
0
        private static void GameOnUpdate(EventArgs args)
        {
            DrawTarget = TargetSelector.GetTarget(R.Range, DamageType.Magical);

            if (DrawTarget.IsValidTarget())
            {
                Qpredictions.Start = Blitz.Position.To2D();
                Qpredictions.End   = Q.GetPrediction(DrawTarget).CastPosition.To2D();
                Qpredictions.UpdatePolygon();
            }
            if (Orbwalker.ActiveModesFlags.HasFlag(Orbwalker.ActiveModes.Combo))
            {
                ByCombo();
            }
            AutoLogic();
        }
Пример #15
0
        internal SinglePassTextureFilter(DrawTargetTexture2D source, DrawTargetTexture2D target)
        {
            if (source == null || target == null)
            {
                throw new ArgumentNullException();
            }
            if (source.SurfaceFormat != target.SurfaceFormat)
            {
                throw new ArgumentException("source.SurfaceFormat != target.SurfaceFormat");
            }
#if XBOX360
            if (source == target && source.Width * source.Height * DrawTarget.FormatSize(source.SurfaceFormat) >
                1000 * 1000 * 10)            //approx 10mb
            {
                throw new ArgumentException("source == target is invalid for larget render targets on Xbox360");
            }
#else
            if (source == target)
            {
                throw new ArgumentException("source == target is invalid on windows");
            }
#endif
            if (source.Width > target.Width ||
                source.Height > target.Height)
            {
                throw new ArgumentException("source is larger than target");
            }

            this.source      = source;
            this.targetClone = target.Clone(false, false, false);

            this.targetClone.ClearBuffer.Enabled = false;

            this.element = new ShaderElement(null, source.Width, source.Height, new Vector2(1, 1), true);
            this.targetClone.Add(element);

            if (target.Width != source.Width ||
                target.Height != source.Height)
            {
                this.targetClone.AddModifier(new Xen.Graphics.Modifier.ScissorModifier(0, 0, Math.Min(1, (source.Width) / target.Width), Math.Min(1, (source.Height) / target.Height)));
                this.element.TextureCrop = new Rectangle(0, 0, Math.Min(this.source.Width, this.targetClone.Width), Math.Min(this.source.Height, this.targetClone.Height));
            }
        }
Пример #16
0
        private List <Fragment> LinearInterpolation(DrawTarget mode, int count, DrawElementsType type, IntPtr indices, VertexArrayObject vao, ShaderProgram program, GLBuffer indexBuffer, PassBuffer[] passBuffers)
        {
            List <Fragment> result = null;

            switch (mode)
            {
            case DrawTarget.Points: result = LinearInterpolationPoints(count, type, indices, vao, program, indexBuffer, passBuffers); break;

            case DrawTarget.Lines: result = LinearInterpolationLines(count, type, indices, vao, program, indexBuffer, passBuffers); break;

            case DrawTarget.LineLoop: result = LinearInterpolationLineLoop(count, type, indices, vao, program, indexBuffer, passBuffers); break;

            case DrawTarget.LineStrip: result = LinearInterpolationLineStrip(count, type, indices, vao, program, indexBuffer, passBuffers); break;

            case DrawTarget.Triangles: result = LinearInterpolationTriangles(count, type, indices, vao, program, indexBuffer, passBuffers); break;

            case DrawTarget.TriangleStrip: result = LinearInterpolationTriangleStrip(count, type, indices, vao, program, indexBuffer, passBuffers); break;

            case DrawTarget.TriangleFan: result = LinearInterpolationTriangleFan(count, type, indices, vao, program, indexBuffer, passBuffers); break;

            case DrawTarget.Quads: result = LinearInterpolationQuads(count, type, indices, vao, program, indexBuffer, passBuffers); break;

            case DrawTarget.QuadStrip: result = LinearInterpolationQuadStrip(count, type, indices, vao, program, indexBuffer, passBuffers); break;

            case DrawTarget.Polygon: result = LinearInterpolationPolygon(count, type, indices, vao, program, indexBuffer, passBuffers); break;

            case DrawTarget.LinesAdjacency: result = LinearInterpolationLinesAdjacency(count, type, indices, vao, program, indexBuffer, passBuffers); break;

            case DrawTarget.LineStripAdjacency: result = LinearInterpolationLineStripAdjacency(count, type, indices, vao, program, indexBuffer, passBuffers); break;

            case DrawTarget.TrianglesAdjacency: result = LinearInterpolationTrianglesAdjacency(count, type, indices, vao, program, indexBuffer, passBuffers); break;

            case DrawTarget.TriangleStripAdjacency: result = LinearInterpolationTriangleStripAdjacency(count, type, indices, vao, program, indexBuffer, passBuffers); break;

            case DrawTarget.Patches: result = LinearInterpolationPatches(count, type, indices, vao, program, indexBuffer, passBuffers); break;

            default: throw new NotDealWithNewEnumItemException(typeof(DrawTarget));
            }

            return(result);
        }
        //Kártya húzás: Modellből adatok lekérése és továbbítása a megfelelő játékos oldalnak.
        public void DrawTheCard(int key, DrawTarget target = DrawTarget.Hand, DrawType drawType = DrawType.Normal, SkillState newState = SkillState.NotDecided)
        {
            Card cardData = null;

            if (target == DrawTarget.Hand && !blindMatch)
            {
                cardData = modules.GetDataModule().GetPlayerWithKey(key).DrawCardFromDeck();
            }

            else if (blindMatch || target == DrawTarget.Field)
            {
                cardData = modules.GetDataModule().GetPlayerWithKey(key).BlindDraw();
            }

            //Ha a felhúzás sikeres
            if (cardData != null)
            {
                modules.GetClientModule().DrawNewCard(cardData, key, modules.GetDataModule().GetPlayerWithKey(key).GetPlayerStatus(), drawType, target, newState);

                //Ha a játékosról van szó továbbítjuk megjelenítésre a deck új méretét
                if (modules.GetDataModule().GetPlayerWithKey(key).GetPlayerStatus())
                {
                    int remainingDeckSize = modules.GetDataModule().GetPlayerWithKey(key).GetDeckSize();
                    modules.GetClientModule().RefreshDeckSize(key, remainingDeckSize);
                }
            }

            //Ha vakharc esetén valaki már nem tud pakliból húzni: játék vége
            else if (cardData == null && blindMatch)
            {
                StartCoroutine(modules.GetClientModule().DisplayNotification(modules.GetDataModule().GetPlayerWithKey(key).GetUsername() + " paklija elfogyott!\nJáték vége!"));
                StartCoroutine(WaitForText());

                ChangePhase(MainGameStates.CreateResult);
            }



            //Amúgy addig megy a játék, amíg a kézből is elfogynak a lapok
        }
Пример #18
0
        private static void Draws_OnComple(EventArgs args)
        {
            var drawQ    = Getcheckboxvalue(Blits, "drawQ");
            var drawR    = Getcheckboxvalue(Blits, "drawR");
            var drawQint = Getcheckboxvalue(Blits, "Qint");

            var position = Blitz.Position;

            if (drawQ && Q.IsReady())
            {
                Circle.Draw(Color.LightBlue, Q.Range, Player.Instance.Position);
            }

            if (drawR)
            {
                Circle.Draw(Color.Red, R.Range, Player.Instance.Position);
            }

            if (drawQint && Q.IsReady() && DrawTarget.IsValidTarget())
            {
                Qpredictions.Draw(System.Drawing.Color.CornflowerBlue, 3);
            }
        }
Пример #19
0
        /// <summary>
        /// Blur the source horizontally to the <paramref name="intermediate"/> target, then blur vertically to <paramref name="target"/>.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="filterFormat">format of the blur filter</param>
        /// <param name="intermediate">draw target to use as a temporary, intermediate target for blurring</param>
        /// <param name="target"></param>
        /// <param name="bellCurveExponent">
        /// <para>A scale value to infulence the bell curve used to generate the filter kernel.</para>
        /// <para>A value of 1.0 generates a standard blur filter kernels. Larger values will produce a tighter curve, and less blur.</para>
        /// <para>Smaller values will produce a wider curve, and a larger blur - but may produce a visible edge as the curve more rapidly ends.</para>
        /// </param>
        public BlurFilter(BlurFilterFormat filterFormat, float bellCurveExponent, DrawTargetTexture2D source, DrawTargetTexture2D intermediate, DrawTargetTexture2D target)
        {
            if (target == null || source == null)
            {
                throw new ArgumentNullException();
            }

            if (intermediate != null && source.SurfaceFormat != intermediate.SurfaceFormat)
            {
                throw new ArgumentException("source.SurfaceFormat != intermediate.SurfaceFormat");
            }
            if (intermediate != null && target.SurfaceFormat != intermediate.SurfaceFormat)
            {
                throw new ArgumentException("target.SurfaceFormat != intermediate.SurfaceFormat");
            }

            this.source = source;

#if XBOX360
            //if the surface will fit into EDRAM then the intermediate can be skipped
            if (source.Width * source.Height * DrawTarget.FormatSize(source.SurfaceFormat) < 1000 * 1000 * 10)  //approx
            {
                this.filterV = new SinglePassTextureFilter(source, target);
                this.filterH = new SinglePassTextureFilter(target, target);
            }
            else
            {
                this.filterV = new SinglePassTextureFilter(source, intermediate);
                this.filterH = new SinglePassTextureFilter(intermediate, source);
            }
#else
            this.filterV = new SinglePassTextureFilter(source, intermediate);
            this.filterH = new SinglePassTextureFilter(intermediate, target);
#endif

            SetFilterFormat(filterFormat, bellCurveExponent);
        }
Пример #20
0
        private void DrawElements(DrawTarget mode, int count, DrawElementsType type, IntPtr indices)
        {
            if (!Enum.IsDefined(typeof(DrawTarget), mode) || !Enum.IsDefined(typeof(DrawElementsType), type))
            {
                SetLastError(ErrorCode.InvalidEnum); return;
            }
            if (count < 0)
            {
                SetLastError(ErrorCode.InvalidValue); return;
            }
            // TODO: GL_INVALID_OPERATION is generated if a geometry shader is active and mode​ is incompatible with the input primitive type of the geometry shader in the currently installed program object.
            // TODO: GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to an enabled array or the element array and the buffer object's data store is currently mapped.

            VertexArrayObject vao = this.currentVertexArrayObject; // data structure.

            if (vao == null)
            {
                return;
            }
            ShaderProgram program = this.currentShaderProgram; // algorithm.

            if (program == null)
            {
                return;
            }
            GLBuffer indexBuffer = this.currentBufferDict[BindBufferTarget.ElementArrayBuffer];

            if (indexBuffer == null)
            {
                return;
            }

            // execute vertex shader for each vertex!
            // This is a low effetient implementation.
            // passBuffers is input for the next stage: linear interpolation.
            // passBuffers[0] is gl_Position.
            // passBuffers[others] are attributes of vertexes.
            PassBuffer[] passBuffers = VertexShaderStage(count, type, indices, vao, program, indexBuffer);
            if (passBuffers == null)
            {
                return;
            }                                    // this stage failed.

            Framebuffer framebuffer = this.currentFramebuffer;

            if (framebuffer == null)
            {
                throw new Exception("This should not happen!");
            }

            ClipSpace2NormalDeviceSpace(passBuffers[0]);
            // linear interpolation.
            List <Fragment> fragmentList = LinearInterpolation(mode, count, type, indices, vao, program, indexBuffer, passBuffers);

            // execute fargment shader for each fragment!
            // This is a low effetient implementation.
            FragmentShaderStage(program, fragmentList);
            {
                int index = 0;
                while (index < fragmentList.Count)
                {
                    if (fragmentList[index].discard)
                    {
                        fragmentList.RemoveAt(index);
                    }
                    else
                    {
                        index++;
                    }
                }
            }
            // Scissor test

            // Multisampel fragment operations

            // Stencil test

            // Depth test
            DepthTest(fragmentList);

            //Blending

            // Dithering

            // Logical operations

            // write fragments to framebuffer's colorbuffer attachment(s).
            {
                uint[] drawBufferIndexes = framebuffer.DrawBuffers.ToArray();
                foreach (var fragment in fragmentList)
                {
                    if (fragment.depthTestFailed)
                    {
                        continue;
                    }

                    for (int i = 0; i < fragment.outVariables.Length && i < drawBufferIndexes.Length; i++)
                    {
                        PassBuffer  outVar     = fragment.outVariables[i];
                        IAttachable attachment = framebuffer.ColorbufferAttachments[drawBufferIndexes[i].ToIndex()];
                        attachment.Set((int)fragment.gl_FragCoord.x, (int)fragment.gl_FragCoord.y, outVar);
                    }
                }
            }
        }
Пример #21
0
        /// <summary>
        /// Construct the texture downsampler
        /// </summary>
        /// <param name="source">Source texture to read</param>
        /// <param name="target">Target texture to write to</param>
        /// <param name="intermediate">Intermediate texture (if null, will be created as required)</param>
        /// <param name="intermediate2">Second intermediate texture (if null, will be created as required)</param>
        /// <param name="targetWidth">target width to downsample to</param>
        /// <param name="targetHeight">target height to downsample to</param>
        public TextureDownsample(DrawTargetTexture2D source, DrawTargetTexture2D target, ref DrawTargetTexture2D intermediate, ref DrawTargetTexture2D intermediate2, int targetWidth, int targetHeight)
        {
            if (source == null ||
                target == null)
            {
                throw new ArgumentNullException();
            }

            if (targetWidth <= 0 ||
                targetHeight <= 0)
            {
                throw new ArgumentException("Invalid target size");
            }

            if (DrawTarget.FormatChannels(source.SurfaceFormat) != DrawTarget.FormatChannels(target.SurfaceFormat))
            {
                throw new ArgumentException("source.SurfaceFormat has a different number of channels than target.SurfaceFormat");
            }

            if (targetWidth > target.Width ||
                targetHeight > target.Height)
            {
                throw new ArgumentException("Size is larger than target");
            }

            if (targetWidth > source.Width ||
                targetHeight > source.Height)
            {
                throw new ArgumentException("Size is larger than source");
            }

            if (intermediate != null)
            {
                if (target.SurfaceFormat != intermediate.SurfaceFormat)
                {
                    throw new ArgumentException("target.SurfaceFormat != intermediate.SurfaceFormat");
                }
                if (intermediate == intermediate2)
                {
                    throw new ArgumentException("intermediate == intermediate2");
                }
            }
            if (intermediate2 != null)
            {
                if (target.SurfaceFormat != intermediate2.SurfaceFormat)
                {
                    throw new ArgumentException("target.SurfaceFormat != intermediate2.SurfaceFormat");
                }
            }

            int w = source.Width;
            int h = source.Height;

            int targetMultipleWidth  = targetWidth;
            int targetMultipleHeight = targetHeight;

            while (targetMultipleWidth * 2 <= w)
            {
                targetMultipleWidth *= 2;
            }
            while (targetMultipleHeight * 2 <= h)
            {
                targetMultipleHeight *= 2;
            }

            DrawTargetTexture2D current = null;
            Rectangle           sRegion = new Rectangle(0, 0, 0, 0);

            //first pass may require that the source is sized down to a multiple of the target size

            if ((double)targetWidth / (double)w <= 0.5 &&
                (double)targetHeight / (double)h <= 0.5 &&
                (targetMultipleWidth != w || targetMultipleHeight != h))
            {
                DrawTargetTexture2D go = this.PickRT(ref intermediate, ref intermediate2, source, targetMultipleWidth, targetMultipleHeight, target.SurfaceFormat);

                Vector2 size = new Vector2((float)targetMultipleWidth, (float)targetMultipleHeight);

                TexturedElement te = new TexturedElement(source, size, false);
                te.TextureCrop = new Rectangle(0, 0, w, h);

                go.Add(te);
                passes.Add(go);
                current = go;
                w       = targetMultipleWidth;
                h       = targetMultipleHeight;
            }

            //downsample on the larger axis, either 2x, 4x or 8x downsampling, until reached the target size

            while (target.Equals(current) == false)
            {
                DrawTargetTexture2D localSource = current ?? source;

                double difW = (double)targetWidth / (double)w;
                double difH = (double)targetHeight / (double)h;

                sRegion.Width  = w;
                sRegion.Height = h;
                sRegion.Y      = localSource.Height - h;

                //both width/height difference are less than 50% smaller, so a linear interpolation will do fine
                if (difW > 0.5 &&
                    difH > 0.5)
                {
                    //write directly to the target
                    DrawTargetTexture2D go      = target.Clone(false, false, false);
                    Vector2             te_size = new Vector2((float)targetWidth, (float)targetHeight);
                    TexturedElement     te      = new TexturedElement(localSource, te_size, false);

                    go.AddModifier(new ScissorModifier(0, go.Height - targetHeight, targetWidth, go.Height, go));
                    te.TextureCrop = sRegion;

                    go.Add(te);
                    passes.Add(go);
                    current = go;

                    continue;
                }

                bool   horizontal = difW < difH;
                double dif        = Math.Min(difW, difH);
                int    size       = horizontal ? w : h;

                Vector2 dir = new Vector2(0, 0);
                if (horizontal)
                {
                    dir.X = 1.0f / localSource.Width;
                }
                else
                {
                    dir.Y = 1.0f / localSource.Height;
                }

                if (dif > 0.25)                 // cutoff for using 2 samples
                {
                    DrawTargetTexture2D go;
                    int new_width  = w;
                    int new_height = h;
                    if (horizontal)
                    {
                        new_width /= 2;
                    }
                    else
                    {
                        new_height /= 2;
                    }

                    if (new_width == targetWidth && new_height == targetHeight)
                    {
                        go = target.Clone(false, false, false);
                    }
                    else
                    {
                        go = PickRT(ref intermediate, ref intermediate2, localSource, new_width, new_height, target.SurfaceFormat);
                    }

                    Vector2       se_size = new Vector2((float)new_width, (float)new_height);
                    ShaderElement se      = new ShaderElement(new Downsample2(), se_size, false);

                    go.AddModifier(new ScissorModifier(0, go.Height - new_height, new_width, go.Height, go));

                    se.TextureCrop = sRegion;

                    go.Add(new Drawer(dir, se, localSource));
                    passes.Add(go);

                    w = new_width;
                    h = new_height;

                    current = go;
                    continue;
                }

                if (dif > 0.125)                 // cutoff for using 4 samples
                {
                    DrawTargetTexture2D go;
                    int new_width  = w;
                    int new_height = h;
                    if (horizontal)
                    {
                        new_width /= 4;
                    }
                    else
                    {
                        new_height /= 4;
                    }

                    if (new_width == targetWidth && new_height == targetHeight)
                    {
                        go = target.Clone(false, false, false);
                    }
                    else
                    {
                        go = PickRT(ref intermediate, ref intermediate2, localSource, new_width, new_height, target.SurfaceFormat);
                    }

                    Vector2       se_size = new Vector2((float)new_width, (float)new_height);
                    ShaderElement se      = new ShaderElement(new Downsample4(), se_size, false);

                    go.AddModifier(new ScissorModifier(0, go.Height - new_height, new_width, go.Height, go));

                    se.TextureCrop = sRegion;

                    go.Add(new Drawer(dir, se, localSource));
                    passes.Add(go);

                    w = new_width;
                    h = new_height;

                    current = go;
                    continue;
                }

                // cutoff for using 8 samples
                {
                    DrawTargetTexture2D go;
                    int new_width  = w;
                    int new_height = h;
                    if (horizontal)
                    {
                        new_width /= 8;
                    }
                    else
                    {
                        new_height /= 8;
                    }

                    if (new_width == targetWidth && new_height == targetHeight)
                    {
                        go = target.Clone(false, false, false);
                    }
                    else
                    {
                        go = PickRT(ref intermediate, ref intermediate2, localSource, new_width, new_height, target.SurfaceFormat);
                    }

                    Vector2       se_size = new Vector2((float)new_width, (float)new_height);
                    ShaderElement se      = new ShaderElement(new Downsample8(), se_size, false);

                    go.AddModifier(new ScissorModifier(0, go.Height - new_height, new_width, go.Height, go));

                    se.TextureCrop = sRegion;

                    go.Add(new Drawer(dir, se, localSource));
                    passes.Add(go);

                    w = new_width;
                    h = new_height;

                    current = go;
                    continue;
                }
            }
        }
 public void DrawNewCard(Card data, int playerKey, bool visibleForPlayer, DrawType drawType, DrawTarget target, SkillState newState)
 {
     client.DisplayNewCard(data, playerKey, visibleForPlayer, drawType, target, newState);
 }
Пример #23
0
        //Továbbítja a kapott új kártya adatokat a megfelelő játékos oldalra, hogy vizuálisan megjelenítse azokat
        public void DisplayNewCard(Card data, int playerKey, bool visibleForThePlayer, DrawType drawType, DrawTarget target, SkillState skillState)
        {
            //Ha nem vakon húztuk
            if (drawType == DrawType.Normal)
            {
                //Létrehozás
                GameObject temp = GetFieldFromKey(playerKey).CreateCard(data, visibleForThePlayer, skillState);

                //Elhelyezés kézbe
                if (target == DrawTarget.Hand)
                {
                    //Kártya objektum hozzáadása a kéz mezőhöz
                    GetFieldFromKey(playerKey).AddCardToHand(temp);
                }

                //Elhelyezés a mezőre
                else
                {
                    GetFieldFromKey(playerKey).BlindSummon(temp);
                    GetFieldFromKey(playerKey).RevealCardsOnField();
                }
            }

            //Vakon húzás a mezőre
            else if (drawType == DrawType.Blind)
            {
                if (target == DrawTarget.Field)
                {
                    GameObject temp = GetFieldFromKey(playerKey).CreateCard(data, false, skillState);
                    GetFieldFromKey(playerKey).BlindSummon(temp);
                }
            }
        }
Пример #24
0
 /// <summary>
 /// <para>Attempt to get the layout (position and size) of this element</para>
 /// <para>The draw target the element is draw to must be specified</para>
 /// <para>Note this operation can be quite expensive if performed multiple times per frame</para>
 /// </summary>
 /// <param name="position"></param>
 /// <param name="size"></param>
 /// <param name="drawTarget"></param>
 /// <returns></returns>
 public bool TryGetLayout(out Vector2 position, out Vector2 size, DrawTarget drawTarget)
 {
     return(TryGetLayout(out position, out size, drawTarget.Size));
 }
Пример #25
0
    public static bool RayCastDrawTarget(Ray ray, IBSDataSource ds, out DrawTarget target, int minvol, bool ignoreDiagonal = true, params IBSDataSource[] relative_ds)
    {
        target = new DrawTarget();

        RaycastHit rch;
        float      dis = Upsilon;

//		bool cast = false;

        if (ds == null)
        {
            return(false);
        }

        IBSDataSource fds = null;

        if (RayCastV(ray, ds, out rch, minvol))
        {
            dis = rch.distance;
//			cast = true;
            fds = ds;
        }


        foreach (IBSDataSource _ds in relative_ds)
        {
            RaycastHit _rch;
            if (_ds != ds && RayCastV(ray, _ds, out _rch, minvol))
            {
                if (dis > _rch.distance)
                {
                    rch = _rch;
                    dis = _rch.distance;
                    fds = _ds;
                }
            }
        }

        target.ds = fds;
        if (fds != null)
        {
            if (fds == ds)
            {
                target.rch    = rch;
                target.snapto = new Vector3(Mathf.FloorToInt((rch.point.x - rch.normal.x * 0.5f) * ds.ScaleInverted) * ds.Scale,
                                            Mathf.FloorToInt((rch.point.y - rch.normal.y * 0.5f) * ds.ScaleInverted) * ds.Scale,
                                            Mathf.FloorToInt((rch.point.z - rch.normal.z * 0.5f) * ds.ScaleInverted) * ds.Scale);
                target.cursor = new Vector3(Mathf.FloorToInt((rch.point.x + rch.normal.x * 0.5f) * ds.ScaleInverted) * ds.Scale,
                                            Mathf.FloorToInt((rch.point.y + rch.normal.y * 0.5f) * ds.ScaleInverted) * ds.Scale,
                                            Mathf.FloorToInt((rch.point.z + rch.normal.z * 0.5f) * ds.ScaleInverted) * ds.Scale);


                IntVector3 offset = DiagonalOffset(rch.point * ds.ScaleInverted, rch.normal * ds.ScaleInverted, ds.DiagonalOffset);

                if (offset.x != 0)
                {
                    Vector3 _snap = target.snapto * ds.ScaleInverted + new Vector3(offset.x, 0, 0);
                    BSVoxel voxel = ds.SafeRead((int)_snap.x, (int)_snap.y, (int)_snap.z);
                    if (!ds.VoxelIsZero(voxel, minvol))
                    {
                        offset.x = 0;
                    }
                }


                if (offset.y != 0)
                {
                    Vector3 _snap = target.snapto * ds.ScaleInverted + new Vector3(0, offset.y, 0);
                    BSVoxel voxel = ds.SafeRead((int)_snap.x, (int)_snap.y, (int)_snap.z);
                    if (!ds.VoxelIsZero(voxel, minvol))
                    {
                        offset.y = 0;
                    }
                }


                if (offset.z != 0)
                {
                    Vector3 _snap = target.snapto * ds.ScaleInverted + new Vector3(0, 0, offset.z);
                    BSVoxel voxel = ds.SafeRead((int)_snap.x, (int)_snap.y, (int)_snap.z);
                    if (!ds.VoxelIsZero(voxel, minvol))
                    {
                        offset.z = 0;
                    }
                }

                if (offset.x != 0 && offset.y != 0)
                {
                    Vector3 _snap = target.snapto * ds.ScaleInverted + new Vector3(offset.x, offset.y, 0);
                    BSVoxel voxel = ds.SafeRead((int)_snap.x, (int)_snap.y, (int)_snap.z);
                    if (!ds.VoxelIsZero(voxel, minvol))
                    {
                        offset.x = 0;
                        offset.y = 0;
                    }
                }

                if (offset.x != 0 && offset.z != 0)
                {
                    Vector3 _snap = target.snapto * ds.ScaleInverted + new Vector3(offset.x, 0, offset.z);
                    BSVoxel voxel = ds.SafeRead((int)_snap.x, (int)_snap.y, (int)_snap.z);
                    if (!ds.VoxelIsZero(voxel, minvol))
                    {
                        offset.x = 0;
                        offset.z = 0;
                    }
                }

                if (offset.y != 0 && offset.z != 0)
                {
                    Vector3 _snap = target.snapto * ds.ScaleInverted + new Vector3(0, offset.y, offset.z);
                    BSVoxel voxel = ds.SafeRead((int)_snap.x, (int)_snap.y, (int)_snap.z);
                    if (!ds.VoxelIsZero(voxel, minvol))
                    {
                        offset.y = 0;
                        offset.z = 0;
                    }
                }

                target.cursor = target.cursor + (offset.ToVector3()) * ds.Scale;

                if (ds == BuildingMan.Blocks)
                {
                    if (!ignoreDiagonal)
                    {
                        Vector3 _snap = target.snapto * ds.ScaleInverted;
                        BSVoxel voxel = ds.SafeRead((int)_snap.x, (int)_snap.y, (int)_snap.z);
                        if (voxel.blockType > 128)
                        {
                            if (voxel.blockType >> 2 != 63)
                            {
                                return(false);
                            }
                        }
                    }
                }
            }
            else
            {
                rch.point += fds.Offset;
                rch.point -= ds.Offset;

                target.rch = rch;
                float factor = Mathf.Min(fds.Scale, ds.Scale);
                target.snapto = new Vector3(Mathf.FloorToInt((rch.point.x - rch.normal.x * 0.5f * factor) * ds.ScaleInverted) * ds.Scale,
                                            Mathf.FloorToInt((rch.point.y - rch.normal.y * 0.5f * factor) * ds.ScaleInverted) * ds.Scale,
                                            Mathf.FloorToInt((rch.point.z - rch.normal.z * 0.5f * factor) * ds.ScaleInverted) * ds.Scale);
                target.cursor = new Vector3(Mathf.FloorToInt((rch.point.x + rch.normal.x * 0.5f * factor) * ds.ScaleInverted) * ds.Scale,
                                            Mathf.FloorToInt((rch.point.y + rch.normal.y * 0.5f * factor) * ds.ScaleInverted) * ds.Scale,
                                            Mathf.FloorToInt((rch.point.z + rch.normal.z * 0.5f * factor) * ds.ScaleInverted) * ds.Scale);
            }

            return(true);
        }

        return(false);
    }
Пример #26
0
		/// <summary>
		/// Construct the scissor rectangle, based on the size of an existing draw target
		/// </summary>
		/// <param name="left"></param>
		/// <param name="top"></param>
		/// <param name="right"></param>
		/// <param name="bottom"></param>
		/// <param name="targetSize"></param>
		public ScissorModifier(int left, int top, int right, int bottom, DrawTarget targetSize)
			: this((left) / (float)targetSize.Width,(top) / (float)targetSize.Height,(right) / (float)targetSize.Width,(bottom) / (float)targetSize.Height)
		{
		}
Пример #27
0
 //Kártya felhúzás kör elején
 public void DrawCard(int currentKey, int amount = 1, DrawTarget target = DrawTarget.Hand, DrawType drawType = DrawType.Normal, SkillState newState = SkillState.NotDecided)
 {
     controller.StartCoroutine(DrawCardAction(currentKey, amount, target, drawType, newState));
 }
Пример #28
0
    public static bool RayCastDrawTarget(Ray ray, out DrawTarget target, int minvol, bool voxelbest = false)
    {
        target = new DrawTarget();
        if (!VCEditor.DocumentOpen())
        {
            return(false);
        }
        // Cast grid and voxel above minvol
        RaycastHit rch_voxel    = new RaycastHit();
        RaycastHit rch_grid     = new RaycastHit();
        float      dist_voxel   = 10000;
        float      dist_grid    = 10000;
        bool       to_cast_grid = true;

        if (VCEMath.RayCastVoxel(VCEInput.s_PickRay, out rch_voxel, minvol))
        {
            dist_voxel = rch_voxel.distance;
            if (voxelbest)
            {
                to_cast_grid = false;
            }
        }

        if (to_cast_grid && VCEMath.RayCastGrid(VCEInput.s_PickRay, out rch_grid))
        {
            if (rch_grid.normal.y > 0)
            {
                dist_grid = rch_grid.distance;
            }
        }

        // cast voxel
        if (dist_voxel < dist_grid)
        {
            target.rch    = rch_voxel;
            target.snapto = new IntVector3(Mathf.FloorToInt(rch_voxel.point.x - rch_voxel.normal.x * 0.5f),
                                           Mathf.FloorToInt(rch_voxel.point.y - rch_voxel.normal.y * 0.5f),
                                           Mathf.FloorToInt(rch_voxel.point.z - rch_voxel.normal.z * 0.5f));
            target.cursor = new IntVector3(Mathf.FloorToInt(rch_voxel.point.x + rch_voxel.normal.x * 0.5f),
                                           Mathf.FloorToInt(rch_voxel.point.y + rch_voxel.normal.y * 0.5f),
                                           Mathf.FloorToInt(rch_voxel.point.z + rch_voxel.normal.z * 0.5f));
            return(true);
        }
        // cast grid
        else if (dist_grid < dist_voxel)
        {
            target.rch    = rch_grid;
            target.snapto = new IntVector3(Mathf.FloorToInt(rch_grid.point.x - rch_grid.normal.x * 0.5f),
                                           Mathf.FloorToInt(rch_grid.point.y - rch_grid.normal.y * 0.5f),
                                           Mathf.FloorToInt(rch_grid.point.z - rch_grid.normal.z * 0.5f));
            target.cursor = new IntVector3(Mathf.FloorToInt(rch_grid.point.x + rch_grid.normal.x * 0.5f),
                                           Mathf.FloorToInt(rch_grid.point.y + rch_grid.normal.y * 0.5f),
                                           Mathf.FloorToInt(rch_grid.point.z + rch_grid.normal.z * 0.5f));
            if (VCEditor.s_Scene.m_IsoData.GetVoxel(VCIsoData.IPosToKey(target.cursor)).Volume > VCEMath.MC_ISO_VALUE)
            {
                target.cursor = null;
                return(false);
            }
            return(true);
        }
        // cast nothing
        else
        {
            target.rch    = new RaycastHit();
            target.snapto = null;
            target.cursor = null;
            return(false);
        }
    }
Пример #29
0
 /// <summary>
 /// Construct the scissor rectangle, based on the size of an existing draw target
 /// </summary>
 /// <param name="left"></param>
 /// <param name="top"></param>
 /// <param name="right"></param>
 /// <param name="bottom"></param>
 /// <param name="targetSize"></param>
 public ScissorModifier(int left, int top, int right, int bottom, DrawTarget targetSize)
     : this((left) / (float)targetSize.Width, (top) / (float)targetSize.Height, (right) / (float)targetSize.Width, (bottom) / (float)targetSize.Height)
 {
 }