Пример #1
0
        public override void Draw(DrawProperty dp)
        {
            if (string.IsNullOrEmpty(Text))
            {
                return;
            }
            // Yellow bar
            var r = dp.PaneRect.Clone();

            r.LT = ScreenPos.From(r.L, 0);
            r.RB = ScreenPos.From(r.R, 2);
            dp.Graphics.FillRectangle(_(r), BackgroundColor);

            // Active Template name (Back ground)
            var tf = new CanvasTextFormat
            {
                FontFamily   = "Coureir New",
                FontSize     = 11.0f,
                FontWeight   = FontWeights.Normal,
                WordWrapping = CanvasWordWrapping.NoWrap,
            };

            r.RB = r.LT + GraphicUtil.MeasureString(dp.Canvas, Text, tf) + ScreenSize.From(10, 10);
            dp.Graphics.FillRectangle(_(r), BackgroundColor);

            // Active Template name (Text)
            dp.Graphics.TextAntialiasing = CanvasTextAntialiasing.ClearType;
            dp.Graphics.DrawText(Text, 4, 2, ColorUtil.GetNegativeColor(BackgroundColor), tf);
        }
Пример #2
0
 /// <summary>
 /// Konstruktor des Invader
 /// </summary>
 /// <param name="game"></param>
 public Invader(Game game)
 {
     Alive        = true;
     _color       = Color.Red;
     _removeColor = Color.Black;
     _graphicUtil = new GraphicUtil(game);
 }
Пример #3
0
    void Update()
    {
        if (quardTree != null &&
            Time.frameCount % 1 == 0)
        {
            quardTree.Refresh(null);
            quardTree.NarrowPhase();

            showText();
        }
        GraphicUtil.drawQuardTree(quardTree);
        if (Input.GetKeyUp(KeyCode.P))
        {
            quardTree.Refresh(null);
            //quardTree.narrowPhase();
            showText();
            //Rectangle a = new Rectangle(0, 0, 20, 20);

            //Rectangle b = new Rectangle(19, 20, 20, 20);

            //if(GraphicUtil.isOverlap(a, b))
            //{
            //    Debug.Log("overlap");
            //}
        }
    }
Пример #4
0
 /// <summary>
 /// Stellt eine Instanze des Objektes Rock bereit
 /// </summary>
 /// <param name="game"></param>
 public Rock(Game game)
 {
     Lives        = 3;
     Destoryed    = false;
     _color       = Color.Yellow;
     _removeColor = Color.Black;
     _graphicUtil = new GraphicUtil(game);
 }
Пример #5
0
 /// <summary>
 /// Konstruktor der Items, wird erstellt auf dem Spielfeld
 /// </summary>
 /// <param name="game"></param>
 protected Item(Game game)
 {
     Y            = 10;
     _game        = game;
     Destoryed    = true;
     _removeColor = Color.Black;
     _graphicUtil = new GraphicUtil(game);
 }
Пример #6
0
    public EnemyBallView CreateEnemyBall(NetObject netObj)
    {
        GameObject obj = TrashMan.spawn("EnemyBall");

        obj.transform.parent = GameObject.Find("Canvas").transform;
        RectTransform rect          = obj.GetComponent <RectTransform>();
        EnemyBallView enemyBallView = obj.GetComponent <EnemyBallView>();

        rect.anchoredPosition = GraphicUtil.ToVector2(netObj.body.center);
        return(enemyBallView);
    }
Пример #7
0
        /// <summary>
        /// Erstellt eine Kugel auf der übergebenen Form, bei einem übergebenen Invader
        /// </summary>
        /// <param name="game"></param>
        /// <param name="indexOf"></param>
        public Bullet(Game game, int indexOf)
        {
            _game        = game;
            _graphicUtil = new GraphicUtil(game);
            CreateInvaderBullet(indexOf);

            _moveTimer          = new Timer();
            _moveTimer.Tick    += (sender, e) => MoveInvaderBullet(sender, e); // Geile sache, so kann man sender einem objekt übergeben
            _moveTimer.Interval = 1;
            _moveTimer.Start();
        }
