Esempio n. 1
0
 public void SetColor(Color color)
 {
     _color = color;
     foreach (CharacterSprite s in _bitmapText)
     {
         s.Sprite.SetColor(color);
     }
 }
Esempio n. 2
0
    void Start()
    {
        switcherCounter  = redSwitcherCounter + greenSwitcherCounter + yellowSwitcherCounter + purpleSwitcherCounter + blueSwitcherCounter;
        conditionCounter = redConditionCounter + greenConditionCounter + yellowConditionCounter + purpleConditionCounter + blueConditionCounter;
        this.switcherInInventoryArray  = new GameObject[switcherCounter];
        this.conditionInInventoryArray = new GameObject[conditionCounter];

        var tmp_switncher = GameObject.Find("Switcher");

        tmp_switncher.GetComponent <SpriteRenderer>().enabled = false;
        tmp_switncher.GetComponent <Collider2D>().enabled     = false;

        switcherItemPosition = tmp_switncher.GetComponent <SpriteRenderer>().transform.position;

        for (var i = 0; i < switcherCounter; i++)
        {
            e.Color color = GetSwitcherColor();
            tmp_switncher.GetComponent <ColorSwitch>().color     = color;
            tmp_switncher.GetComponent <SpriteRenderer>().sprite = tmp_switncher.GetComponent <ColorSwitch>().spritesDict[color];
            var clone = Instantiate(tmp_switncher);
            clone.transform.position = switcherItemPosition;
            clone.transform.parent   = this.transform;
            clone.GetComponent <SpriteRenderer>().enabled = false;
            clone.GetComponent <Collider2D>().enabled     = false;
            this.switcherInInventoryArray[i] = clone;
        }

        var tmpCondition = GameObject.Find("Condition");

        tmpCondition.GetComponent <SpriteRenderer>().enabled = false;
        tmpCondition.GetComponent <Collider2D>().enabled     = false;

        counterItemPosition = tmpCondition.GetComponent <SpriteRenderer>().transform.position;

        for (var i = 0; i < conditionCounter; i++)
        {
            e.Color color = GetConditionColor();
            tmpCondition.GetComponent <ConditionBlock>().color  = color;
            tmpCondition.GetComponent <SpriteRenderer>().sprite = tmpCondition.GetComponent <ConditionBlock>().spritesDict[color];
            var clone = Instantiate(tmpCondition);
            clone.transform.position = counterItemPosition;
            clone.transform.parent   = this.transform;
            clone.GetComponent <SpriteRenderer>().enabled = false;
            clone.GetComponent <Collider2D>().enabled     = false;
            this.conditionInInventoryArray[i]             = clone;
        }

        ShowNextChangeBlock();
        ShowNextConditionBlock();
    }
