Пример #1
0
        private void RenderLineAcrossWayPoints(float offset, int width, bool inMiniMap)
        {
            Vector2 previousWayPointPosition = CallerActor.Position;

            if (wayPoints.Count > 0)
            {
                previousWayPointPosition += (wayPoints[0].GridPosition - CallerActor.GridPosition).GetPerpendicular().normalized *offset;
            }
            else
            {
                previousWayPointPosition += (HandlerActor.GridPosition - CallerActor.GridPosition).GetPerpendicular().normalized *offset;
            }

            for (int i = 0; i < wayPoints.Count; i++)
            {
                WayPoint wayPoint         = wayPoints[i];
                Vector2  wayPointPosition = wayPoint.GetPosition(CallerActor, offset);

                if (inMiniMap)
                {
                    RenderingHelper.RenderLineInMiniMap(previousWayPointPosition, wayPointPosition, lineColor, width);
                }
                else
                {
                    RenderingHelper.RenderLineInMonitorWindow(previousWayPointPosition, wayPointPosition, lineColor, width);
                }

                previousWayPointPosition = wayPointPosition;
            }

            Vector2 endPosition = HandlerActor.Position;

            if (wayPoints.Count > 0)
            {
                endPosition += (wayPoints[wayPoints.Count - 1].GridPosition - CallerActor.GridPosition).GetPerpendicular().normalized *offset;
            }
            else
            {
                endPosition += (HandlerActor.GridPosition - CallerActor.GridPosition).GetPerpendicular().normalized *offset;
            }

            if (inMiniMap)
            {
                RenderingHelper.RenderLineInMiniMap(previousWayPointPosition, endPosition, lineColor, width);
            }
            else
            {
                RenderingHelper.RenderLineInMonitorWindow(previousWayPointPosition, endPosition, lineColor, width);
            }
        }
Пример #2
0
        private void RenderDots(Vector2 startPos, Vector2 endPos, Color color, float dotAge)
        {
            float distance = Vector2.Distance(startPos, endPos);

            if (dotAge <= dotMaxAge)
            {
                const int dotCount = 2;
                for (int i = 0; i < dotCount; i++)
                {
                    color.a = 1.0f - dotAge / dotMaxAge;
                    float lerp = ((age / (distance / dotSpeed) + (float)i / dotCount)) % 1;
                    color.a *= Mathf.Sin(lerp * Mathf.PI);
                    Vector2 position = Vector2.Lerp(startPos, endPos, lerp);
                    RenderingHelper.RenderDotInMonitorWindow(position, color, 6, 6);
                }
            }
        }
Пример #3
0
        private void RenderArrow(bool reversed, float offset, int width)
        {
            Vector2 direction;
            Vector2 position;

            Vector2 startPos;
            Vector2 endPos;

            if (!reversed)
            {
                startPos = CallerActor.Position;
                if (wayPoints.Count == 0)
                {
                    endPos = HandlerActor.Position;
                }
                else
                {
                    endPos = wayPoints[0].GetPosition(CallerActor, 0.0f);
                }
            }
            else
            {
                startPos = HandlerActor.Position;
                if (wayPoints.Count == 0)
                {
                    endPos = CallerActor.Position;
                }
                else
                {
                    endPos = wayPoints[wayPoints.Count - 1].GetPosition(CallerActor, 0.0f);
                }
            }

            direction = (endPos - startPos).normalized;
            position  = Vector2.Lerp(startPos, endPos, wayPoints.Count == 0 ? .45f : .9f);

            Vector2 perpendicular = direction.GetPerpendicular();
            Vector2 leftLine      = position + ArrowSize * (-direction + perpendicular);
            Vector2 rightLine     = position + ArrowSize * (-direction - perpendicular);

            Vector2 positionOffset = perpendicular * offset;

            RenderingHelper.RenderLineInMonitorWindow(position + positionOffset, leftLine + positionOffset, lineColor, width);
            RenderingHelper.RenderLineInMonitorWindow(position + positionOffset, rightLine + positionOffset, lineColor, width);
        }
