Пример #1
0
    void OnScreen(int i)
    {
        //if transform destroy, then remove from list
        if (!Huds[i].m_Target)
        {
            Huds.Remove(Huds[i]);
            return;
        }
        //Check target if OnScreen
        if (HWPUtility.isOnScreen(HWPUtility.ScreenPosition(Huds[i].m_Target), Huds[i].m_Target) &&
            IsPlaying &&                                                                                                           // Тоглох
            !Huds[i].character ? true : Huds[i].character.data.isLive &&                                                           // амьд
            (A.FollowType == FollowType.Hud || A.FollowType == FollowType.HudPointer || A.FollowType == FollowType.HudPointerOff)) // HUD
        {
            //Calculate Position of target
            Vector3 RelativePosition = Huds[i].m_Target.position + Huds[i].Offset;
            if ((Vector3.Dot(this.LocalPlayer.forward, RelativePosition - this.LocalPlayer.position) > 0f))
            {
                //Calculate the 2D position of the position where the icon should be drawn
                Vector3 point = HWPUtility.mCamera.WorldToViewportPoint(RelativePosition);

                //The viewportPoint coordinates are between 0 and 1, so we have to convert them into screen space here
                Vector2 drawPosition = new Vector2(point.x * Screen.width, Screen.height * (1 - point.y));

                if (!Huds[i].arrow.ShowArrow)
                {
                    //Clamp the position to the edge of the screen in case the icon would be drawn outside the screen
                    drawPosition.x = Mathf.Clamp(drawPosition.x, clampBorder, Screen.width - clampBorder);
                    drawPosition.y = Mathf.Clamp(drawPosition.y, clampBorder, Screen.height - clampBorder);
                }
                //Calculate distance from player to way point
                float Distance = Vector3.Distance(this.LocalPlayer.position, RelativePosition);
                //Cache distance
                float CompleteDistance = Distance;

                //Max Hud Increment
                if (Distance > Huds[i].m_MaxSize) // if more than "50" no increase more
                {
                    Distance = 50;
                }
                float n = IconSize;
                //Calculate depend of type
                if (Huds[i].m_TypeHud == HWPType.Decreasing)
                {
                    n = (((50 + Distance) / (25)) * 0.9f) + 0.1f;
                }
                else if (Huds[i].m_TypeHud == HWPType.Increasing)
                {
                    n = (((50 - Distance) / (25)) * 0.9f) + 0.1f;
                }
                //Calculate Size of Hud
                float sizeX = Huds[i].m_Icon.width * n;
                if (sizeX >= Huds[i].m_MaxSize)
                {
                    sizeX = Huds[i].m_MaxSize;
                }
                float sizeY = Huds[i].m_Icon.height * n;
                if (sizeY >= Huds[i].m_MaxSize)
                {
                    sizeY = Huds[i].m_MaxSize;
                }
                float TextUperIcon = sizeY / 2 + 5;

                //palpating effect
                if (Huds[i].isPalpitin)
                {
                    Palpating(Huds[i]);
                }
                //Draw Huds
                GUI.color = Huds[i].color;
                GUI.DrawTexture(new Rect(drawPosition.x - (sizeX / 2), drawPosition.y - (sizeY / 2), sizeX, sizeY), Huds[i].m_Icon);
                if (!Huds[i].ShowDistance)
                {
                    if (!string.IsNullOrEmpty(Huds[i].text))
                    {
                        Vector2 size = TextStyle.CalcSize(new GUIContent(Huds[i].text));
                        GUI.Label(new Rect(drawPosition.x - (size.x / 2) + 10, (drawPosition.y - (size.y / 2)) - TextUperIcon, size.x, size.y), Huds[i].text, TextStyle);
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(Huds[i].text))
                    {
                        string  text = Huds[i].text + "\n<color=whitte>[" + string.Format("{0:N0}m", CompleteDistance) + "]</color>";
                        Vector2 size = TextStyle.CalcSize(new GUIContent(text));
                        GUI.Label(new Rect(drawPosition.x - (size.x / 2) + 10, (drawPosition.y - (size.y / 2)) - TextUperIcon, size.x, size.y), text, TextStyle);
                    }
                    else
                    {
                        string  text = "<color=whitte>[" + string.Format("{0:N0}m", CompleteDistance) + "]</color>";
                        Vector2 size = TextStyle.CalcSize(new GUIContent(text));
                        GUI.Label(new Rect(drawPosition.x - (size.x / 2) + 10, ((drawPosition.y - (size.y / 2)) - TextUperIcon), size.x, size.y), text, TextStyle);
                    }
                }
            }
        }
    }
