コード例 #1
0
    void Update()
    {
        if (!DrawColorManager.IsDrawColor(drawColorStatus))
        {
            return;
        }

        // 色指定されてる場合は塗る
        SetColor();
        UpdateTexture();
    }
コード例 #2
0
    void SetColor()
    {
        Debug.Log(drawTexture.width);
        Debug.Log(-transform.position.x);

        int drawCenterX = (int)(-transform.position.x * verticalSize + drawTexture.width / 2);
        int drawCenterY = (int)(-transform.position.z * horizontalSize + drawTexture.height / 2);

        // drawCenterの周囲drawSizeピクセルを塗る
        for (int rangeX = -drawSize; rangeX < drawSize; rangeX++)
        {
            for (int rangeY = -drawSize; rangeY < drawSize; rangeY++)
            {
                int drawX = drawCenterX + rangeX;
                int drawY = drawCenterY + rangeY;

                if (0 > drawX || drawX >= drawTexture.width)
                {
                    // 範囲外は塗らない
                    continue;
                }
                if (0 > drawY || drawY >= drawTexture.height)
                {
                    // 範囲外は塗らない
                    continue;
                }

                Color color = DrawColorManager.GetColorCode(drawColorStatus);

                Transform myTransform = this.transform;
                Vector3   pos         = myTransform.position;
                int       pix_x       = 0;
                int       pix_z       = 0;


                pix_x = (int)(pos.x * 1000 + 350);
                pix_z = (int)(-pos.z * 1000 + 250);



                if (pix_x >= 0 && pix_x < 700 && pix_z >= 0 && pix_z < 500)
                {
                    Color c_gray = new Color(0.000f, 0f, 0f);
                    if (flogStatusManager.flogStatus == FlogStatus.f1)
                    {
                        Color c = tex1.GetPixel(pix_x, 500 - pix_z);
                        if ((Math.Abs(c.r - c_gray.r) < 0.05f))
                        {
                            animeStatusManager.animeStatus = AnimeStatus.walk;
                        }
                        else
                        {
                            animeStatusManager.animeStatus = AnimeStatus.put;
                            colorBuffer.SetValue(c, pix_x + 699 * (500 - pix_z));
                        }
                    }
                    else if (flogStatusManager.flogStatus == FlogStatus.f2)
                    {
                        Color c = tex2.GetPixel(pix_x, 500 - pix_z);
                        if ((Math.Abs(c.r - c_gray.r) < 0.05f))
                        {
                            animeStatusManager.animeStatus = AnimeStatus.walk;
                        }
                        else
                        {
                            animeStatusManager.animeStatus = AnimeStatus.put;
                            colorBuffer.SetValue(c, pix_x + 699 * (500 - pix_z));
                        }
                    }
                    else if (flogStatusManager.flogStatus == FlogStatus.f3)
                    {
                        Color c = tex3.GetPixel(pix_x, 500 - pix_z);
                        animeStatusManager.animeStatus = AnimeStatus.walkanddraw;
                        if ((Math.Abs(c.r - c_gray.r) < 0.05f))
                        {
                        }
                        else
                        {
                            colorBuffer.SetValue(c, pix_x + 699 * (500 - pix_z));
                        }
                    }
                    else if (flogStatusManager.flogStatus == FlogStatus.f4)
                    {
                        Color c = tex4.GetPixel(pix_x, 500 - pix_z);
                        if (Math.Abs(c.r - c_gray.r) < 0.05f)
                        {
                            animeStatusManager.animeStatus = AnimeStatus.walk;
                        }
                        else
                        {
                            animeStatusManager.animeStatus = AnimeStatus.put;
                            colorBuffer.SetValue(c, pix_x + 699 * (500 - pix_z));
                        }
                    }
                    else if (flogStatusManager.flogStatus == FlogStatus.f5)
                    {
                        Color c = tex5.GetPixel(pix_x, 500 - pix_z);
                        if (Math.Abs(c.r - c_gray.r) < 0.05f)
                        {
                            animeStatusManager.animeStatus = AnimeStatus.walk;
                        }
                        else
                        {
                            animeStatusManager.animeStatus = AnimeStatus.put;
                            colorBuffer.SetValue(c, pix_x + 699 * (500 - pix_z));
                        }
                    }
                    else
                    {
                    }
                }
                else
                {
                    colorBuffer.SetValue(new Color(0.5f, 0.5f, 0.5f), drawX + 350 * drawY);
                }
            }
        }
    }