Exemple #1
0
    public PROPAGATION onMessage(string message, object data)
    {
        if (message == "RClick")
        {
            Vector3 position = (Vector3)data;
            if (mouseDownPosition == Misc.VECTOR3_NULL)
            {
                // Right click when no object is active for rerouting
                InformationBase selectedObject = InformationBase.GetInformationBaseAtPosition(position);
                if (selectedObject != null)
                {
                    GameObject rerouteGameObject = selectedObject.gameObject;
                    IReroute   componentIReroute = rerouteGameObject.GetComponent <IReroute>();
                    if (componentIReroute.isRerouteOk())
                    {
                        mouseDownPosition      = position;
                        RerouteInfo.gameObject = rerouteGameObject;
                        RerouteInfo.iReroute   = componentIReroute;
                        RerouteInfo.isVehicle  = selectedObject.type == InformationBase.TYPE_VEHICLE;
                        RerouteInfo.iReroute.pauseMovement();
                        RerouteInfo.isReroute    = false;
                        RerouteInfo.originalPath = RerouteInfo.iReroute.getPath();
                        RerouteInfo.positionOriginalPathHalos();
                        Vector3 objectPosition = rerouteGameObject.transform.position;
                        haloObject.transform.localPosition = new Vector3(objectPosition.x, objectPosition.y, 0f);
                        haloObject.SetActive(true);
                        originalParentObj.SetActive(true);
                        rerouteParentObj.SetActive(false);
                        inactivateHaloObjects(reroutePathHalos);
                    }
                    else
                    {
                        // Re-routing not accepted, play sound
                        GenericSoundEffects.playRerouteUnavailable();
                    }
                }
            }
            else
            {
                if (RerouteInfo.isReroute && RerouteInfo.reroutePath.Count > 0)
                {
                    RerouteInfo.iReroute.setPath(RerouteInfo.reroutePath);
                }
                haloObject.SetActive(false);
                originalParentObj.SetActive(false);
                rerouteParentObj.SetActive(false);
                inactivateHaloObjects(originalPathHalos);
                inactivateHaloObjects(reroutePathHalos);
                RerouteInfo.iReroute.resumeMovement();

                RerouteInfo.gameObject = null;
                RerouteInfo.iReroute   = null;
                mouseDownPosition      = Misc.VECTOR3_NULL;
            }
        }
        else if (message == "RMove")
        {
            if (RerouteInfo.gameObject != null)
            {
                Vector3 mousePos        = (Vector3)data;
                Vector3 objectScreenPos = Game.instance.objectToScreenPos(RerouteInfo.gameObject);
                float   moveFromObject  = Misc.getDistance(mousePos, objectScreenPos);
                if (moveFromObject >= DISTANCE_FOR_REROUTE)
                {
// Get re-route pos object
                    Vector2 mousePosVector2 = Game.instance.screenToWorldPosInBasePlane(mousePos);
                    Pos     pos             = NodeIndex.getPosClosestTo(mousePosVector2, RerouteInfo.isVehicle);

                    int pathPoints   = RerouteInfo.originalPath.Count;
                    Pos addToPathPos = null;
                    Pos targetPos    = RerouteInfo.originalPath[RerouteInfo.originalPath.Count - 1];
                    if (targetPos.Id == -1L)
                    {
                        addToPathPos = targetPos;
                        targetPos    = RerouteInfo.originalPath[RerouteInfo.originalPath.Count - 2];
                        pathPoints--;
                    }

                    if (pathPoints > 2)
                    {
                        Pos startPos = RerouteInfo.originalPath[1];
                        RerouteInfo.reroutePath = Game.calculateCurrentPaths(startPos, targetPos, RerouteInfo.originalPath[0], pos, RerouteInfo.isVehicle, !RerouteInfo.isVehicle);

                        if (RerouteInfo.reroutePath.Count > 0)
                        {
                            RerouteInfo.reroutePath.Insert(0, Game.createTmpPos(RerouteInfo.gameObject.transform.position));
                            if (addToPathPos != null)
                            {
                                // Remove last path, if endPos is on this wayReference
                                if (!RerouteInfo.isVehicle && RerouteInfo.gameObject.GetComponent <HumanLogic>().endWay.hasNodes(RerouteInfo.reroutePath[RerouteInfo.reroutePath.Count - 2], RerouteInfo.reroutePath[RerouteInfo.reroutePath.Count - 1]))
                                {
                                    RerouteInfo.reroutePath.RemoveAt(RerouteInfo.reroutePath.Count - 1);
                                }

                                // Human should walk to end pos (tmp Pos object)
                                RerouteInfo.reroutePath.Add(addToPathPos);
                            }
//                        if (!RerouteInfo.isVehicle && isGoingFrontAndBackOnWay(RerouteInfo.originalPath)) {
//                            RerouteInfo.reroutePath.RemoveAt(1);
//                        }
                            RerouteInfo.isReroute = true;
                            RerouteInfo.positionReroutePathHalos();
                            rerouteParentObj.SetActive(true);
                            originalParentObj.SetActive(false);
                            inactivateHaloObjects(originalPathHalos);
                        }
                        else
                        {
                            RerouteInfo.isReroute = false;
                            originalParentObj.SetActive(true);
                            rerouteParentObj.SetActive(false);
                            inactivateHaloObjects(reroutePathHalos);
                        }
                    }
                }
            }
            else if (RerouteInfo.isReroute)
            {
                RerouteInfo.isReroute = false;
                originalParentObj.SetActive(true);
                rerouteParentObj.SetActive(false);
                inactivateHaloObjects(reroutePathHalos);
            }
//            Debug.Log(objectScreenPos + " - " + mousePos);

//            Vector3 objectPosition = Game.getCameraPosition(pos);
//            haloObject.transform.localPosition = new Vector3(objectPosition.x, objectPosition.y, 0f);
//            haloObject.SetActive(true);
        }
        else if (message == "Graphics:quality")
        {
            float quality = Game.instance.graphicsQuality;
            numberOfHalosInPath = Mathf.FloorToInt(NUMBER_HALOS_MIN + (quality * (NUMBER_HALOS_MAX - NUMBER_HALOS_MIN)));
//            activateHaloObjects(originalPathHalos);
//            activateHaloObjects(reroutePathHalos);
        }
        return(PROPAGATION.DEFAULT);
    }
