示例#1
0
    private bool CheckGraphicPolluter(PurchasableIcon purchasableIcon)
    {
        bool hasFoundData = false;

        PolluterAttrib attrib = purchasableIcon.GetPolluterAttributes();

        if (attrib != null)
        {
            hasFoundData = true;

            polluterContent.textTitle.text = attrib.title;

            polluterContent.textDetails.text = "Price: " + attrib.economicAttrib.price + " Income: " + attrib.economicAttrib.profitPerTurn + "\nRemoval cost: " + attrib.economicAttrib.removalCost;

            VulnerabilityAttrib vulnerabilityAttrib = attrib.vulnerabilityAttrib;
            if (vulnerabilityAttrib.vulnerabilities != null)
            {
                string vulnerabilityString = ""; //"Vulnerable to ";
                foreach (VulnerabilityAttrib.Vulnerability v in vulnerabilityAttrib.vulnerabilities)
                {
                    vulnerabilityString += v.disasterName + ": " + v.factor + " ";
                }
                polluterContent.textVulnerabilities.text = vulnerabilityString;
            }
            else
            {
                polluterContent.textVulnerabilities.text = "";
            }


            PollutionMap map = new PollutionMap(attrib.pollutionAttrib.emissions);

            if (purchasableIcon.GetPolluterIcon().GetPolluter().GetEntityType() == EntityType.FILTER)
            {
                map = Util.MultiplyMap(map, (-1));
            }

            VisualAttrib visualAttrib = attrib.visualAttrib;
            if (visualAttrib.imageName != "")
            {
                worldWindow.imageLoader.LoadImage(visualAttrib.imageName);
                imageToShow = true;
            }
            else
            {
                imageToShow = false;
            }

            imageIsDisaster = false;

            SetPieChart(polluterContent.pieChart, map);
        }

        return(hasFoundData);
    }
    void Start()
    {
        attribLoader     = UIManager.Instance.attribLoader;
        playerController = UIManager.Instance.playerController;
        var data = attribLoader.LoadLazy();

        ShowFactories();

        var factoryAttribs = purchasables[0].polluterAttribs;

        foreach (var factoryAttrib in data.factoryList)
        {
            factoryAttribs.Add(factoryAttrib);
        }
        var filterAttribs = purchasables[1].polluterAttribs;

        foreach (var filterAttrib in data.filterList)
        {
            filterAttribs.Add(filterAttrib);
        }


        foreach (var pur in purchasables)
        {
            for (int i = 0; i < pur.polluterAttribs.Count; i++)
            {
                PurchasableIcon purchasableIcon = null;
                Polluter        polluter        = pur.purchasableIcon.GetPolluterIcon().GetPolluter();

                if (polluter is Factory)
                {
                    purchasableIcon = Instantiate(pur.purchasableIcon, factoriesMenu);
                    purchasableIcon.SetSpace(spaceFactories);
                }

                if (polluter is Filter)
                {
                    purchasableIcon = Instantiate(pur.purchasableIcon, filtersMenu);
                    purchasableIcon.SetSpace(spaceFilters);
                }

                purchasableIcon.SetPolluterAttributes(pur.polluterAttribs[i]);
                purchasableIcon.playerController = playerController;

                purchasableIcon.shopTransform = transform;

                purchasableIcon.polluterId = (i + 1);
                purchasableIcon.SetText(purchasableIcon.polluterId.ToString());
            }
        }
    }
示例#3
0
    private bool UIRaycasting()
    {
        bool hasHit = false;

        isBlocked = false;

        pointerEventData          = new PointerEventData(eventSystem);
        pointerEventData.position = Input.mousePosition;
        List <RaycastResult> graphicResults = new List <RaycastResult>();

        graphicRaycaster.Raycast(pointerEventData, graphicResults);

        EventSystem.current.RaycastAll(pointerEventData, graphicResults);

        foreach (RaycastResult rr in graphicResults)
        {
            if (rr.gameObject.CompareTag(blockingRaycastTag))
            {
                isBlocked = true;
                return(hasHit);
            }

            PurchasableIcon purchasableIcon = rr.gameObject.GetComponentInChildren <PurchasableIcon>();
            if (purchasableIcon != null)
            {
                hasHit = true;

                if (purchasableIcon.gameObject != currentGameObject)
                {
                    currentGameObject = purchasableIcon.gameObject;

                    if (CheckGraphicPolluter(purchasableIcon))
                    {
                        HidePopupOtherThan(polluterContent);
                        ShowPopup(polluterContent);
                    }
                }
            }


            if (raycastDisaster)
            {
                DisasterIcon disasterIcon = rr.gameObject.GetComponentInChildren <DisasterIcon>();
                if (disasterIcon != null)
                {
                    hasHit = true;

                    if (disasterIcon.gameObject != currentGameObject)
                    {
                        currentGameObject = disasterIcon.gameObject;

                        if (CheckGraphicDisaster(disasterIcon))
                        {
                            HidePopupOtherThan(disasterContent);
                            ShowPopup(disasterContent);
                        }
                    }
                }
            }
        }

        return(hasHit);
    }