コード例 #1
0
    private void Start()
    {
        setupDecorationTabThings();

        homeFlowerSlots         = new List <GameObject>();
        otherCanvas             = GameObject.Find("UICanvas");
        fpc                     = GameObject.Find("FPSController").GetComponent <FlowerPlayerControler>();
        homeFlowerInventory     = HomeInventoryData.instance.homeFlowerInventory;
        homeDecorationInventory = HomeInventoryData.instance.homeDecorationInventory;
        homeDecorationsBought   = HomeInventoryData.instance.homeDecorationsBought;

        playerStuffContainer = GameObject.Find("playerInventoryContainer");
        topContainer         = GameObject.Find("topContainer");

        //Set up the player inventory
        FillPlayerInventoryPanel();

        //Figure out how many flowers to put on each page
        int gridWidth  = (int)Mathf.Floor(Screen.width / (slotSize * 2));
        int gridHeight = (int)Mathf.Floor(Screen.height / (slotSize * 2));

        //Subtract one because one slot is always needed as an empty one
        flowersPerPage = (gridHeight * gridWidth) - 1;

        GetComponent <Canvas>().worldCamera   = GameObject.Find("UICamera").GetComponent <Camera>();
        GetComponent <Canvas>().planeDistance = 19f;
        SetFlowersTab();
        setPageCountText();
        updateMoneyText();

        currentQuestID = otherCanvas.GetComponent <UIControllerScript>().currentQuestId;

        //Only de-activate the other canvas at the end of the start
        otherCanvas.SetActive(false);
    }
コード例 #2
0
    // Start is called before the first frame update
    void Start()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
            return;
        }
        mainCamera = Camera.main;
        player     = GameObject.Find("FPSController").GetComponent <FlowerPlayerControler>();
        foreach (MeshFilter filter in GetComponentsInChildren <MeshFilter>())
        {
            filter.mesh.bounds = new Bounds(Vector3.zero, new Vector3(10, 20, 10));
        }

        if (PlayerPrefs.HasKey("economy_0_0"))
        {
            loadEconomy();
        }
        else
        {
            for (int x = 0; x < 4; x++)
            {
                List <int> toPickFrom  = new List <int>();
                List <int> toPickFrom2 = new List <int>();
                for (int y = 0; y < 16; y++)//for every part of the flower the possible options are shuffleded
                {
                    toPickFrom.Add(y);
                    toPickFrom2.Add(y);
                }
                for (int y = 0; y < 16; y++)
                {
                    int rand  = Random.Range(0, toPickFrom.Count);//pick random start
                    int index = toPickFrom[rand];
                    toPickFrom.RemoveAt(rand);
                    float currentVal = (float)categories[index] + Random.Range(0f, (float)max[index] - categories[index]);
                    rand = Random.Range(0, toPickFrom2.Count);//pick random target
                    int index2 = toPickFrom2[rand];
                    toPickFrom2.RemoveAt(rand);
                    float targetVal = (float)categories[index2] + Random.Range(0f, (float)max[index2] - categories[index2]);
                    partsEconomy[x, y] = new FlowerPart(index, index2, currentVal, targetVal, Random.Range(lowerJumpRange[(int)jumpIndex.l], lowerJumpRange[(int)jumpIndex.u]), Random.Range(upperJumpRange[(int)jumpIndex.l], upperJumpRange[(int)jumpIndex.u]));
                }
            }
            float minValue = 20f;
            int[,] shuffleHelper = //I want to make sure there is at least one of each part on home planet that is worth more than minValue, having this makes the following code easier
            {
                { 1, 2, 4,  7 },   //these are the parts that are available on homeworld
                { 0, 4, 9, 11 },
                { 0, 2, 8, 15 },
                { 0, 1, 3,  6 }
            };
            for (int i = 0; i < 4; i++)
            {
                //if nothing is above minValue
                if (partsEconomy[i, shuffleHelper[i, 0]].currentValue < minValue && partsEconomy[i, shuffleHelper[i, 1]].currentValue < minValue && partsEconomy[i, shuffleHelper[i, 2]].currentValue < minValue && partsEconomy[i, shuffleHelper[i, 3]].currentValue < minValue)
                {
                    //find one that is and swap them
                    int toAdjust = shuffleHelper[i, Random.Range(0, 4)];
                    int newOne   = Random.Range(0, 16);
                    while (partsEconomy[i, newOne].currentValue < minValue)
                    {
                        newOne = Random.Range(0, 16);
                    }
                    FlowerPart temp = partsEconomy[i, newOne];
                    partsEconomy[i, newOne]   = partsEconomy[i, toAdjust];
                    partsEconomy[i, toAdjust] = temp;
                }
            }
        }
        totalFlowersSold = startingWorldCount;
        //sell balance test

        /*string toPrint = "";
         * for (int i = 0; i < 4; i++)
         * {
         *  toPrint += "{";
         *  for (int j = 0; j < 16; j++)
         *  {
         *      toPrint += partValue[i, j] + ", ";
         *  }
         *  toPrint = toPrint.Substring(0, toPrint.Length - 2);
         *  toPrint += "}\n";
         * }
         * print(toPrint);
         * for (int i = 0; i < 50; i++)
         * {
         *  uint returnIndex = 0;
         *  for (int j = 0; j < 8; j++)
         *  {
         *      returnIndex += (uint)Random.Range(0, 5);
         *      returnIndex *= 16;
         *  }
         *  processFlowerSell(returnIndex);
         * }
         * for (int i = 0; i < 80; i++)
         * {
         *  uint returnIndex = 0;
         *  for (int j = 0; j < 8; j++)
         *  {
         *      returnIndex += (uint)Random.Range(0,9);
         *      returnIndex *= 16;
         *  }
         *  processFlowerSell(returnIndex);
         * }
         * for (int i = 0; i < 110; i++)
         * {
         *  uint returnIndex = 0;
         *  for (int j = 0; j < 8; j++)
         *  {
         *      returnIndex += (uint)Random.Range(0, 13);
         *      returnIndex *= 16;
         *  }
         *  processFlowerSell(returnIndex);
         * }
         * for (int i = 0; i < 200; i++)
         * {
         *  uint returnIndex = 0;
         *  for (int j = 0; j < 8; j++)
         *  {
         *      returnIndex += (uint)Random.Range(0, 17);
         *      returnIndex *= 16;
         *  }
         *  processFlowerSell(returnIndex);
         * }
         * toPrint = "";
         * for (int i = 0; i < 4; i++)
         * {
         *  toPrint += "{";
         *  for (int j = 0; j < 16; j++)
         *  {
         *      toPrint += partValue[i, j] + ", ";
         *  }
         *  toPrint = toPrint.Substring(0, toPrint.Length - 2);
         *  toPrint += "}\n";
         * }
         * print(toPrint);*/
    }