Exemple #2
0
    private float drawSummaryInnerContents(float popupWidth, bool onlyCalculation = false)
    {
        float pointY = 0;

        printTitle("Points:", ref pointY, popupWidth, subtitleStyle, onlyCalculation);

        int points = summary.pointsBefore;

        // Present included points
        foreach (PointCalculator.Point point in summary.alreadyIncluded)
        {
            printPointData(point, ref pointY, popupWidth, onlyCalculation);
        }

        // Present each "not yet included" points
        foreach (PointCalculator.Point point in summary.notYetIncluded)
        {
            printPointData(point, ref pointY, popupWidth, onlyCalculation);
            points += point.calculatedValue;
        }

        // Present total points
        PointCalculator.Point totalPoints = new PointCalculator.Point(PointCalculator.Point.TYPE_TOTAL_POINTS, "Total", points);
        if (!onlyCalculation)
        {
            EditorGUIx.DrawLine(new Vector2(5f, 4f + pointY), new Vector2(popupWidth - 5f, 4f + pointY), 2f);
        }
        pointY += 7f;
        printPointData(totalPoints, ref pointY, popupWidth, onlyCalculation);

        if (!summary.failedMission)
        {
            drawStars(summary.numberOfStars, ref pointY, popupWidth, onlyCalculation: onlyCalculation);
        }

        if (summary.newHighscore)
        {
            drawHighscoreStamp(ref pointY, popupWidth, onlyCalculation);
            if (!onlyCalculation)
            {
                if (!summary.havePlayedHighscoreSound)
                {
                    summary.havePlayedHighscoreSound = true;
                    GenericSoundEffects.playHighscoreSerenade();
                }
            }
        }

        if (summary.failedMission)
        {
            drawFailedStamp(ref pointY, popupWidth, onlyCalculation);
            if (!onlyCalculation)
            {
                if (!summary.havePlayedFailedSound)
                {
                    summary.havePlayedFailedSound = true;
                    GenericSoundEffects.playFailSound();
                }
            }
        }

        return(pointY);
    }
Exemple #3
0
 // Use this for initialization
 void Start()
 {
     instance = this;
 }