Esempio n. 3
0
    public void Play()
    {
        var g = new e.BallGenerator(balls, 2, -1);

        game.AddObject(g);

        for (var i = 0; i < 350; i++)
        {
            game.Step();
        }

        foreach (var obj in game.GetCurrentWorld())
        {
            if (obj is e.ColorSwitch)
            {
                var clone = Instantiate(this.ColorSwitchPrefab);
                clone.GetComponent <ColorSwitch>().ColorSwitcher = obj as e.ColorSwitch;
                clone.GetComponent <ColorSwitch>().active        = true;
            }
        }

        for (var i = 0; i < ballHistory.GetList().Count; i++)
        {
            var ball  = ballHistory.GetList()[i];
            var clone = Instantiate(this.BallPrefab, GeneratorPrefab.transform.position, GeneratorPrefab.transform.rotation);
            clone.GetComponent <Ball>().eBall = ball;
            e.Color originColor = ball.GetActions()[0].Color;
            clone.GetComponent <SpriteRenderer>().sprite = clone.GetComponent <Ball>().GetSpriteByColor(originColor);
        }

        var grid   = GameObject.Find("Grid").GetComponent <GridInit>();
        int height = grid.height;
        int width  = grid.width;

        for (int i = 0; i < height; i++)
        {
            for (int j = 0; j < width; j++)
            {
                grid.cellsArray[i, j].GetComponent <SpriteRenderer>().enabled = false;
            }
        }
    }
        public String addColorToSelectedText(Engine.Color color)
        {
            String colorText    = textBox.Caption;
            String defaultColor = textBox.TextColor.ToHexString();

            if (textBox.IsTextSelection)
            {
                int    selectionStart = findPositionInColorizedString((int)textBox.TextSelectionStart, colorText);
                String currentColor   = findColorForPosition(selectionStart, colorText, defaultColor);
                colorText = colorText.Insert(selectionStart, color.ToHexString());

                int selectionEnd = findPositionInColorizedString((int)textBox.TextSelectionEnd, colorText);
                colorText = colorText.Insert(selectionEnd, currentColor);
            }
            else
            {
                uint selection = textBox.TextCursor;
                colorText = colorText.Insert(findPositionInColorizedString((int)selection, colorText), color.ToHexString());
            }
            return(colorText);
        }
        public static void top_colors(int ofs_p, bool sv_c, int dc, Image img, SubsystemPalette p)
        {
            System.Drawing.Bitmap image = new System.Drawing.Bitmap(img.Width, img.Height);

            List <System.Drawing.Color> colors = new List <System.Drawing.Color>(image.Width * image.Height);

            for (int x = 0; x < img.Width; x++)
            {
                for (int y = 0; y < img.Height; y++)
                {
                    colors.Add(System.Drawing.Color.FromArgb(img.GetPixel(x, y).R, img.GetPixel(x, y).G, img.GetPixel(x, y).B));
                }
            }


            KMeansClusteringCalculator   clustering      = new KMeansClusteringCalculator();
            IList <System.Drawing.Color> dominantColours = clustering.Calculate(dc, colors, 6.0d);

            Color[] c_c = WorldPalette.DefaultColors;


            for (int i = 0; i < dominantColours.Count; i++)
            {
                c_c[i + ofs_p] = new Engine.Color(dominantColours[i].R, dominantColours[i].G, dominantColours[i].B);
            }

            p.m_colors = c_c.ToArray();

            if (sv_c)
            {
                p_c__ = c_c.ToArray();
                //p_c = "158,2,81;158,131,100;1,0,1;190,2,107;186,2,80;91,45,42;128,4,62;178,90,65;130,78,56;224,2,96;209,102,76;143,94,88;186,144,135;242,123,90;227,174,167;255,255,255";
                n_w = GameManager.WorldInfo.DirectoryName;
                //dat.ValuesDictionary.GetValue<ValuesDictionary>("GameInfo").GetValue<ValuesDictionary>("Palette").SetValue<string>(str1,"Colors");
            }
        }
Esempio n. 6
0
        private void InitializeBoundingBlocks()
        {
            Engine.Color blockColor = new Engine.Color(0.6f, 0.6f, 0.7f, 1);

            // Initialize left bound
            double x = leftBound.Left + Block.WIDTH / 2;
            double y = leftBound.Top - Block.HEIGHT / 2 - 2 * Block.HEIGHT;

            while (y > leftBound.Bottom)
            {
                Block block = new Block(textureManager);
                block.SetPosition(new Vector(x, y, 0));
                y -= Block.HEIGHT;
                block.Color = blockColor;
                outlineBlocks.Add(block);
            }

            // Initialize right bound
            x = rightBound.Left + Block.WIDTH / 2;
            y = rightBound.Top - Block.HEIGHT / 2 - 2 * Block.HEIGHT;

            while (y > leftBound.Bottom)
            {
                Block block = new Block(textureManager);
                block.SetPosition(new Vector(x, y, 0));
                y -= Block.HEIGHT;
                block.Color = blockColor;
                outlineBlocks.Add(block);
            }

            // Initialize upper bound
            x = upperBound.Left + Block.WIDTH / 2;
            y = upperBound.Top - Block.HEIGHT / 2 - 2 * Block.HEIGHT;

            while (x < upperBound.Right)
            {
                Block block = new Block(textureManager);
                block.SetPosition(new Vector(x, y, 0));
                x += Block.WIDTH;
                block.Color = blockColor;
                outlineBlocks.Add(block);
            }

            // Initialize lower bound
            x = lowerBound.Left + Block.WIDTH / 2;
            y = lowerBound.Top - Block.HEIGHT / 2;

            while (x < lowerBound.Right)
            {
                Block block = new Block(textureManager);
                block.SetPosition(new Vector(x, y, 0));
                x += Block.WIDTH;
                block.Color = blockColor;
                outlineBlocks.Add(block);
            }
        }