Пример #8
0
        /// <summary>
        /// Erstellt eine Kugel auf der übergebenen Form, bei dem übergebene Shiff
        /// </summary>
        /// <param name="game"></param>
        public Bullet(Game game)
        {
            _game        = game;
            _graphicUtil = new GraphicUtil(game);
            CreateSpaceShipBullet();

            _moveTimer          = new Timer();
            _moveTimer.Tick    += (sender, e) => MoveShipBullet(sender, e);
            _moveTimer.Interval = 1;
            _moveTimer.Start();
        }
Пример #9
0
    public BallView CreateBall(NetObject netObj)
    {
        GameObject    obj  = TrashMan.spawn("Ball");
        BallView      ball = obj.GetComponent <BallView>();
        RectTransform rect = obj.GetComponent <RectTransform>();

        ball.uid              = netObj.uid;
        obj.transform.parent  = GameObject.Find("Canvas").transform;
        rect.anchoredPosition = GraphicUtil.ToVector2(netObj.body.center);
        ball.setData(netObj);
        return(ball);
    }
Пример #10
0
        /// <summary>
        /// Stellt eine Instanz der Klasse InvaderTest bereit
        /// </summary>
        /// <param name="game"></param>
        public InvaderTest(Game game)
        {
            _game        = game;
            _graphicUtil = new GraphicUtil(game);

            Width  = 3;
            Height = 3;
            X      = _game.ContainerWidth / 2;
            Y      = _game.ContainerHeight / 2;

            CreateMid();
        }
Пример #11
0
        /// <summary>
        /// Konstruktor des Schiffes, nimmt das Objekt Game entgegen
        /// </summary>
        /// <param name="game"></param>
        public SpaceShip(Game game)
        {
            _game = game;
            Alive = true;

            Lives      = DefaultLives;
            _moveSpeed = DefaultMoveSpeed;

            _ship                  = new Rectangle[3];
            _bulletWatch           = new Stopwatch();
            _graphicUtil           = new GraphicUtil(game);
            _defaultIntervalTimer  = new Stopwatch();
            _defaultMoveSpeedTimer = new Stopwatch();
        }
Пример #12
0
    void Compute()
    {
        material.color = defaultColor;
        Graphics.Blit(a, b, material);

        if (blitInner)
        {
            material.color = innerColor;
            GraphicUtil.BlitExceptBorder(a, b, material);
        }

        if (blitBorder)
        {
            material.color = borderColor;
            GraphicUtil.BlitBorder(a, b, material);
        }
    }
Пример #13
0
    public void UpdateEnemyPos()
    {
        List <NetObject> remove = new List <NetObject>();

        foreach (NetObject obj in listEnemy)
        {
            obj.PerformMove();
            if (!GraphicUtil.isInner(obj.body, bound))
            {
                remove.Add(obj);
            }
        }

        for (int i = 0; i < remove.Count; i++)
        {
            collisionTree.Remove(remove[i].body);
            listEnemy.Remove(remove[i]);
        }
        remove.Clear();
    }
Пример #14
0
    public void SolvePoisson(
        RenderTexture x, RenderTexture b,
        int iterations, float alpha, float beta,
        System.Action <RenderTexture, RenderTexture> applyBoundaryCondition = null)
    {
        var buffers = new RenderTexture[]
        {
            RenderTexture.GetTemporary(x.width, x.height, 0, RenderTextureFormat.ARGBFloat),
            RenderTexture.GetTemporary(x.width, x.height, 0, RenderTextureFormat.ARGBFloat)
        };

        solverMat.SetFloat("_Alpha", alpha);
        solverMat.SetFloat("_ReciprocalBeta", 1.0f / beta);
        solverMat.SetTexture("_BTex", b);

        Graphics.SetRenderTarget(buffers[0]);
        GL.Clear(true, true, Color.black);
        Graphics.SetRenderTarget(null);

        int index = 0;

        for (int i = 0; i != iterations; ++i)
        {
            if (applyBoundaryCondition != null)
            {
                applyBoundaryCondition(buffers[index % 2], buffers[(index + 1) % 2]);
                index++;
            }
            GraphicUtil.BlitExceptBorder(buffers[index % 2], buffers[(index + 1) % 2], solverMat);
            ++index;
        }

        Graphics.Blit(buffers[index % 2], x);

        RenderTexture.ReleaseTemporary(buffers[0]);
        RenderTexture.ReleaseTemporary(buffers[1]);
    }