Пример #2
0
    void OffScreen(int i)
    {
        //if transform destroy, then remove from list
        if (!Huds[i].m_Target)
        {
            Huds.Remove(Huds[i]);
            return;
        }
        if (Huds[i].arrow.ArrowIcon && Huds[i].arrow.ShowArrow &&
            IsPlaying &&                                                           // Тоглох
            !Huds[i].character ? true : Huds[i].character.data.isLive &&           // амьд
            GameController.Kills + A.GC.showFollowLive >= A.Characters.Count &&    // showFollowLive хүнтэй
            (A.FollowType != FollowType.Follow && A.FollowType != FollowType.Hud)) // заагчтай
        {
            //Check target if OnScreen
            if (!HWPUtility.isOnScreen(HWPUtility.ScreenPosition(Huds[i].m_Target), Huds[i].m_Target))
            {
                //Get the relative position of arrow
                Vector3 ArrowPosition = Huds[i].m_Target.position + Huds[i].arrow.ArrowOffset;
                Vector3 pointArrow    = HWPUtility.mCamera.WorldToScreenPoint(ArrowPosition);

                pointArrow.x = pointArrow.x / HWPUtility.mCamera.pixelWidth;
                pointArrow.y = pointArrow.y / HWPUtility.mCamera.pixelHeight;

                Vector3 mForward = Huds[i].m_Target.position - HWPUtility.mCamera.transform.position;
                Vector3 mDir     = HWPUtility.mCamera.transform.InverseTransformDirection(mForward);
                mDir         = mDir.normalized / 5;
                pointArrow.x = 0.5f + mDir.x * 20f / HWPUtility.mCamera.aspect;
                pointArrow.y = 0.5f + mDir.y * 20f;

                if (pointArrow.z < 0)
                {
                    pointArrow *= -1f;
                    pointArrow *= -1f;
                }
                //Arrow
                GUI.color = Huds[i].color;

                float Xpos = HWPUtility.mCamera.pixelWidth * pointArrow.x;
                float Ypos = HWPUtility.mCamera.pixelHeight * (1f - pointArrow.y);

                //palpating effect
                if (Huds[i].isPalpitin)
                {
                    Palpating(Huds[i]);
                }

                //Calculate area to rotate guis
                float mRot = HWPUtility.GetRotation(HWPUtility.mCamera.pixelWidth / (2), HWPUtility.mCamera.pixelHeight / (2), Xpos, Ypos);
                //Get pivot from area
                Vector2 pivot = HWPUtility.GetPivot(Xpos, Ypos, Huds[i].arrow.size);
                //Arrow
                Vector2   rotVec = new Vector2(M.Cos(mRot), M.Sin(mRot));
                Vector2   pos1   = pivot - rotVec * offScreenArrowDis;
                Matrix4x4 matrix = GUI.matrix;
                GUIUtility.RotateAroundPivot(mRot - 90, pos1);
                GUI.DrawTexture(new Rect(pos1.x - HWPUtility.HalfSize(Huds[i].arrow.size), pos1.y - HWPUtility.HalfSize(Huds[i].arrow.size), Huds[i].arrow.size, Huds[i].arrow.size), Huds[i].arrow.ArrowIcon);
                GUI.matrix = matrix;

                float ClampedX = Mathf.Clamp(pivot.x, 20, (Screen.width - OffScreenIconSize) - 20);
                float ClampedY = Mathf.Clamp(pivot.y, 20, (Screen.height - OffScreenIconSize) - 20);
                GUI.DrawTexture(HWPUtility.ScalerRect(new Rect(ClampedX, ClampedY, OffScreenIconSize, OffScreenIconSize)), Huds[i].m_Icon);

                Vector2 pos = pivot;
                //Icons and Text
                if (A.FollowType != FollowType.FollowPointerOff && A.FollowType != FollowType.HudPointerOff)
                {
                    if (!Huds[i].ShowDistance)
                    {
                        if (!string.IsNullOrEmpty(Huds[i].text))
                        {
                            Vector2 size = TextStyle.CalcSize(new GUIContent(Huds[i].text));
                            // pos.x = Mathf.Clamp (pos.x, (size.x + OffScreenIconSize) + 30, ((Screen.width - OffScreenIconSize) - 10) - size.x);
                            // pos.y = Mathf.Clamp (pos.y, (size.y + OffScreenIconSize) + 35, ((Screen.height - size.y) - OffScreenIconSize) - 20);
                            pos = pivot - rotVec * offScreenNameDis;
                            GUIUtility.RotateAroundPivot(mRot - 90, pos);
                            GUI.Label(HWPUtility.ScalerRect(new Rect(
                                                                pos.x - (size.x / 2),
                                                                pos.y - (size.y / 2),
                                                                size.x, size.y)), Huds[i].text, TextStyle);
                            GUI.matrix = matrix;
                        }
                    }
                    else
                    {
                        float Distance = Vector3.Distance(LocalPlayer.position, Huds[i].m_Target.position);
                        if (!string.IsNullOrEmpty(Huds[i].text))
                        {
                            string  text = Huds[i].text + "\n <color=whitte>[" + string.Format("{0:N0}m", Distance) + "]</color>";
                            Vector2 size = TextStyle.CalcSize(new GUIContent(text));
                            pos.x = Mathf.Clamp(pos.x, (size.x + OffScreenIconSize) + 30, ((Screen.width - OffScreenIconSize) - 10) - size.x);
                            pos.y = Mathf.Clamp(pos.y, (size.y + OffScreenIconSize) + 35, ((Screen.height - size.y) - OffScreenIconSize) - 20);
                            GUI.Label(HWPUtility.ScalerRect(new Rect(pos.x - (size.x / 2), (pos.y - (size.y / 2)), size.x, size.y)), text, TextStyle);
                        }
                        else
                        {
                            string  text = "<color=whitte>[" + string.Format("{0:N0}m", Distance) + "]</color>";
                            Vector2 size = TextStyle.CalcSize(new GUIContent(text));
                            pos.x = Mathf.Clamp(pos.x, (size.x + OffScreenIconSize) + 30, ((Screen.width - OffScreenIconSize) - 10) - size.x);
                            pos.y = Mathf.Clamp(pos.y, (size.y + OffScreenIconSize) + 35, ((Screen.height - size.y) - OffScreenIconSize) - 20);
                            GUI.Label(HWPUtility.ScalerRect(new Rect(pos.x - (size.x / 2), (pos.y - (size.y / 2)), size.x, size.y)), text, TextStyle);
                        }
                    }
                }
                // GUI.DrawTexture(bl_HudUtility.ScalerRect(new Rect(mPivot.x + marge.x,(mPivot.y + ((!Huds[i].ShowDistance) ? 10 : 20)) + marge.y, 25, 25)), Huds[i].m_Icon);
            }
            GUI.color = Color.white;
        }
    }