Exemplo n.º 1
0
        void Handle_Clicked(object sender, System.EventArgs e)
        {
            if (_revealing)
            {
                Revealer.StartHidingAnimation();
            }
            else
            {
                Revealer.StartRevealAnimation();
            }


            _revealing = !_revealing;


            _ = btn.RotateTo(720, length: 850, easing: Easing.CubicOut)
                .ContinueWith(t => btn.Rotation = 0.0);
            //.ContinueWith(t => LabelRevealer.StartRevealAnimation());

            btn.Animate("OpacityAnimation", d =>
            {
                if (d < 0.5)
                {
                    btn.Opacity = 1.0 - d;
                }
                else
                {
                    btn.Opacity         = d;
                    btn.BackgroundColor = _revealing ? Color.White : Color.DodgerBlue;
                }
            }, length: 600);
        }
Exemplo n.º 2
0
    /// <summary>
    /// Reveal the map using a cached result.
    /// </summary>

    void RevealUsingCache(Revealer r, float worldToTex)
    {
        if (r.mCachedBuffer == null)
        {
            RevealIntoCache(r, worldToTex);
        }

        Color32 white = new Color32(255, 255, 255, 255);

        for (int y = r.mCachedY, ymax = r.mCachedY + r.mCachedSize; y < ymax; ++y)
        {
            if (y > -1 && y < textureSize)
            {
                int by = y * textureSize;
                int cy = (y - r.mCachedY) * r.mCachedSize;

                for (int x = r.mCachedX, xmax = r.mCachedX + r.mCachedSize; x < xmax; ++x)
                {
                    if (x > -1 && x < textureSize)
                    {
                        int cachedIndex = x - r.mCachedX + cy;

                        if (r.mCachedBuffer[cachedIndex])
                        {
                            mBuffer1[x + by] = white;
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 3
0
 // called once at DivRoot.Awake() or instantiation
 public void Init()
 {
     Construct();
     Associate();
     ApplyStyle(true);
     Revealer.Init();
     Revealer.SetVisibility(ElementStyle.IsVisibleAtStart, true);
 }
Exemplo n.º 4
0
    /// <summary>
    /// Create a new fog revealer.
    /// </summary>

    static public Revealer CreateRevealer()
    {
        Revealer rev = new Revealer();

        rev.isActive = false;
        lock (mAdded) mAdded.Add(rev);
        return(rev);
    }
Exemplo n.º 5
0
    //여까지명우가넣은거

    private void Start()
    {
        if (FogOfWar.fogAlignment == FogOfWar.FogAlignment.DDDMode)
        {
            previousFaction          = FogOfWar3D.currentlyRevealed;
            rbody                    = gameObject.AddComponent <Rigidbody>();
            rbody.useGravity         = false;
            rbody.isKinematic        = true;
            sphereCollider           = gameObject.AddComponent <SphereCollider>();
            sphereCollider.isTrigger = true;

            if (FogOfWar3D.currentlyRevealed != faction)
            {
                sphereCollider.radius = 0f;
                isInTheSightRange     = false;//명우가넣은거
                Check();
                //Hide();
            }
            else
            {
                sphereCollider.radius = visionRange;
            }

            revealer3D = new Revealer3D(visionRange,
                                        faction,
                                        transform);

            FogOfWar3D.RegisterRevealer(revealer3D);
        }
        else
        {
            revealer = new Revealer(visionRange,
                                    faction,
                                    upVision,
                                    gameObject);

            FogOfWar.RegisterRevealer(revealer);

            if (dynamicBlock)
            {
                FogOfWar.RegisterVisionBlocker(gameObject);
            }

            if (faction == FogOfWar.RevealFaction)
            {
                isInTheSightRange = true;//명우가넣은거
                Check();
                //Show();
            }
            else
            {
                isInTheSightRange = false;//명우가넣은거
                Check();
                //Hide();
            }
        }
    }
Exemplo n.º 6
0
        public void EnableInstructionOnly_AllElementStateCorrect()
        {
            var revealInstruction = new Revealer();

            _instruction.Accept(revealInstruction);

            Assert.False(_mario.Active);
            Assert.False(_luigi.Active);
            Assert.True(_instruction.Active);
        }
Exemplo n.º 7
0
        /// <summary>
        ///     Reveals any hidden members using the provided expression and revealing convention.
        /// </summary>
        /// <param name="expression">
        ///     The expression.
        /// </param>
        /// <param name="convention">
        ///     The revealing convention.
        /// </param>
        /// <typeparam name="TEntity">
        ///     The <see cref="System.Type" /> of the entity.
        /// </typeparam>
        /// <returns>
        ///     The hidden member name.
        /// </returns>
        public static string ByConvention <TEntity>
        (
            Expression <Func <TEntity, object> > expression,
            IRevealConvention convention
        )
        {
            IRevealer revealer = new Revealer(convention);

            return(revealer.Reveal(expression));
        }
Exemplo n.º 8
0
        /// <summary>
        ///     Reveals any hidden members using the provided expression.
        /// </summary>
        /// <param name="expression">
        ///     The expression.
        /// </param>
        /// <typeparam name="TEntity">
        ///     The <see cref="System.Type" /> of the entity.
        /// </typeparam>
        /// <returns>
        ///     The hidden member name.
        /// </returns>
        public static string ByConvention <TEntity>(Expression <Func <TEntity, object> > expression)
        {
            if (DefaultConvention != null)
            {
                return(ByConvention(expression, DefaultConvention));
            }

            IRevealer revealer = new Revealer();

            return(revealer.Reveal(expression));
        }
Exemplo n.º 9
0
 public override void action()
 {
     GameObject[] objects = GameObject.FindGameObjectsWithTag("HiddenObject");
     foreach (GameObject item in objects)
     {
         Revealer revealer = item.GetComponent <Revealer>();
         revealer.ShowChildren();
     }
     if (fadingIn == null)
     {
         fadingIn = StartCoroutine(fadeIn());
     }
 }
Exemplo n.º 10
0
    void RefreshMapHeight(Revealer r)
    {
        Vector3 pos = r.pos - mMapOrigin;
        int     sx  = Mathf.RoundToInt(pos.x - worldSize * 0.5f) + 1;
        int     sy  = Mathf.RoundToInt(pos.z - worldSize * 0.5f);

        for (int wy = 0, my = sy, ylen = worldSize + sy; my < ylen; my++, wy++)
        {
            for (int wx = 0, mx = sx, xlen = worldSize + sx; mx < xlen; mx++, wx++)
            {
                mHeights[wx, wy] = mMapHeights[mx, my];
            }
        }
    }
Exemplo n.º 11
0
    //public float mod2 = 1;

    /// <summary>
    /// Reveals FOW at position.
    /// </summary>

    void RevealAtPosition(Revealer r, float worldToTex)
    {
        // Position relative to the fog of war
        Vector2 pos = r.pos - mOrigin;
        //if (pos == lastPos) return;

        // Coordinates we'll be dealing with
        int xmin = Mathf.RoundToInt((pos.x - r.revealDistance) * worldToTex);
        int ymin = Mathf.RoundToInt((pos.y - r.revealDistance) * worldToTex);
        int xmax = Mathf.RoundToInt((pos.x + r.revealDistance) * worldToTex);
        int ymax = Mathf.RoundToInt((pos.y + r.revealDistance) * worldToTex);

        int cx = Mathf.RoundToInt(pos.x * worldToTex);
        int cy = Mathf.RoundToInt(pos.y * worldToTex);

        int size = (int)(map.fow.textureSize);

        cx = Mathf.Clamp(cx, 0, size - 1);
        cy = Mathf.Clamp(cy, 0, size - 1);

        int radius = Mathf.RoundToInt(r.revealDistance * r.revealDistance * worldToTex * worldToTex);

        for (int y = ymin; y < ymax; ++y)
        {
            if (y > -1 && y < size)
            {
                int yw = y * size;

                for (int x = xmin; x < xmax; ++x)
                {
                    if (x > -1 && x < size)
                    {
                        int xd   = x - cx;
                        int yd   = y - cy;
                        int dist = xd * xd + yd * yd;

                        // Reveal this pixel
                        if (dist < radius)
                        {
                            mBuffer1[x + yw].r = 255;
                        }
                    }
                }
            }
        }

        //lastPos = pos;
    }
Exemplo n.º 12
0
    /// <summary>
    /// The fastest form of visibility updates -- radius-based, no line of sights checks.
    /// </summary>

    void RevealUsingRadius(Revealer r, float worldToTex)
    {
        // Position relative to the fog of war
        Vector3 pos = r.pos - mOrigin;

        // Coordinates we'll be dealing with
        int xmin = Mathf.RoundToInt((pos.x - r.outer) * worldToTex);
        int ymin = Mathf.RoundToInt((pos.z - r.outer) * worldToTex);
        int xmax = Mathf.RoundToInt((pos.x + r.outer) * worldToTex);
        int ymax = Mathf.RoundToInt((pos.z + r.outer) * worldToTex);

        int cx = Mathf.RoundToInt(pos.x * worldToTex);
        int cy = Mathf.RoundToInt(pos.z * worldToTex);

        cx = Mathf.Clamp(cx, 0, textureSize - 1);
        cy = Mathf.Clamp(cy, 0, textureSize - 1);

        int radius = Mathf.RoundToInt(r.outer * r.outer * worldToTex * worldToTex);

        // Leave the edges unrevealed
        int limit = textureSize - 1;

        for (int y = ymin; y < ymax; ++y)
        {
            if (y > 0 && y < limit)
            {
                int yw = y * textureSize;

                for (int x = xmin; x < xmax; ++x)
                {
                    if (x > 0 && x < limit)
                    {
                        int xd   = x - cx;
                        int yd   = y - cy;
                        int dist = xd * xd + yd * yd;

                        // Reveal this pixel
                        if (dist < radius)
                        {
                            mBuffer1[x + yw].r = 255;
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 13
0
    /// <summary>
    /// 最快的可见性更新——基于辐射的,没有视线检查。
    /// </summary>

    void RevealUsingRadius(Revealer r, float worldToTex)
    {
        // 相对于战争迷雾的位置
        Vector3 pos = r.pos - mOrigin;

        // 我们要处理的坐标
        int xmin = Mathf.RoundToInt((pos.x - r.outer) * worldToTex);
        int ymin = Mathf.RoundToInt((pos.z - r.outer) * worldToTex);
        int xmax = Mathf.RoundToInt((pos.x + r.outer) * worldToTex);
        int ymax = Mathf.RoundToInt((pos.z + r.outer) * worldToTex);

        int cx = Mathf.RoundToInt(pos.x * worldToTex);
        int cy = Mathf.RoundToInt(pos.z * worldToTex);

        cx = Mathf.Clamp(cx, 0, textureSize - 1);
        cy = Mathf.Clamp(cy, 0, textureSize - 1);

        int radius = Mathf.RoundToInt(r.outer * r.outer * worldToTex * worldToTex);

        for (int y = ymin; y < ymax; ++y)
        {
            if (y > -1 && y < textureSize)
            {
                int yw = y * textureSize;

                for (int x = xmin; x < xmax; ++x)
                {
                    if (x > -1 && x < textureSize)
                    {
                        int xd   = x - cx;
                        int yd   = y - cy;
                        int dist = xd * xd + yd * yd;

                        // 揭示这个像素
                        if (dist < radius)
                        {
                            mBuffer1[x + yw].r = 255;
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 14
0
 // called every frame
 public virtual void Refresh(bool instant)
 {
     if (StyleDirty)
     {
         ApplyStyle(instant);
     }
     if (IsVisible && Positioner.Transporting)
     {
         Positioner.Refresh(instant || Revealer.CurrentVisibility == 0);
     }
     if (Revealer.Transitioning)
     {
         Revealer.Refresh(instant);
     }
     if (Sizer.Resizing)
     {
         Sizer.Refresh(instant);
     }
 }
Exemplo n.º 15
0
    public void OnEnable()
    {
        if (!meshRenderer)
        {
            meshRenderer = gameObject.GetComponent <MeshRenderer>();
        }

        _Revealer = new Revealer(VisionRange,
                                 Faction,
                                 UpVision,
                                 gameObject);

        FogOfWar.RegisterRevealer(_Revealer);

        if (FogOfWar.IsPositionRevealedByFaction(transform.position, FogOfWar.RevealFactionInt))
        {
            meshRenderer.enabled = true;
        }
        else
        {
            meshRenderer.enabled = false;
        }
    }
Exemplo n.º 16
0
    public void Start()
    {
        if (!image)
        {
            image = gameObject.GetComponent <Image>();
        }

        _Revealer = new Revealer(VisionRange,
                                 Faction,
                                 UpVision,
                                 gameObject);

        FogOfWar.RegisterRevealer(_Revealer);

        if (FogOfWar.IsPositionRevealedByFaction(transform.position, FogOfWar.RevealFactionInt))
        {
            image.enabled = true;
        }
        else
        {
            image.enabled = false;
        }
    }
Exemplo n.º 17
0
        public Editor(Gtk.Window parent)
        {
            Parent = parent;
            View   = new Box(Orientation.Vertical, 0);

            // Load services
            storage = GlobalDI.GetService <IDocumentsStorage>();

            // Init widgets
            var scrolled = new ScrolledWindow()
            {
                Expand = true
            };

            View.StyleContext.AddClass("view");

            FormatBar      = new FormatBar(Orientation.Horizontal, 6);
            FormatRevealer = new Revealer();
            FormatRevealer.Add(FormatBar);

            FormatRevealer.RevealChild = false;

            TextTagTable tagTable = new TextTagTable();

            foreach (var tag in Tags)
            {
                tagTable.Add(tag.Value);
            }
            TextBuffer        = new TextBuffer(tagTable);
            SerializeFormat   = TextBuffer.RegisterSerializeTagset("text/markdown");
            DeserializeFormat = TextBuffer.RegisterDeserializeTagset("text/markdown");
            EditorView        = new EditorView(TextBuffer);
            scrolled.Add(EditorView);

            View.PackStart(FormatRevealer, false, true, 0);
            View.PackEnd(scrolled, true, true, 0);
        }
Exemplo n.º 18
0
    /// <summary>
    /// Reveal the map using a cached result.
    /// </summary>

    void RevealUsingCache(Revealer r, float worldToTex)
    {
        if (!r.isValid)
        {
            RevealIntoCache(r, worldToTex);
        }

        Color32 white = new Color32(255, 255, 255, 255);

        bool[] buffer = r.cachedBuffer;

        // Leave the edges unrevealed
        int limit = textureSize - 1;

        for (int y = r.cachedY, ymax = r.cachedY + r.cachedSize; y < ymax; ++y)
        {
            if (y > 0 && y < limit)
            {
                int by = y * textureSize;
                int cy = (y - r.cachedY) * r.cachedSize;

                for (int x = r.cachedX, xmax = r.cachedX + r.cachedSize; x < xmax; ++x)
                {
                    if (x > 0 && x < limit)
                    {
                        int cachedIndex = x - r.cachedX + cy;

                        if (buffer[cachedIndex])
                        {
                            mBuffer1[x + by] = white;
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 19
0
	/// <summary>
	/// Create a new fog revealer.
	/// </summary>

	static public Revealer CreateRevealer ()
	{
		Revealer rev = new Revealer();
		rev.isActive = false;
		lock (mAdded) mAdded.Add(rev);
		return rev;
	}
Exemplo n.º 20
0
    /// <summary>
    ///创建缓存的可见结果。
    /// </summary>

    void RevealIntoCache(Revealer r, float worldToTex)
    {
        // 相对于战争迷雾的位置
        Vector3 pos = r.pos - mOrigin;

        // 我们要处理的坐标
        int xmin = Mathf.RoundToInt((pos.x - r.outer) * worldToTex);
        int ymin = Mathf.RoundToInt((pos.z - r.outer) * worldToTex);
        int xmax = Mathf.RoundToInt((pos.x + r.outer) * worldToTex);
        int ymax = Mathf.RoundToInt((pos.z + r.outer) * worldToTex);

        int cx = Mathf.RoundToInt(pos.x * worldToTex);
        int cy = Mathf.RoundToInt(pos.z * worldToTex);

        cx = Mathf.Clamp(cx, 0, textureSize - 1);
        cy = Mathf.Clamp(cy, 0, textureSize - 1);

        // 创建缓冲区以显示
        int size = Mathf.RoundToInt(xmax - xmin);

        r.cachedBuffer = new bool[size * size];
        r.cachedSize   = size;
        r.cachedX      = xmin;
        r.cachedY      = ymin;

        // 缓冲区应该从clear开始
        for (int i = 0, imax = size * size; i < imax; ++i)
        {
            r.cachedBuffer[i] = false;
        }

        int minRange = Mathf.RoundToInt(r.inner * r.inner * worldToTex * worldToTex);
        int maxRange = Mathf.RoundToInt(r.outer * r.outer * worldToTex * worldToTex);
        int variance = Mathf.RoundToInt(Mathf.Clamp01(margin / (heightRange.y - heightRange.x)) * 255);
        int gh       = WorldToGridHeight(r.pos.y);

        for (int y = ymin; y < ymax; ++y)
        {
            if (y > -1 && y < textureSize)
            {
                for (int x = xmin; x < xmax; ++x)
                {
                    if (x > -1 && x < textureSize)
                    {
                        int xd   = x - cx;
                        int yd   = y - cy;
                        int dist = xd * xd + yd * yd;

                        if (dist < minRange || (cx == x && cy == y))
                        {
                            r.cachedBuffer[(x - xmin) + (y - ymin) * size] = true;
                        }
                        else if (dist < maxRange)
                        {
                            Vector2 v = new Vector2(xd, yd);
                            v.Normalize();
                            v *= r.inner;

                            int sx = cx + Mathf.RoundToInt(v.x);
                            int sy = cy + Mathf.RoundToInt(v.y);

                            if (sx > -1 && sx < textureSize &&
                                sy > -1 && sy < textureSize &&
                                IsVisible(sx, sy, x, y, Mathf.Sqrt(dist), gh, variance))
                            {
                                r.cachedBuffer[(x - xmin) + (y - ymin) * size] = true;
                            }
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 21
0
    /// <summary>
    /// Create the cached visibility result.
    /// </summary>

    void RevealIntoCache(Revealer r, float worldToTex)
    {
        // Position relative to the fog of war
        Vector3 pos = r.pos - mOrigin;

        // Coordinates we'll be dealing with
        int xmin = Mathf.RoundToInt((pos.x - r.outer) * worldToTex);
        int ymin = Mathf.RoundToInt((pos.z - r.outer) * worldToTex);
        int xmax = Mathf.RoundToInt((pos.x + r.outer) * worldToTex);
        int ymax = Mathf.RoundToInt((pos.z + r.outer) * worldToTex);

        int cx = Mathf.RoundToInt(pos.x * worldToTex);
        int cy = Mathf.RoundToInt(pos.z * worldToTex);

        cx = Mathf.Clamp(cx, 0, textureSize - 1);
        cy = Mathf.Clamp(cy, 0, textureSize - 1);

        // Create the buffer to reveal into
        int size       = Mathf.Max(Mathf.RoundToInt(xmax - xmin), Mathf.RoundToInt(ymax - ymin));
        int bufferSize = size * size;

        if (r.cachedBuffer == null || r.cachedBuffer.Length != bufferSize)
        {
            r.cachedBuffer = new bool[bufferSize];
        }

        // The buffer should start off clear
        for (int i = 0, imax = size * size; i < imax; ++i)
        {
            r.cachedBuffer[i] = false;
        }

        int minRange = Mathf.RoundToInt(r.inner * r.inner * worldToTex * worldToTex);
        int maxRange = Mathf.RoundToInt(r.outer * r.outer * worldToTex * worldToTex);
        int variance = Mathf.RoundToInt(Mathf.Clamp01(margin / (heightRange.y - heightRange.x)) * 255);
        int gh       = WorldToGridHeight(r.pos.y);

        // Leave the edges unrevealed
        int limit = textureSize - 1;

        for (int y = ymin; y < ymax; ++y)
        {
            if (y > 0 && y < limit)
            {
                for (int x = xmin; x < xmax; ++x)
                {
                    if (x > 0 && x < limit)
                    {
                        int xd   = x - cx;
                        int yd   = y - cy;
                        int dist = xd * xd + yd * yd;

                        if (dist < minRange || (cx == x && cy == y))
                        {
                            r.cachedBuffer[(x - xmin) + (y - ymin) * size] = true;
                        }
                        else if (dist < maxRange)
                        {
                            Vector2 v = new Vector2(xd, yd);
                            v.Normalize();
                            v *= r.inner;

                            int sx = cx + Mathf.RoundToInt(v.x * worldToTex);
                            int sy = cy + Mathf.RoundToInt(v.y * worldToTex);

                            if (sx > -1 && sx < textureSize &&
                                sy > -1 && sy < textureSize &&
                                IsVisible(sx, sy, x, y, Mathf.Sqrt(dist), gh, variance, r.rot, r.fovCosine))
                            {
                                r.cachedBuffer[(x - xmin) + (y - ymin) * size] = true;
                            }
                        }
                    }
                }
            }
        }

        r.cachedSize = size;
        r.cachedX    = xmin;
        r.cachedY    = ymin;
        r.isValid    = true;
    }
Exemplo n.º 22
0
    /// <summary>
    /// Reveal the map around the revealer performing line-of-sight checks.
    /// </summary>

    void RevealUsingLOS(Revealer r, float worldToTex)
    {
        // Position relative to the fog of war
        Vector3 pos = r.pos - mOrigin;

        // Coordinates we'll be dealing with
        int xmin = Mathf.RoundToInt((pos.x - r.outer) * worldToTex);
        int ymin = Mathf.RoundToInt((pos.z - r.outer) * worldToTex);
        int xmax = Mathf.RoundToInt((pos.x + r.outer) * worldToTex);
        int ymax = Mathf.RoundToInt((pos.z + r.outer) * worldToTex);

        xmin = Mathf.Clamp(xmin, 0, textureSize - 1);
        xmax = Mathf.Clamp(xmax, 0, textureSize - 1);
        ymin = Mathf.Clamp(ymin, 0, textureSize - 1);
        ymax = Mathf.Clamp(ymax, 0, textureSize - 1);

        int cx = Mathf.RoundToInt(pos.x * worldToTex);
        int cy = Mathf.RoundToInt(pos.z * worldToTex);

        cx = Mathf.Clamp(cx, 0, textureSize - 1);
        cy = Mathf.Clamp(cy, 0, textureSize - 1);

        int     minRange = Mathf.RoundToInt(r.inner * r.inner * worldToTex * worldToTex);
        int     maxRange = Mathf.RoundToInt(r.outer * r.outer * worldToTex * worldToTex);
        int     gh       = WorldToGridHeight(r.pos.y);
        int     variance = Mathf.RoundToInt(Mathf.Clamp01(margin / (heightRange.y - heightRange.x)) * 255);
        Color32 white    = new Color32(255, 255, 255, 255);

        // Leave the edges unrevealed
        int limit = textureSize - 1;

        for (int y = ymin; y < ymax; ++y)
        {
            if (y > 0 && y < limit)
            {
                for (int x = xmin; x < xmax; ++x)
                {
                    if (x > 0 && x < limit)
                    {
                        int xd    = x - cx;
                        int yd    = y - cy;
                        int dist  = xd * xd + yd * yd;
                        int index = x + y * textureSize;

                        if (dist < minRange || (cx == x && cy == y))
                        {
                            mBuffer1[index] = white;
                        }
                        else if (dist < maxRange)
                        {
                            Vector2 v = new Vector2(xd, yd);
                            v.Normalize();
                            v *= r.inner;

                            int sx = cx + Mathf.RoundToInt(v.x);
                            int sy = cy + Mathf.RoundToInt(v.y);

                            if (sx > -1 && sx < textureSize &&
                                sy > -1 && sy < textureSize &&
                                IsVisible(sx, sy, x, y, Mathf.Sqrt(dist), gh, variance, r.rot, r.fovCosine))
                            {
                                mBuffer1[index] = white;
                            }
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 23
0
    /// <summary>
    /// Update the fog of war's visibility.
    /// </summary>

    void UpdateBuffer()
    {
        // Add all items scheduled to be added
        if (mAdded.Count > 0)
        {
            lock (mAdded)
            {
                while (mAdded.Count > 0)
                {
                    mRevealers.Add(mAdded.Dequeue());
                }
            }
        }

        // Remove all items scheduled for removal
        if (mRemoved.Count > 0)
        {
            lock (mRemoved)
            {
                while (mRemoved.Count > 0)
                {
                    mRevealers.Remove(mRemoved.Dequeue());
                }
            }
        }

        // Use the texture blend time, thus estimating the time this update will finish
        // Doing so helps avoid visible changes in blending caused by the blended result being X milliseconds behind.
        float factor = (textureBlendTime > 0f) ? Mathf.Clamp01(mBlendFactor + mElapsed / textureBlendTime) : 1f;

        //清除缓冲区的红色通道(用于当前可见性的通道——它将在后面更新)
        for (int i = 0, imax = mBuffer0.Length; i < imax; ++i)
        {
            mBuffer0[i]   = Color32.Lerp(mBuffer0[i], mBuffer1[i], factor);
            mBuffer1[i].r = 0;
        }

        // For conversion from world coordinates to texture coordinates
        float worldToTex = (float)textureSize / worldSize;

        // Update the visibility buffer, one revealer at a time
        for (int i = 0; i < mRevealers.Count; ++i)
        {
            Revealer rev = mRevealers[i];
            if (!rev.isActive)
            {
                continue;
            }

            if (rev.los == LOSChecks.None)
            {
                RevealUsingRadius(rev, worldToTex);
            }
            else if (rev.los == LOSChecks.OnlyOnce)
            {
                RefreshMapHeight(rev);
                RevealUsingCache(rev, worldToTex);
            }
            else
            {
                RefreshMapHeight(rev);
                RevealUsingLOS(rev, worldToTex);
            }
        }

        //模糊
        for (int i = 0; i < blurIterations; ++i)
        {
            BlurVisibility();
        }

        //通过更新绿色通道来显示地图最大的红色通道。
        //RevealMap();
    }
Exemplo n.º 24
0
    /// <summary>
    /// Update the fog of war's visibility.
    /// </summary>

    void UpdateBuffer()
    {
        // Add all items scheduled to be added
        if (mAdded.Count > 0)
        {
            lock (mAdded)
            {
                while (mAdded.Count > 0)
                {
                    int index = mAdded.Count - 1;
                    mRevealers.Add(mAdded[index]);
                    mAdded.RemoveAt(index);
                }
            }
        }

        // Remove all items scheduled for removal
        if (mRemoved.Count > 0)
        {
            lock (mRemoved)
            {
                while (mRemoved.Count > 0)
                {
                    int index = mRemoved.Count - 1;
                    mRevealers.Remove(mRemoved[index]);
                    mRemoved.RemoveAt(index);
                }
            }
        }

        // Use the texture blend time, thus estimating the time this update will finish
        // Doing so helps avoid visible changes in blending caused by the blended result being X milliseconds behind.
        float factor = (textureBlendTime > 0f) ? Mathf.Clamp01(mBlendFactor + mElapsed / textureBlendTime) : 1f;

        // Clear the buffer's red channel (channel used for current visibility -- it's updated right after)
        for (int i = 0, imax = mBuffer0.Length; i < imax; ++i)
        {
            mBuffer0[i]   = Color32.Lerp(mBuffer0[i], mBuffer1[i], factor);
            mBuffer1[i].r = 0;
        }

        // For conversion from world coordinates to texture coordinates
        float worldToTex = (float)textureSize / worldSize;

        // Update the visibility buffer, one revealer at a time
        for (int i = 0, imax = mRevealers.Count; i < imax; ++i)
        {
            Revealer rev = mRevealers[i];
            if (!rev.isActive)
            {
                continue;
            }

            lock (rev)
            {
                if (rev.los == LOSChecks.None)
                {
                    RevealUsingRadius(rev, worldToTex);
                }
                else if (rev.los == LOSChecks.OnlyOnce)
                {
                    RevealUsingCache(rev, worldToTex);
                }
                else
                {
                    RevealUsingLOS(rev, worldToTex);
                }
            }
        }

        // Blur the final visibility data
        for (int i = 0; i < blurIterations; ++i)
        {
            BlurVisibility();
        }

        // Reveal the map based on what's currently visible
        RevealVisible();
    }
Exemplo n.º 25
0
 public void RemoveRevealingSource(Revealer r)
 {
     revealingSources.Remove(r);
 }
Exemplo n.º 26
0
	/// <summary>
	/// Create the cached visibility result.
	/// </summary>

	void RevealIntoCache (Revealer r, float worldToTex)
	{
		// Position relative to the fog of war
        Vector3 pos = r.pos - mOrigin;

		// Coordinates we'll be dealing with
		int xmin = Mathf.RoundToInt((pos.x - r.outer) * worldToTex);
		int ymin = Mathf.RoundToInt((pos.z - r.outer) * worldToTex);
		int xmax = Mathf.RoundToInt((pos.x + r.outer) * worldToTex);
		int ymax = Mathf.RoundToInt((pos.z + r.outer) * worldToTex);

		int cx = Mathf.RoundToInt(pos.x * worldToTex);
		int cy = Mathf.RoundToInt(pos.z * worldToTex);

		cx = Mathf.Clamp(cx, 0, textureSize - 1);
		cy = Mathf.Clamp(cy, 0, textureSize - 1);

		// Create the buffer to reveal into
		int size = Mathf.RoundToInt(xmax - xmin);		
		r.cachedBuffer = new bool[size * size];
		r.cachedSize = size;
		r.cachedX = xmin;
		r.cachedY = ymin;

		// The buffer should start off clear
		for (int i = 0, imax = size * size; i < imax; ++i) r.cachedBuffer[i] = false;

		int minRange = Mathf.RoundToInt(r.inner * r.inner * worldToTex * worldToTex);
		int maxRange = Mathf.RoundToInt(r.outer * r.outer * worldToTex * worldToTex);
		int variance = Mathf.RoundToInt(Mathf.Clamp01(margin / (heightRange.y - heightRange.x)) * 255);
		int gh = WorldToGridHeight(r.pos.y);

		for (int y = ymin; y < ymax; ++y)
		{
			if (y > -1 && y < textureSize)
			{
				for (int x = xmin; x < xmax; ++x)
				{
					if (x > -1 && x < textureSize)
					{
						int xd = x - cx;
						int yd = y - cy;
						int dist = xd * xd + yd * yd;

						if (dist < minRange || (cx == x && cy == y))
						{
							r.cachedBuffer[(x - xmin) + (y - ymin) * size] = true;
						}
						else if (dist < maxRange)
						{
							Vector2 v = new Vector2(xd, yd);
							v.Normalize();
							v *= r.inner;

							int sx = cx + Mathf.RoundToInt(v.x);
							int sy = cy + Mathf.RoundToInt(v.y);

							if (sx > -1 && sx < textureSize &&
								sy > -1 && sy < textureSize &&
								IsVisible(sx, sy, x, y, Mathf.Sqrt(dist), gh, variance))
							{
								r.cachedBuffer[(x - xmin) + (y - ymin) * size] = true;
							}
						}
					}
				}
			}
		}
	}
Exemplo n.º 27
0
    /// <summary>
    /// Update the fog of war's visibility.
    /// </summary>

    void UpdateBuffer()
    {
        // Add all items scheduled to be added
        if (mAdded.size > 0)
        {
            lock (mAdded)
            {
                while (mAdded.size > 0)
                {
                    int index = mAdded.size - 1;
                    mRevealers.Add(mAdded.buffer[index]);
                    mAdded.RemoveAt(index);
                }
            }
        }

        // Remove all items scheduled for removal
        if (mRemoved.size > 0)
        {
            lock (mRemoved)
            {
                while (mRemoved.size > 0)
                {
                    int index = mRemoved.size - 1;
                    mRevealers.Remove(mRemoved.buffer[index]);
                    mRemoved.RemoveAt(index);
                }
            }
        }

        // Use the texture blend time, thus estimating the time this update will finish
        // Doing so helps avoid visible changes in blending caused by the blended result being X milliseconds behind.
        float factor = (map.fow.textureBlendTime > 0f) ? Mathf.Clamp01(mBlendFactor + map.elapsed / map.fow.textureBlendTime) : 1f;

        // Clear the buffer's red channel (channel used for current visibility -- it's updated right after)
        if (mBuffer0 != null)
        {
            for (int i = 0, imax = mBuffer0.Length; i < imax; ++i)
            {
                mBuffer0[i]   = Color32.Lerp(mBuffer0[i], mBuffer1[i], factor);
                mBuffer0[i].r = 0;
            }
        }

        // For conversion from world coordinates to texture coordinates
        float worldToTex = (float)(map.fow.textureSize / map.fow.textureSize);

        // Update the visibility buffer, one revealer at a time
        for (int i = 0; i != mRevealers.size; ++i)
        {
            Revealer rev = mRevealers[i];

            if (!rev.isActive)
            {
                continue;
            }

            RevealAtPosition(rev, worldToTex);
        }

        // Blur the final visibility data
        for (int i = 0; i != map.fow.blurIterations; ++i)
        {
            BlurVisibility();
        }

        // Reveal the map based on what's currently visible
        RevealMap();
    }
Exemplo n.º 28
0
	/// <summary>
	/// Delete the specified revealer.
	/// </summary>

	static public void DeleteRevealer (Revealer rev) { lock (mRemoved) mRemoved.Add(rev); }
Exemplo n.º 29
0
	/// <summary>
	/// The fastest form of visibility updates -- radius-based, no line of sights checks.
	/// </summary>

	void RevealUsingRadius (Revealer r, float worldToTex)
	{
		// Position relative to the fog of war
        Vector3 pos = r.pos- mOrigin;
		// Coordinates we'll be dealing with
		int xmin = Mathf.RoundToInt((pos.x - r.outer) * worldToTex);
		int ymin = Mathf.RoundToInt((pos.z - r.outer) * worldToTex);
		int xmax = Mathf.RoundToInt((pos.x + r.outer) * worldToTex);
		int ymax = Mathf.RoundToInt((pos.z + r.outer) * worldToTex);

		int cx = Mathf.RoundToInt(pos.x * worldToTex);
		int cy = Mathf.RoundToInt(pos.z * worldToTex);

		cx = Mathf.Clamp(cx, 0, textureSize - 1);
		cy = Mathf.Clamp(cy, 0, textureSize - 1);

		int radius = Mathf.RoundToInt(r.outer * r.outer * worldToTex * worldToTex);

		for (int y = ymin; y < ymax; ++y)
		{
			if (y > -1 && y < textureSize)
			{
				int yw = y * textureSize;

				for (int x = xmin; x < xmax; ++x)
				{
					if (x > -1 && x < textureSize)
					{
						int xd = x - cx;
						int yd = y - cy;
						int dist = xd * xd + yd * yd;

						// Reveal this pixel
						if (dist < radius) mBuffer1[x + yw].r = 255;
					}
				}
			}
		}
	}
Exemplo n.º 30
0
	/// <summary>
	/// Reveal the map around the revealer performing line-of-sight checks.
	/// </summary>

	void RevealUsingLOS (Revealer r, float worldToTex)
	{
		// Position relative to the fog of war
        Vector3 pos = r.pos - mOrigin;

		// Coordinates we'll be dealing with
		int xmin = Mathf.RoundToInt((pos.x - r.outer) * worldToTex);
		int ymin = Mathf.RoundToInt((pos.z - r.outer) * worldToTex);
		int xmax = Mathf.RoundToInt((pos.x + r.outer) * worldToTex);
		int ymax = Mathf.RoundToInt((pos.z + r.outer) * worldToTex);

		int cx = Mathf.RoundToInt(pos.x * worldToTex);
		int cy = Mathf.RoundToInt(pos.z * worldToTex);

		cx = Mathf.Clamp(cx, 0, textureSize - 1);
		cy = Mathf.Clamp(cy, 0, textureSize - 1);

		int minRange = Mathf.RoundToInt(r.inner * r.inner * worldToTex * worldToTex);
		int maxRange = Mathf.RoundToInt(r.outer * r.outer * worldToTex * worldToTex);
		int gh = WorldToGridHeight(r.pos.y);
		int variance = Mathf.RoundToInt(Mathf.Clamp01(margin / (heightRange.y - heightRange.x)) * 255);
		Color32 white = new Color32(255, 255, 255, 255);

		for (int y = ymin; y < ymax; ++y)
		{
			if (y > -1 && y < textureSize)
			{
				for (int x = xmin; x < xmax; ++x)
				{
					if (x > -1 && x < textureSize)
					{
						int xd = x - cx;
						int yd = y - cy;
						int dist = xd * xd + yd * yd;
						int index = x + y * textureSize;

						if (dist < minRange || (cx == x && cy == y))
						{
							mBuffer1[index] = white;
						}
						else if (dist < maxRange)
						{
							Vector2 v = new Vector2(xd, yd);
							v.Normalize();
							v *= r.inner;

							int sx = cx + Mathf.RoundToInt(v.x);
							int sy = cy + Mathf.RoundToInt(v.y);

							if (sx > -1 && sx < textureSize &&
								sy > -1 && sy < textureSize &&
								IsVisible(sx, sy, x, y, Mathf.Sqrt(dist), gh, variance))
							{
								mBuffer1[index] = white;
							}
						}
					}
				}
			}
		}
	}
Exemplo n.º 31
0
	/// <summary>
	/// Reveal the map using a cached result.
	/// </summary>

	void RevealUsingCache (Revealer r, float worldToTex)
	{
		if (r.cachedBuffer == null) RevealIntoCache(r, worldToTex);

		Color32 white = new Color32(255, 255, 255, 255);

		for (int y = r.cachedY, ymax = r.cachedY + r.cachedSize; y < ymax; ++y)
		{
			if (y > -1 && y < textureSize)
			{
				int by = y * textureSize;
				int cy = (y - r.cachedY) * r.cachedSize;

				for (int x = r.cachedX, xmax = r.cachedX + r.cachedSize; x < xmax; ++x)
				{
					if (x > -1 && x < textureSize)
					{
						int cachedIndex = x - r.cachedX + cy;

						if (r.cachedBuffer[cachedIndex])
						{
							mBuffer1[x + by] = white;
						}
					}
				}
			}
		}
	}
Exemplo n.º 32
0
        public void CanProvideConventionAtInstantiation()
        {
            IRevealer <UserEntity> revealer = new Revealer <UserEntity>(new UnderscoreConvention());

            Assert.That(revealer.Reveal(x => x.Password), Is.EqualTo("_Password"));
        }
Exemplo n.º 33
0
    /// <summary>
    /// Delete the specified revealer.
    /// </summary>

    static public void DeleteRevealer(Revealer rev)
    {
        lock (mRemoved) mRemoved.Add(rev);
    }
Exemplo n.º 34
0
 public void RegisterRevealer(Revealer revealer)
 {
     _revealers.Add(revealer);
 }
Exemplo n.º 35
0
 public void UnregisterRevealer(Revealer revealer)
 {
     _revealers.Remove(revealer);
 }
Exemplo n.º 36
0
 public void AddRevealingSource(Revealer r)
 {
     revealingSources.Add(r);
 }