Пример #4
0
        public void RenderLineInMiniMap(Vector2 startPos, Vector2 endPos)
        {
            Vector2 offset = Vector2.zero;

            if (HasChangeRelation && HasDeleteRelation)
            {
                offset = (endPos - startPos).GetPerpendicular().normalized * 2.0f;
            }

            if (HasChangeRelation)
            {
                RenderingHelper.RenderLineInMiniMap(startPos - offset, endPos - offset, new Color(1.0f, 1.0f, 1.0f, .5f), 1);
            }
            if (HasDeleteRelation)
            {
                RenderingHelper.RenderLineInMiniMap(startPos + offset, endPos + offset, new Color(1.0f, 1.0f, 1.0f, .5f), 1);
            }
        }
Пример #5
0
        public void RenderMiniMap()
        {
            Vector2 start = TypeWidget.Position - .25f * ModelTypeWidget.Width * Vector2.right + .5f * ModelTypeWidget.Height * Vector2.up;

            foreach (ModelTypeWidgetNode node in nodes)
            {
                Vector2 end = node.TypeWidget.Position - .5f * ModelTypeWidget.Width * Vector2.right;
                Vector2 mid = new Vector2(start.x, end.y);
                RenderingHelper.RenderLineInMiniMap(start, mid, new Color(1.0f, 1.0f, 1.0f, .3f), 1);
                RenderingHelper.RenderLineInMiniMap(mid, end, new Color(1.0f, 1.0f, 1.0f, .3f), 1);
                start = new Vector2(TypeWidget.Position.x - .25f * ModelTypeWidget.Width, node.TypeWidget.Position.y);
            }

            TypeWidget.RenderMiniMap();
            foreach (ModelTypeWidgetNode node in nodes)
            {
                node.RenderMiniMap();
            }
        }
Пример #6
0
        private void RenderDots(bool reversed, float offset)
        {
            const int dotCount = 2;

            for (int i = 0; i < dotCount; i++)
            {
                float timeSinceLastSend = age - (reversed ? lastReverseSendTime : lastSendTime);
                if (timeSinceLastSend <= DotMaxAge)
                {
                    lineColor.a = Mathf.Sin((1.0f - timeSinceLastSend / DotMaxAge) * Mathf.PI * 0.5f);
                    float lerp = (age / (totalGridDistance) + (float)i / dotCount) % 1;
                    if (reversed)
                    {
                        lerp = 1.0f - lerp;
                    }
                    lineColor.a *= Mathf.Sin(lerp * Mathf.PI);
                    Vector2 position = GetPositionOnLine(lerp, offset);
                    RenderingHelper.RenderDotInMonitorWindow(position, lineColor, 6, 6);
                }
            }
        }
Пример #7
0
        public void Render()
        {
            Vector2 start = TypeWidget.Position - .25f * ModelTypeWidget.Width * Vector2.right + .5f * ModelTypeWidget.Height * Vector2.up;

            foreach (ModelTypeWidgetNode node in nodes)
            {
                Vector2 end = node.TypeWidget.Position - .5f * ModelTypeWidget.Width * Vector2.right;
                Vector2 mid = new Vector2(start.x, end.y);
                RenderingHelper.RenderLineInMonitorWindow(start, mid, Color.white, 1);
                RenderingHelper.RenderLineInMonitorWindow(mid, end, Color.white, 1);
                start = new Vector2(TypeWidget.Position.x - .25f * ModelTypeWidget.Width, node.TypeWidget.Position.y);
            }

            TypeWidget.Render();

            foreach (ModelTypeWidgetNode node in nodes)
            {
                Vector2 aggregationCountPosition = node.TypeWidget.Position - .70f * ModelTypeWidget.Width * Vector2.right + CodeControlMonitorWindow.WindowOffset;
                CodeControlEditorStyles.SetLabelStyle(CodeControlEditorStyles.LabelStyle.AggregationCountType);
                GUI.Label(new Rect(aggregationCountPosition.x - 100, aggregationCountPosition.y - 8, 100, 30), node.AggregationCountType);
                CodeControlEditorStyles.ResetLabelStyle();
                node.Render();
            }
        }