Пример #15
0
 public static void BlitWithBorderCopy(RenderTexture src, RenderTexture dst, Material mat)
 {
     Graphics.Blit(src, dst, mat);
     GraphicUtil.BlitBorder(src, dst, copyMaterial);
 }
Пример #16
0
 public void UpdateBorder(Material material, bool useOffset)
 {
     Swap();
     GraphicUtil.BlitBorderWithInnerCopy(src, dst, material, useOffset);
 }
Пример #17
0
 public void UpdateExceptBorder(Material material)
 {
     Swap();
     GraphicUtil.BlitWithBorderCopy(src, dst, material);
 }
Пример #18
0
    void UpdateSimulation(float dt)
    {
        var dx = settings.dx;

        // advect
        if (settings.enableVelocityAdvection || settings.enableInkAdvection)
        {
            advectionMat.SetFloat("_ReciprocalDx", 1.0f / dx);
            advectionMat.SetFloat("_DeltaTime", dt);

            // advect velocity
            if (settings.enableVelocityAdvection)
            {
                boundaryMat.SetFloat("_Scale", -1);
                velocityBuf.UpdateBorder(boundaryMat, true);

                advectionMat.SetTexture("_VelocityTex", velocityBuf.current);
                advectionMat.SetFloat("_OneMinusDissipation", 1.0f);
                velocityBuf.UpdateExceptBorder(advectionMat);
            }

            // advect ink
            if (settings.enableInkAdvection)
            {
                boundaryMat.SetFloat("_Scale", 0);
                inkBuf.UpdateBorder(boundaryMat, true);

                advectionMat.SetTexture("_VelocityTex", velocityBuf.current);
                advectionMat.SetFloat("_OneMinusDissipation", 1.0f - settings.inkDissipation);
                inkBuf.UpdateExceptBorder(advectionMat);
            }
        }

        // impulse
        if (source.output > 0)
        {
            impulseMat.SetFloat("_Radius", settings.sourceRadius);
            impulseMat.SetVector("_Position", source.position);

            if (settings.enableVelocityImpulse)
            {
                var strength = new Vector4(
                    Mathf.Clamp(source.force.x, -1, 1),
                    Mathf.Clamp(source.force.y, -1, 1), 0, 0) * settings.strengthMul;
                impulseMat.SetVector("_Color", strength);
                Debug.Log(strength);
                velocityBuf.UpdateExceptBorder(impulseMat);
            }

            if (settings.enableInkImpulse)
            {
                impulseMat.SetColor("_Color", source.color);
                inkBuf.UpdateExceptBorder(impulseMat);
            }
        }

        if (settings.viscosity > 0)
        {
            var alpha = dx * dx / (settings.viscosity * dt);
            var beta  = 4.0f + alpha;
            solver.SolvePoisson(velocityBuf.current, velocityBuf.current,
                                settings.solverIterations,
                                alpha, beta);
        }

        if (settings.enablePressureUpdate)
        {
            divergenceMat.SetFloat("_HalfReciprocalDx", 0.5f / dx);
            Graphics.Blit(velocityBuf.current, divergenceBuf, divergenceMat);

            var alpha = -dx * dx;
            var beta  = 4.0f;
            boundaryMat.SetFloat("_Scale", 1);
            solver.SolvePoisson(pressureBuf, divergenceBuf,
                                settings.solverIterations,
                                alpha, beta, (arg1, arg2) =>
                                GraphicUtil.BlitBorderWithInnerCopy(arg1, arg2, boundaryMat, true));
        }

        boundaryMat.SetFloat("_Scale", -1);
        velocityBuf.UpdateBorder(boundaryMat, true);

        if (settings.enableSubstractPressureGradient)
        {
            substractGradientMat.SetFloat("_HalfReciprocalDx", 0.5f / dx);
            substractGradientMat.SetTexture("_SecondTex", pressureBuf);
            velocityBuf.UpdateExceptBorder(substractGradientMat);
        }
    }