Esempio n. 7
0
        private IEnumerable <IdleStatus> renderImage(ImageRendererProperties properties, Action <FreeImageBitmap> renderingCompletedCallback)
        {
            if (imageRendererProgress != null)
            {
                imageRendererProgress.Visible = properties.ShowUIUpdates;
                imageRendererProgress.Cancel  = false;
                imageRendererProgress.update(0, "Rendering Image");
            }

            FreeImageBitmap bitmap      = null;
            SceneViewWindow sceneWindow = sceneViewController.ActiveWindow;

            if (sceneWindow != null)
            {
                if (ImageRenderStarted != null)
                {
                    ImageRenderStarted.Invoke(this, EventArgs.Empty);
                }

                //Background color
                Engine.Color backgroundColor = properties.CustomBackgroundColor;
                if (properties.UseWindowBackgroundColor)
                {
                    backgroundColor = sceneWindow.BackColor;
                }

                //Size (with AA)
                //int width = properties.Width * properties.AntiAliasingMode;
                //int height = properties.Height * properties.AntiAliasingMode;

                //Camera position
                Vector3 cameraPosition = sceneWindow.Translation;
                Vector3 cameraLookAt   = sceneWindow.LookAt;
                if (!properties.UseActiveViewportLocation)
                {
                    cameraPosition = properties.CameraPosition;
                    cameraLookAt   = properties.CameraLookAt;
                }

                //Turn off background if needed
                if (background != null)
                {
                    background.setVisible(properties.ShowBackground);
                }

                //Layer override
                String activeTransparencyState = TransparencyController.ActiveTransparencyState;
                if (properties.OverrideLayers)
                {
                    TransparencyController.ActiveTransparencyState = TransparencyStateName;
                    if (properties.LayerState != null)
                    {
                        properties.LayerState.instantlyApply();
                    }
                    else
                    {
                        Log.Warning("ImageRenderer was told to override layers but no layer state was provided.");
                    }
                }

                TransparencyController.applyTransparencyState(TransparencyController.ActiveTransparencyState);

                //Render
                IEnumerable <IdleStatus> process = createRender(properties.Width, properties.Height, properties.AntiAliasingMode, properties.ShowWatermark, properties.TransparentBackground, backgroundColor, sceneWindow.Camera, cameraPosition, cameraLookAt, sceneWindow.MinNearDistance, sceneWindow.NearPlaneWorld, sceneWindow.NearFarLength, properties,
                                                                (product) =>
                {
                    bitmap = product;
                });
                foreach (IdleStatus idleStatus in process)
                {
                    yield return(idleStatus);
                }

                //Turn off layer override
                if (properties.OverrideLayers)
                {
                    TransparencyController.ActiveTransparencyState = activeTransparencyState;
                }

                //Reactivate background
                if (background != null)
                {
                    background.setVisible(true);
                }

                if (ImageRenderCompleted != null)
                {
                    ImageRenderCompleted.Invoke(this, EventArgs.Empty);
                }
            }

            if (imageRendererProgress != null && properties.ShowUIUpdates)
            {
                imageRendererProgress.Visible = false;
            }

            renderingCompletedCallback(bitmap);
            yield break;
        }
