コード例 #1
0
    public static void craftChemical(chemical chem, int i)
    {
        chem.crafted = true;
        showFeedback(chem.chemSprite);
        AudioManager.singleton.audioSource.PlayOneShot(AudioManager.singleton.correct, 0.7F);

        //update tv
        FireworksTVControl.updateTV(i);

        // clear combined
        combined = new List <elements>();

        // check if this was enough to make red and purple
        if (!GameStateManager.singleton.purpleCrafted &&
            GameStateManager.singleton.chemicals[2].crafted &&
            GameStateManager.singleton.chemicals[3].crafted)
        {
            // craft purple
            GameStateManager.singleton.purpleCrafted = true;
            var purple = ElementCombine.showFeedback(GameStateManager.singleton.purpleSprite, 8);
            purple.GetComponent <Billboard>().enabled = false;
            purple.transform.LookAt(purple.transform.position + Vector3.forward);

            //update tv
            FireworksTVControl.updateTV(5);

            // explanation
            PlayerTextUI.singleton.helpMessages.Add("Purple is created with a combination of red and blue light!");
            PlayerTextUI.singleton.helpMessages.Add("By mixing your strontium and copper componds you can have purple as well.");
            PlayerTextUI.singleton.startPush();
        }

        // defer to our next frame to check for all chemicals crafted
        GameStateManager.singleton.StartCoroutine(GameStateManager.singleton.checkForAllChemicals());
    }
    void Start()
    {
        texture = new Texture2D(200, 200);
        grid    = new chemical[P5JSExtension.width][];
        next    = new chemical[P5JSExtension.width][];
        for (int x = 0; x < P5JSExtension.width; x++)
        {
            grid[x] = new chemical[P5JSExtension.height];
            next[x] = new chemical[P5JSExtension.height];
            for (var y = 0; y < P5JSExtension.height; y++)
            {
                chemical c;
                c.a        = 1; c.b = 0;
                grid[x][y] = c;

                c.a        = 1; c.b = 0;
                next[x][y] = c;
            }
        }

        for (int i = 100; i < 110; i++)
        {
            for (int j = 100; j < 110; j++)
            {
                grid[i][j].b = 1;
            }
        }
    }