コード例 #1
0
    void Show()
    {
        Clear();

        SOShip[] buildableShips = selectedNode.BuildOptions();

        foreach (SOShip shipData in selectedNode.ShipDataset)
        {
            GameObject newProductionOptionComponent         = Instantiate(ShipProductionComponent, Vector3.zero, Quaternion.identity, (Transform)productionOptionsPanel);
            ShipProductionComponent shipProductionComponent = newProductionOptionComponent.GetComponent <ShipProductionComponent>();

            shipProductionComponent.Ship = shipData;
            newProductionOptionComponent.GetComponent <RawImage>().texture = shipData.sprite.texture;

            if (buildableShips.Contains(shipProductionComponent.Ship))
            {
                shipProductionComponent.Enable();
            }

            shipProductionComponent.Clicked += OnShipProductionComponentClicked;
        }

        view.DOAnchorPos(new Vector2(362, 75), 0.2f);
        shown = true;
    }
コード例 #2
0
    void OnStoreUpdated(string storeKey)
    {
        if (storeKey == "Selection" && uiController.Store[storeKey] != null && uiController.Store[storeKey].GetComponent <ProductionNode>() != null)
        {
            selectedNode = uiController.Store[storeKey].GetComponent <ProductionNode>();

            Show();
        }

        if (storeKey == "Selection" && (uiController.Store[storeKey] == null || uiController.Store[storeKey].GetComponent <ProductionNode>() == null) && shown)
        {
            Hide();
        }

        if (storeKey == "GameState" && uiController.Store[storeKey] == GameState.Over && shown)
        {
            Hide();
        }

        if (storeKey == "CompletedResearch" && selectedNode != null)
        {
            SOShip[] buildableShips = selectedNode.BuildOptions();

            foreach (Transform productionOptionTransform in (Transform)productionOptionsPanel)
            {
                ShipProductionComponent shipProductionComponent = productionOptionTransform.GetComponent <ShipProductionComponent>();

                if (buildableShips.Contains(shipProductionComponent.Ship))
                {
                    shipProductionComponent.Enable();
                }
                else
                {
                    shipProductionComponent.Disable();
                }
            }
        }

        if (storeKey == "SpecialResources" && selectedNode != null)
        {
            SOShip[] buildableShips = selectedNode.BuildOptions();

            foreach (Transform productionOptionTransform in (Transform)productionOptionsPanel)
            {
                ShipProductionComponent shipProductionComponent = productionOptionTransform.GetComponent <ShipProductionComponent>();

                if (buildableShips.Contains(shipProductionComponent.Ship))
                {
                    shipProductionComponent.Enable();
                }
                else
                {
                    shipProductionComponent.Disable();
                }
            }
        }
    }