Esempio n. 1
0
        private bool RightArrowLightMode(int segmentId, Vector3 screenPos, float lightWidth,
                                         float pedestrianWidth, float zoom, float lightHeight, ICustomSegmentLight segmentDict, bool hoveredSegment)
        {
            SetAlpha(segmentId, 5);

            var myRect5 =
                new Rect(screenPos.x - lightWidth / 2 - lightWidth - pedestrianWidth + 5f * zoom,
                         screenPos.y - lightHeight / 2, lightWidth, lightHeight);

            switch (segmentDict.LightRight)
            {
            case RoadBaseAI.TrafficLightState.Green:
                GUI.DrawTexture(myRect5, TextureResources.GreenLightRightTexture2D);
                break;

            case RoadBaseAI.TrafficLightState.Red:
                GUI.DrawTexture(myRect5, TextureResources.RedLightRightTexture2D);
                break;
            }

            if (!myRect5.Contains(Event.current.mousePosition))
            {
                return(hoveredSegment);
            }

            _hoveredButton[0] = segmentId;
            _hoveredButton[1] = 5;

            if (!MainTool.CheckClicked())
            {
                return(true);
            }
            segmentDict.ChangeRightLight();
            return(true);
        }
        private bool RightForwardLSegmentLightMode(int segmentId,
                                                   Vector3 screenPos,
                                                   float lightWidth,
                                                   float pedestrianWidth,
                                                   float zoom,
                                                   float lightHeight,
                                                   bool hasForwardSegment,
                                                   bool hasLeftSegment,
                                                   ICustomSegmentLight segmentDict,
                                                   bool hasRightSegment,
                                                   bool hoveredSegment)
        {
            SetAlpha(segmentId, 3);

            var myRect4 = new Rect(
                screenPos.x - (lightWidth / 2) - (lightWidth * 2) - pedestrianWidth + (5f * zoom),
                screenPos.y - (lightHeight / 2),
                lightWidth,
                lightHeight);

            if (hasForwardSegment && hasLeftSegment)
            {
                switch (segmentDict.LightLeft)
                {
                case RoadBaseAI.TrafficLightState.Green: {
                    GUI.DrawTexture(myRect4, TrafficLightTextures.GreenLightForwardLeft);
                    break;
                }

                case RoadBaseAI.TrafficLightState.Red: {
                    GUI.DrawTexture(myRect4, TrafficLightTextures.RedLightForwardLeft);
                    break;
                }
                }
            }
            else if (!hasLeftSegment)
            {
                if (!hasRightSegment)
                {
                    myRect4 = new Rect(
                        screenPos.x - (lightWidth / 2) - lightWidth - pedestrianWidth + (5f * zoom),
                        screenPos.y - (lightHeight / 2),
                        lightWidth,
                        lightHeight);
                }

                switch (segmentDict.LightMain)
                {
                case RoadBaseAI.TrafficLightState.Green: {
                    GUI.DrawTexture(myRect4, TrafficLightTextures.GreenLightStraight);
                    break;
                }

                case RoadBaseAI.TrafficLightState.Red: {
                    GUI.DrawTexture(myRect4, TrafficLightTextures.RedLightStraight);
                    break;
                }
                }
            }
            else
            {
                if (!hasRightSegment)
                {
                    myRect4 = new Rect(
                        screenPos.x - (lightWidth / 2) - lightWidth - pedestrianWidth + (5f * zoom),
                        screenPos.y - (lightHeight / 2),
                        lightWidth,
                        lightHeight);
                }

                switch (segmentDict.LightMain)
                {
                case RoadBaseAI.TrafficLightState.Green: {
                    GUI.DrawTexture(myRect4, TrafficLightTextures.GreenLightLeft);
                    break;
                }

                case RoadBaseAI.TrafficLightState.Red: {
                    GUI.DrawTexture(myRect4, TrafficLightTextures.RedLightLeft);
                    break;
                }
                }
            }

            if (myRect4.Contains(Event.current.mousePosition))
            {
                hoveredButton[0] = segmentId;
                hoveredButton[1] = 3;
                hoveredSegment   = true;

                if (MainTool.CheckClicked())
                {
                    segmentDict.ChangeMainLight();
                }
            }

            Color guiColor = GUI.color;

            // right arrow light
            if (hasRightSegment)
            {
                guiColor.a = TrafficManagerTool.GetHandleAlpha(
                    hoveredButton[0] == segmentId && hoveredButton[1] == 4);
            }

            GUI.color = guiColor;

            var myRect5 =
                new Rect(
                    screenPos.x - (lightWidth / 2) - lightWidth - pedestrianWidth + (5f * zoom),
                    screenPos.y - (lightHeight / 2),
                    lightWidth,
                    lightHeight);

            switch (segmentDict.LightRight)
            {
            case RoadBaseAI.TrafficLightState.Green: {
                GUI.DrawTexture(myRect5, TrafficLightTextures.GreenLightRight);
                break;
            }

            case RoadBaseAI.TrafficLightState.Red: {
                GUI.DrawTexture(myRect5, TrafficLightTextures.RedLightRight);
                break;
            }
            }

            if (!myRect5.Contains(Event.current.mousePosition))
            {
                return(hoveredSegment);
            }

            hoveredButton[0] = segmentId;
            hoveredButton[1] = 4;

            if (!MainTool.CheckClicked())
            {
                return(true);
            }

            segmentDict.ChangeRightLight();
            return(true);
        }