Esempio n. 8
0
        private IEnumerable <IdleStatus> gridRender(int width, int height, int backBufferWidth, int backBufferHeight, int aaMode, RenderTexture renderTexture, Camera camera, Camera backgroundCamera, bool transparentBG, Engine.Color bgColor, Action <FreeImageBitmap> renderingCompletedCallback)
        {
            float originalLeft, originalRight, originalTop, originalBottom;

            camera.getFrustumExtents(out originalLeft, out originalRight, out originalTop, out originalBottom);

            int imageCountWidth  = width % backBufferWidth == 0 ? width / backBufferWidth : width / backBufferWidth + 1;
            int imageCountHeight = height % backBufferHeight == 0 ? height / backBufferHeight : height / backBufferHeight + 1;

            float gridStepHoriz = (originalRight * 2) / imageCountWidth;
            float gridStepVert  = (originalTop * 2) / imageCountHeight;

            float bgOriginalLeft = 0, bgOriginalRight = 0, bgOriginalTop = 0, bgOriginalBottom = 0, bgGridStepHoriz = 0, bgGridStepVert = 0;

            if (backgroundCamera != null)
            {
                backgroundCamera.getFrustumExtents(out bgOriginalLeft, out bgOriginalRight, out bgOriginalTop, out bgOriginalBottom);
                bgGridStepHoriz = (bgOriginalRight * 2) / imageCountWidth;
                bgGridStepVert  = (bgOriginalTop * 2) / imageCountHeight;
            }

            int imageStepHoriz = backBufferWidth;
            int imageStepVert  = backBufferHeight;

            int finalWidth          = width / aaMode;
            int finalHeight         = height / aaMode;
            int imageStepHorizSmall = finalWidth / imageCountWidth;
            int imageStepVertSmall  = finalHeight / imageCountHeight;

            float left, right, top, bottom;
            float bgLeft, bgRight, bgTop, bgBottom;
            int   totalSS = imageCountWidth * imageCountHeight;

            String updateString = "Rendering piece {0} of " + totalSS;

            OgrePlugin.PixelFormat   format       = OgrePlugin.PixelFormat.PF_A8R8G8B8;
            FreeImageAPI.PixelFormat bitmapFormat = FreeImageAPI.PixelFormat.Format32bppRgb;
            if (transparentBG)
            {
                bitmapFormat = FreeImageAPI.PixelFormat.Format32bppArgb;
            }

            Rectangle       destRect   = new Rectangle();
            Rectangle       srcRect    = new Rectangle(0, 0, imageStepHoriz, imageStepVert);
            FreeImageBitmap fullBitmap = new FreeImageBitmap(finalWidth, finalHeight, bitmapFormat);

            using (FreeImageBitmap pieceBitmap = new FreeImageBitmap(imageStepHoriz, imageStepVert, bitmapFormat))
            {
                bool      aaOn            = aaMode > 1;
                Rectangle scalarRectangle = new Rectangle();
                if (aaOn)
                {
                    scalarRectangle = new Rectangle(0, 0, imageStepHorizSmall, imageStepVertSmall);
                }
                for (int i = 0; i < totalSS; ++i)
                {
                    int y = i / imageCountWidth;
                    int x = i - y * imageCountWidth;

                    left   = originalLeft + gridStepHoriz * x;
                    right  = left + gridStepHoriz;
                    top    = originalTop - gridStepVert * y;
                    bottom = top - gridStepVert;

                    camera.setFrustumExtents(left, right, top, bottom);
                    if (backgroundCamera != null)
                    {
                        bgLeft   = bgOriginalLeft + bgGridStepHoriz * x;
                        bgRight  = bgLeft + bgGridStepHoriz;
                        bgTop    = bgOriginalTop - bgGridStepVert * y;
                        bgBottom = bgTop - bgGridStepVert;

                        backgroundCamera.setFrustumExtents(bgLeft, bgRight, bgTop, bgBottom);
                    }
                    Root.getSingleton().clearEventTimes();
                    renderTexture.getViewport(0).clear(FrameBufferType.FBT_COLOUR | FrameBufferType.FBT_DEPTH | FrameBufferType.FBT_STENCIL, bgColor);
                    renderTexture.update();

                    pieceBitmap.copyFromRenderTarget(renderTexture, format);
                    destRect.X      = x * imageStepHorizSmall;
                    destRect.Y      = y * imageStepVertSmall;
                    destRect.Width  = imageStepHorizSmall;
                    destRect.Height = imageStepVertSmall;
                    if (aaOn)
                    {
                        using (FreeImageBitmap scaled = new FreeImageBitmap(pieceBitmap))
                        {
                            scaled.Rescale(scalarRectangle.Width, scalarRectangle.Height, FREE_IMAGE_FILTER.FILTER_BILINEAR);
                            fullBitmap.Paste(scaled, destRect.X, destRect.Y, int.MaxValue);
                        }
                    }
                    else
                    {
                        fullBitmap.Paste(pieceBitmap, destRect.X, destRect.Y, int.MaxValue);
                    }

                    if (imageRendererProgress != null)
                    {
                        imageRendererProgress.update((uint)(((float)(i + 1) / totalSS) * 100.0f), String.Format(updateString, i + 1));
                        if (imageRendererProgress.Cancel)
                        {
                            break;
                        }
                    }

                    yield return(IdleStatus.Ok);
                }
            }

            renderTexture.getViewport(0).setOverlaysEnabled(true);

            renderingCompletedCallback(fullBitmap);
            yield break;
        }
