Esempio n. 1
0
    CMYK GetColorUnderScope()
    {
        Color      color;
        RaycastHit hit;
        GameObject hitted;

        if (Physics.Raycast(scope.transform.position, new Vector3(0, -1, 0), out hit))
        {
            hitted = hit.collider.gameObject;
        }
        else
        {
            return(cmyk);
        }

        if (hitted.layer == LayerMask.NameToLayer("Tile"))
        {
            color = hitted.GetComponent <MeshRenderer>().material.color;
            return(cmyk + CMYK.RGBToCMYK(color));
        }
        else
        {
            return(cmyk);
        }
    }
Esempio n. 2
0
    private void OnCollisionEnter(Collision collision)
    {
        if ((collision.gameObject.layer == LayerMask.NameToLayer("Tile") || collision.gameObject.layer == LayerMask.NameToLayer("StartTile")) && isFalling)
        {
            if (collision.gameObject.layer == LayerMask.NameToLayer("StartTile"))
            {
                isStarted = true;
            }

            isFalling = false;
            cmyk     += CMYK.RGBToCMYK(collision.gameObject.GetComponent <MeshRenderer>().material.color);
            GetComponent <MeshRenderer>().material.color = cmyk.CMYKToRGB();
            rigidbody.AddForce(collision.gameObject.transform.up * 600, ForceMode.Acceleration);
        }
        else if (collision.gameObject.layer == LayerMask.NameToLayer("DestTile"))
        {
            Debug.Log("finished");
            Time.timeScale = 0;
            if (CalculateScore(CMYK.RGBToCMYK(collision.gameObject.GetComponent <MeshRenderer>().material.color), cmyk))
            {
                gameManager.fsm.next = StateType.Clear;
            }
            else
            {
                gameManager.fsm.next = StateType.Result;
            }
        }

        if (scope != null)
        {
            RaycastHit hit;
            Physics.Raycast(transform.position, transform.up * (-1), out hit);
            scope.transform.position = hit.point + (transform.forward.normalized * 18.44998f) + new Vector3(0, 0.001f, 0);
        }
    }
Esempio n. 3
0
    public void Init(TileTypes[] area, Color[] _colors)
    {
        tilesTypes = area;
        colors     = _colors;

        for (int i = 0; i < 7; i++)
        {
            if (area[i] == TileTypes.empty)
            {
                Destroy(tiles[i]);
            }

            if (area[i] == TileTypes.starttile)
            {
                tiles[i].layer = LayerMask.NameToLayer("StartTile");
                tiles[i].GetComponent <MeshRenderer>().material.color = Color.white;
            }

            if (area[i] == TileTypes.normaltile)
            {
                tiles[i].layer = LayerMask.NameToLayer("Tile");
                colors[i].a    = 1.0f;
                tiles[i].GetComponent <MeshRenderer>().material.color = colors[i];
            }

            if (area[i] == TileTypes.desttile)
            {
                tiles[i].layer = LayerMask.NameToLayer("DestTile");
                colors[i].a    = 1.0f;
                tiles[i].GetComponent <MeshRenderer>().material.color = colors[i];
                tiles[i].transform.parent.Find("dest").GetComponent <SpriteRenderer>().color = Color.white;
                GameObject.Find("GameManager").GetComponent <GameManager>().dest             = CMYK.RGBToCMYK(colors[i]);
            }
        }
    }