Пример #19
0
 // offset will be used for boundary conditions
 public static void BlitBorderWithInnerCopy(RenderTexture src, RenderTexture dst, Material mat, bool useOffset)
 {
     Graphics.Blit(src, dst, copyMaterial);
     GraphicUtil.BlitBorder(src, dst, mat, useOffset);
 }
Пример #20
0
 /// <summary>
 /// Stellt eine Instanz des Objekt Ship bereit
 /// </summary>
 /// <param name="game"></param>
 public Ship(Game game)
 {
     _game        = game;
     _graphicUtil = new GraphicUtil(game);
 }
Пример #21
0
        public void CDGtoAVI(string aviFileName, string cdgFileName, string mp3FileName, double frameRate, string backgroundFileName = "")
        {
            Bitmap      backgroundBmp = null;
            Bitmap      mergedBMP     = null;
            VideoStream aviStream     = default(VideoStream);
            CDGFile     myCDGFile     = new CDGFile(cdgFileName);

            myCDGFile.renderAtPosition(0);
            Bitmap bitmap__1 = (Bitmap)myCDGFile.RGBImage;

            if (!string.IsNullOrEmpty(backgroundFileName))
            {
                try
                {
                    if (IsMovie(backgroundFileName))
                    {
                        backgroundBmp = MovieFrameExtractor.GetBitmap(0, backgroundFileName, CDGFile.CDG_FULL_WIDTH, CDGFile.CDG_FULL_HEIGHT);
                    }
                    if (IsGraphic(backgroundFileName))
                    {
                        backgroundBmp = CDGNet.GraphicUtil.GetCDGSizeBitmap(backgroundFileName);
                    }
                }
                catch (Exception ex)
                {
                    Console.Write(ex.Message);
                }
            }
            AviManager aviManager = new AviManager(aviFileName, false);

            if (backgroundBmp != null)
            {
                mergedBMP = GraphicUtil.MergeImagesWithTransparency(backgroundBmp, bitmap__1);
                aviStream = aviManager.AddVideoStream(true, frameRate, mergedBMP);
                mergedBMP.Dispose();
                if (IsMovie(backgroundFileName))
                {
                    backgroundBmp.Dispose();
                }
            }
            else
            {
                aviStream = aviManager.AddVideoStream(true, frameRate, bitmap__1);
            }

            int    count         = 0;
            double frameInterval = 1000 / frameRate;
            long   totalDuration = myCDGFile.getTotalDuration();
            double position      = 0;

            while (position <= totalDuration)
            {
                count   += 1;
                position = count * frameInterval;
                myCDGFile.renderAtPosition(Convert.ToInt64(position));
                bitmap__1 = (Bitmap)myCDGFile.RGBImage;
                if (!string.IsNullOrEmpty(backgroundFileName))
                {
                    if (IsMovie(backgroundFileName))
                    {
                        backgroundBmp = MovieFrameExtractor.GetBitmap(position / 1000, backgroundFileName, CDGFile.CDG_FULL_WIDTH, CDGFile.CDG_FULL_HEIGHT);
                    }
                }
                if (backgroundBmp != null)
                {
                    mergedBMP = GraphicUtil.MergeImagesWithTransparency(backgroundBmp, bitmap__1);
                    aviStream.AddFrame(mergedBMP);
                    mergedBMP.Dispose();
                    if (IsMovie(backgroundFileName))
                    {
                        backgroundBmp.Dispose();
                    }
                }
                else
                {
                    aviStream.AddFrame(bitmap__1);
                }
                bitmap__1.Dispose();
                double percentageDone = (position / totalDuration) * 100;

                if (Status != null)
                {
                    Status(percentageDone.ToString());
                }
                Application.DoEvents();
            }
            myCDGFile.Dispose();
            aviManager.Close();
            if (backgroundBmp != null)
            {
                backgroundBmp.Dispose();
            }

            // Add MP3 to AVI
            Console.Write("|nAVI terminated, add MP3 to AVI");
            AddMP3toAVI(aviFileName, mp3FileName);
        }