Beispiel #1
0
    public void SetEditColor()
    {
        SingleBox[] boxes = FindObjectsOfType <SingleBox> ();
        foreach (SingleBox b in boxes)
        {
            b.InitColor();
        }
        // 设置编辑颜色的初始颜色
        MagicCubeOperate opetarer = FindObjectOfType <MagicCubeOperate> ();

        SingleBoxPiece[] pieces = FindObjectsOfType <SingleBoxPiece> ();
        foreach (SingleBoxPiece p in pieces)
        {
            if (Mathf.Abs(p.transform.position.x) < 1.25f &&
                Mathf.Abs(p.transform.position.y) < 1.25f &&
                Mathf.Abs(p.transform.position.z) < 1.25f)
            {
                p.GetComponent <MeshRenderer> ().material.color = new Color(0f, 0f, 0f, 0.5f);
                p.enabled = false;
            }
            else
            {
                SingleBox sb = p.GetComponentInParent <SingleBox> ();
                if (sb.myStyle.Equals(CubeStyle.Face))
                {
                    if (p.transform.position.x >= 1.25f)
                    {
                        opetarer.PickColor(MagicColor.Green);
                        sb.SetColor(p.gameObject);
                    }
                    else if (p.transform.position.x <= -1.25f)
                    {
                        opetarer.PickColor(MagicColor.Blue);
                        sb.SetColor(p.gameObject);
                    }
                    else if (p.transform.position.y >= 1.25f)
                    {
                        opetarer.PickColor(MagicColor.Yellow);
                        sb.SetColor(p.gameObject);
                    }
                    else if (p.transform.position.y <= -1.25f)
                    {
                        opetarer.PickColor(MagicColor.White);
                        sb.SetColor(p.gameObject);
                    }
                    else if (p.transform.position.z <= -1.25f)
                    {
                        opetarer.PickColor(MagicColor.Red);
                        sb.SetColor(p.gameObject);
                    }
                    else if (p.transform.position.z >= 1.25f)
                    {
                        opetarer.PickColor(MagicColor.Orange);
                        sb.SetColor(p.gameObject);
                    }
                }
            }
        }
    }
Beispiel #2
0
    void OnMouseDown()
    {
        if (!this.isActiveAndEnabled)
        {
            return;
        }
        switch (operater.mystate)
        {
        case State.Operate:
            if (operater.Stop)
            {
                //print ("Current face pos :" + this.transform.position);
                if (this.transform.position.x <= (-1.25f))
                {
                    operater.ManualOperate(OperatePiece.Left,
                                           this.transform.position, this.transform.parent.gameObject);
                }
                else if (this.transform.position.y >= (1.25f))
                {
                    operater.ManualOperate(OperatePiece.Top,
                                           this.transform.position, this.transform.parent.gameObject);
                }
                else if (this.transform.position.z <= (-1.25f))
                {
                    operater.ManualOperate(OperatePiece.Right,
                                           this.transform.position, this.transform.parent.gameObject);
                }
            }
            break;

        case State.EditColor:
            if (!box.myStyle.Equals(CubeStyle.Face))
            {
                box.SetColor(this.gameObject);
            }
            break;
        }
    }