Esempio n. 9
0
        private FreeImageBitmap simpleRender(int width, int height, int aaMode, bool transparentBG, Engine.Color bgColor, RenderTexture renderTexture)
        {
            renderTexture.getViewport(0).clear(FrameBufferType.FBT_COLOUR | FrameBufferType.FBT_DEPTH | FrameBufferType.FBT_STENCIL, bgColor);
            renderTexture.update();
            OgrePlugin.PixelFormat   format       = OgrePlugin.PixelFormat.PF_A8R8G8B8;
            FreeImageAPI.PixelFormat bitmapFormat = FreeImageAPI.PixelFormat.Format32bppRgb;
            if (transparentBG)
            {
                bitmapFormat = FreeImageAPI.PixelFormat.Format32bppArgb;
            }
            FreeImageBitmap bitmap = new FreeImageBitmap(width, height, bitmapFormat);

            bitmap.copyFromRenderTarget(renderTexture, format);

            //Resize if aa is active
            if (aaMode > 1)
            {
                int smallWidth  = width / aaMode;
                int smallHeight = height / aaMode;
                bitmap.Rescale(smallWidth, smallHeight, FREE_IMAGE_FILTER.FILTER_BILINEAR);
            }

            return(bitmap);
        }
Esempio n. 10
0
        private IEnumerable <IdleStatus> createRender(int finalWidth, int finalHeight, int aaMode, bool showWatermark, bool transparentBG, Engine.Color backColor, Camera cloneCamera, Vector3 position, Vector3 lookAt, float minNearDistance, float nearPlaneWorld, float nearFarLength, ImageRendererProperties properties, Action <FreeImageBitmap> renderingCompletedCallback)
        {
            FreeImageBitmap  bitmap       = null;
            OgreSceneManager sceneManager = controller.CurrentScene.getDefaultSubScene().getSimElementManager <OgreSceneManager>();

            if (sceneManager != null)
            {
                bool doGridRender;
                int  backBufferWidth;
                int  backBufferHeight;

                using (TexturePtr texture = createOgreTexture(finalWidth, finalHeight, aaMode, out doGridRender, out backBufferWidth, out backBufferHeight))
                {
                    if (texture != null)
                    {
                        using (HardwarePixelBufferSharedPtr pixelBuffer = texture.Value.getBuffer())
                        {
                            RenderTexture renderTexture = pixelBuffer.Value.getRenderTarget();
                            Camera        camera        = sceneManager.SceneManager.createCamera("__PictureCamera");
                            camera.setLodBias(cloneCamera.getLodBias());
                            camera.setUseRenderingDistance(cloneCamera.getUseRenderingDistance());
                            camera.setNearClipDistance(cloneCamera.getNearClipDistance());
                            camera.setFarClipDistance(cloneCamera.getFarClipDistance());
                            camera.setPolygonMode(cloneCamera.getPolygonMode());
                            camera.setRenderingDistance(cloneCamera.getRenderingDistance());
                            camera.setProjectionType(cloneCamera.getProjectionType());
                            camera.setFOVy(cloneCamera.getFOVy());

                            camera.setAutoAspectRatio(false);
                            camera.setAspectRatio((float)finalWidth / finalHeight);

                            SceneNode node = sceneManager.SceneManager.createSceneNode("__PictureCameraNode");
                            node.attachObject(camera);
                            node.setPosition(position);
                            sceneManager.SceneManager.getRootSceneNode().addChild(node);
                            camera.lookAt(lookAt);
                            Viewport viewport = renderTexture.addViewport(camera, 1, 0.0f, 0.0f, 1.0f, 1.0f);

                            if (properties.UseIncludePoint)
                            {
                                Matrix4x4 viewMatrix       = camera.getViewMatrix();
                                Matrix4x4 projectionMatrix = camera.getProjectionMatrix();
                                float     aspect           = camera.getAspectRatio();
                                float     fovy             = camera.getFOVy() * 0.5f;

                                float   distance  = SceneViewWindow.computeOffsetToIncludePoint(viewMatrix, projectionMatrix, properties.IncludePoint, aspect, fovy);
                                Vector3 direction = (position - lookAt).normalized();
                                node.setPosition(position - (direction * distance));
                                camera.lookAt(lookAt);
                            }

                            if (transparentBG)
                            {
                                backColor.a = 0.0f;
                            }

                            ViewportBackground bgViewport = null;
                            if (background != null)
                            {
                                bgViewport = new ViewportBackground("ImageRenderer", 0, background, renderTexture, false);
                                bgViewport.BackgroundColor = backColor;
                                bgViewport.Camera.setAutoAspectRatio(false);
                                bgViewport.Camera.setAspectRatio((float)finalWidth / finalHeight);
                            }
                            viewport.setBackgroundColor(backColor);
                            viewport.setOverlaysEnabled(false);
                            viewport.setClearEveryFrame(false);

                            if (properties.CustomizeCameraPosition != null)
                            {
                                properties.CustomizeCameraPosition(camera, viewport);
                            }

                            float near = CameraPositioner.computeNearClipDistance(camera.getDerivedPosition().length(), minNearDistance, nearPlaneWorld);
                            camera.setNearClipDistance(near);
                            camera.setFarClipDistance(near + nearFarLength);

                            if (doGridRender)
                            {
                                IEnumerable <IdleStatus> process = gridRender(finalWidth * aaMode, finalHeight * aaMode, backBufferWidth, backBufferHeight, aaMode, renderTexture, camera, bgViewport != null ? bgViewport.Camera : null, transparentBG, backColor,
                                                                              (product) =>
                                {
                                    bitmap = product;
                                });
                                foreach (IdleStatus idleStatus in process)
                                {
                                    yield return(idleStatus);
                                }
                            }
                            else
                            {
                                bitmap = simpleRender(backBufferWidth, backBufferHeight, aaMode, transparentBG, backColor, renderTexture);
                            }

                            if (showWatermark && LoadLogo != null)
                            {
                                using (FreeImageBitmap logo = LoadLogo())
                                {
                                    float imageFinalHeight = bitmap.Height * 0.0447f;
                                    float scale            = imageFinalHeight / logo.Height;
                                    float imageFinalWidth  = logo.Width * scale;
                                    if (imageFinalWidth > bitmap.Width)
                                    {
                                        imageFinalWidth  = bitmap.Width;
                                        scale            = imageFinalWidth / logo.Width;
                                        imageFinalHeight = logo.Height * scale;
                                    }

                                    logo.Rescale((int)imageFinalWidth, (int)imageFinalHeight, FREE_IMAGE_FILTER.FILTER_BILINEAR);
                                    //Have to composite the logo image first.
                                    using (FreeImageBitmap fullImageCorner = bitmap.Copy(0, bitmap.Height - (int)imageFinalHeight, (int)imageFinalWidth, bitmap.Height))
                                    {
                                        fullImageCorner.ConvertColorDepth(FREE_IMAGE_COLOR_DEPTH.FICD_24_BPP);
                                        logo.Composite(false, null, fullImageCorner);
                                    }
                                    bitmap.Paste(logo, 0, bitmap.Height - (int)imageFinalHeight, int.MaxValue);
                                }
                            }

                            renderTexture.destroyViewport(viewport);
                            if (bgViewport != null)
                            {
                                bgViewport.Dispose();
                            }
                            sceneManager.SceneManager.getRootSceneNode().removeChild(node);
                            sceneManager.SceneManager.destroySceneNode(node);
                            sceneManager.SceneManager.destroyCamera(camera);

                            TextureManager.getInstance().remove(texture);
                        }
                    }
                    else
                    {
                        //An error making the render texture. Log it and return the error image.
                        Log.Error("Could not render image. Returning placeholder image. Reason: Could not create valid render to texture target.");
                        bitmap = new FreeImageBitmap(finalWidth, finalHeight);
                        bitmap.FillBackground(new RGBQUAD()
                        {
                            rgbRed = 255
                        });
                    }
                }
            }
            renderingCompletedCallback(bitmap);
            yield break;
        }
