示例#1
0
    private void prepareAuctionPanel(AuctionHandler auction)
    {
        increaseBid.enabled = true;
        decreaseBid.enabled = true;
        App             app         = UnityEngine.Object.FindObjectOfType <App>();
        int             playerIndex = app.GetHumanIndex();
        Nation          player      = State.getNations()[playerIndex];
        TextMeshProUGUI title       = AuctionPanelTitleText.GetComponent <TextMeshProUGUI>();
        Nation          item        = State.getNations()[0];

        // Colony Auction
        backGroudImage.sprite = Resources.Load("Sprites/BackGrounds/imperialism_cartoon", typeof(Sprite)) as Sprite;
        title.text            = "Colony Bids";
        pointTypeText.text    = "Colonial Points";
        // PointTypeImage.sprite = Resources.Load("Sprites/GUI/eagle", typeof(Sprite)) as Sprite;

        item = State.getNations()[auction.getIndexOfCurrentItem()];

        // GameObject mapPrefab = Instantiate(Resources.Load<GameObject>("RPG100set/512/Prop/06_letter" + item.getNationName()));
        currentNumberOfBiddingPoints.text = player.GetColonialPoints().ToString();
        if (player.GetColonialPoints() < State.CurrentColonyAuctionBid || player.RecognizingTheseClaims.Contains(item.getIndex()) || player.landForces.Strength < 2)
        {
            increaseBid.interactable = false;
        }
        else
        {
            increaseBid.interactable = true;
        }

        TextMeshProUGUI itemName = ItemNameText.GetComponent <TextMeshProUGUI>();

        itemName.text = item.getNationName();

        GameObject itemFlag = Instantiate(Resources.Load <GameObject>("Flags/Prefabs/" + item.getNationName()));

        itemFlag1.ObjectPrefab = itemFlag.transform;

        // TextMeshProUGUI currentPlayerBid = currentBidAmount.GetComponent<TextMeshProUGUI>();
        currentBidAmount.text = "00";
        int firstProvIndex  = -1;
        int secondProvIndex = -1;

        foreach (int provIndex in item.getProvinces())
        {
            if (firstProvIndex == -1)
            {
                firstProvIndex = provIndex;
            }
            else
            {
                secondProvIndex = provIndex;
            }
        }

        assemblyCsharp.Province firstProvince = State.getProvince(firstProvIndex);
        itemProvinces.Rows[1].Cells[0].GetComponentInChildren <Text>().text = firstProvince.getProvName();
        //  itemProvinces.Rows[1].Cells[1].GetComponentInChildren<Image>().sprite =
        Transform P1Res      = itemProvinces.Rows[1].Cells[1].transform.GetChild(0);
        Image     P1ResImage = P1Res.GetComponent <Image>();

        // Image provOneRes = itemProvinces.Rows[1].Cells[1].GetComponentInChildren<Image>() as Image;
        //resImg.sprite = Resources.Load("Resource/" + imp.getResourceType().ToString(), typeof(Sprite)) as Sprite;
        //  Debug.Log("First Resource is: " + firstProvince.getResource());
        P1ResImage.sprite = Resources.Load("Resource/" + firstProvince.getResource().ToString(), typeof(Sprite)) as Sprite;
        itemProvinces.Rows[1].Cells[2].GetComponentInChildren <Text>().text = firstProvince.getDevelopmentLevel().ToString();
        Toggle provOneRail = itemProvinces.Rows[1].Cells[3].GetComponentInChildren <Toggle>();

        if (firstProvince.getRail())
        {
            provOneRail.isOn = true;
        }
        else
        {
            provOneRail.isOn = false;
        }

        assemblyCsharp.Province secondProvince = State.getProvince(secondProvIndex);
        itemProvinces.Rows[2].Cells[0].GetComponentInChildren <Text>().text = secondProvince.getProvName();
        //  itemProvinces.Rows[1].Cells[1].GetComponentInChildren<Image>().sprite =
        // Image provTwoRes = itemProvinces.Rows[2].Cells[1].GetComponentInChildren<Image>() as Image;
        // Debug.Log("Second Resource is: " + secondProvince.getResource());
        Transform P2Res      = itemProvinces.Rows[2].Cells[1].transform.GetChild(0);
        Image     P2ResImage = P2Res.GetComponent <Image>();

        P2ResImage.sprite = Resources.Load("Resource/" + secondProvince.getResource().ToString(), typeof(Sprite)) as Sprite;
        itemProvinces.Rows[2].Cells[2].GetComponentInChildren <Text>().text = secondProvince.getDevelopmentLevel().ToString();
        Toggle provTwoRail = itemProvinces.Rows[2].Cells[3].GetComponentInChildren <Toggle>();

        if (secondProvince.getRail())
        {
            provTwoRail.isOn = true;
        }
        else
        {
            provTwoRail.isOn = false;
        }
        if (item.IsColonyOf() != -1)
        {
            Nation currentOwner = State.getNations()[item.IsColonyOf()];
            currentOwnerName.text         = currentOwner.getNationName();
            relationWithCurrentOwner.text = player.Relations[currentOwner.getIndex()].ToString();
        }
        else
        {
            currentOwnerName.text = "None";
        }

        if (player.RecognizingTheseClaims.Contains(item.getIndex()))
        {
            isRecognizing.isOn = true;
        }
        else
        {
            isRecognizing.isOn = false;
        }
    }