Esempio n. 11
0
    // Update is called once per frame
    void Update()
    {
        time += Time.deltaTime;
        var actions = this.eBall.GetMoveActions();

        if (actions.Count > step)
        {
            var  action = actions[step];
            var  grid   = GameObject.Find("Grid").GetComponent <GridInit>();
            Cell cell   = null;
            var  pos    = action.Position;
            if (pos.X >= 0 && pos.Y >= 0)
            {
                cell = grid.cellsArray[pos.Y, pos.X];
                var cell_actions = this.eBall.GetActionsByCell(pos.X, pos.Y);
                foreach (var cell_action in cell_actions)
                {
                    switch (cell_action.Type)
                    {
                    case e.ActionType.BallProduced:

                        break;

                    case e.ActionType.BallMove:
                        if (cell)
                        {
                            this.transform.position = Vector3.Lerp(this.step_position, cell.transform.position, time);
                            Vector3 difference = this.step_position - cell.transform.position;
                            difference.Normalize();
                            // вычисляемый необходимый угол поворота
                            float rotation_z = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg - 90;
                            // Применяем поворот вокруг оси Z
                            this.transform.rotation = Quaternion.Euler(0f, 0f, rotation_z);
                        }
                        else if (false)
                        {
                        }
                        break;

                    case e.ActionType.BallChangeColor:
                        if (time >= 1)
                        {
                            // TODO Механика получения нужного цвета.
                            // При расстановке блоков надо сохранять цвет и от бэка получать цвет на который поменяли.
                            // Для этого при выставлении блока надо сохранять его цвет в бэк
                            // А для этого цвет надо хранить в экземпляре блока.
                            e.Color color = cell_action.Color;
                            this.GetComponent <SpriteRenderer>().sprite = spritesDict[color];
                        }
                        break;
                    }
                }
                if (this.transform.position == cell.transform.position)
                {
                    this.step_position = this.transform.position;
                    step++;
                    time = 0;
                }
            }
            else
            {
                if (time >= 1)
                {
                    step++;
                    time = 0;
                }
            }
        }
    }
Esempio n. 12
0
 public Sprite GetSpriteByColor(e.Color color)
 {
     return(spritesDict[color]);
 }
Esempio n. 13
0
 public void DrawImmediateModeVertex(Vector position, Color color, Point uvs)
 {
     Gl.glColor4f(color.Red, color.Green, color.Blue, color.Alpha);
     Gl.glTexCoord2f(uvs.X, uvs.Y);
     Gl.glVertex3d(position.X, position.Y, position.Z);
 }
Esempio n. 14
0
 public void SetColor(Color color)
 {
     Sprite.SetColor(color);
 }