Ejemplo n.º 1
0
    public int SetupStack(MahjongPile pile, int offset, int num)
    {
        MahjongTile        tile  = null;
        List <MahjongTile> stack = pile.GetRange(offset, num);

        _pile = pile;
        // 0 2 4 ...
        // 1 3 5 ...
        for (int i = 0; i < stack.Count; ++i)
        {
            tile = stack [i];

            tile.transform.parent = null;

            tile.Direction = MahjongTile.Face.PLANE_NEGTIVE;
            float angle = Vector3.Angle(Vector3.right, _direction);
            if (_direction == Vector3.forward)
            {
                angle = 270f;
            }
            //Debug.Log (_angle + "," + _direction + "," + _stackPosition);
            tile.transform.Rotate(Vector3.up, angle, Space.Self);
            tile.transform.parent = StackLocator;

            int row = i / 2;
            int col = i % 2;

            tile.transform.localPosition = row * _direction * MahjongTile.Width + col * Vector3.up * MahjongTile.Thickness;
        }

        return(num);
    }
Ejemplo n.º 2
0
        public override void OnInspectorGUI()
        {
            _pile = target as MahjongPile;
            EnumMahJongDirection direction = (EnumMahJongDirection)EditorGUILayout.EnumPopup("麻将方向", _pile.ItemDirection);
            EnumMahJongAction    action    = (EnumMahJongAction)EditorGUILayout.EnumPopup("麻将动作", _pile.ItemAction);
            EnumShowDirection    show      = (EnumShowDirection)EditorGUILayout.EnumPopup("麻将所属人", _pile.ItemShow);
            int       baseLayer            = EditorGUILayout.IntField("基础层级", _pile.BaseLayer);
            bool      isAddLayer           = EditorGUILayout.Toggle("层级是否递增", _pile.IsLayerAdd);
            float     scaleX = EditorGUILayout.FloatField("X轴缩放", _pile.ItemScaleX);
            float     scaleY = EditorGUILayout.FloatField("Y轴缩放", _pile.ItemScaleY);
            DefLayout layout = EditorGUILayout.ObjectField(new GUIContent("布局文件Layout"), _pile.Layout, typeof(DefLayout), true) as DefLayout;

            if (!direction.Equals(_pile.ItemDirection))
            {
                _pile.ItemDirection = direction;
            }
            if (!action.Equals(_pile.ItemAction))
            {
                _pile.ItemAction = action;
            }
            if (!show.Equals(_pile.ItemShow))
            {
                _pile.ItemShow = show;
            }
            if (!baseLayer.Equals(_pile.BaseLayer))
            {
                _pile.BaseLayer = baseLayer;
            }
            if (!isAddLayer.Equals(_pile.IsLayerAdd))
            {
                _pile.IsLayerAdd = isAddLayer;
            }
            if (!scaleX.Equals(_pile.ItemScaleX))
            {
                _pile.ItemScaleX = scaleX;
            }
            if (!scaleY.Equals(_pile.ItemScaleY))
            {
                _pile.ItemScaleY = scaleY;
            }
            if (layout != null)
            {
                if (!layout.Equals(_pile.Layout))
                {
                    _pile.Layout = layout;
                }
            }
            serializedObject.ApplyModifiedProperties();
        }
Ejemplo n.º 3
0
    public override bool Enter()
    {
        _shuffle_initpocket_state = -1;

        poolMahjongRes = PoolManager.Pools ["mahjongres"];

        _pile = gameObject.AddComponent <MahjongPile> ();

        _slot         = GameObject.Find("slot").transform;
        _slotOriginal = _slot.transform.position;

        var go = new GameObject("self");

        _self       = go.AddComponent <MahjongUserPlayer> ();
        _self.Proxy = GameClient.Instance.MahjongGamePlayer;
        go          = new GameObject("left");
        _left       = go.AddComponent <MahjongPlayer> ();
        go          = new GameObject("front");
        _front      = go.AddComponent <MahjongPlayer> ();
        go          = new GameObject("right");
        _right      = go.AddComponent <MahjongPlayer> ();

        //_self.ResPool = poolMahjongRes;
        //_left.ResPool = poolMahjongRes;
        //_front.ResPool = poolMahjongRes;
        //_right.ResPool = poolMahjongRes;

        _players = new List <MahjongPlayer> ();
        _players.Add(_self);
        _players.Add(_right);
        _players.Add(_front);
        _players.Add(_left);

        /*
         * if (GamePlayer._PlayedList != null) {
         *      GamePlayer._PlayedList.Clear ();
         * }
         */
        go = GameObject.Find("MyShowPocketLocator");
        go.GetComponent <MeshRenderer>().enabled = false;
        _self.MyShowPocketLocator = go.transform;
        go = GameObject.Find("MyPocketLocator");
        go.GetComponent <MeshRenderer>().enabled = false;

        string[][] locators = new string[4][] {
            new string[] { "mahjong", "MyPlayLocator", "MyStackLocator", "MyComboLocator", "MyWinLocator", "MyExchangeLocator" },
            new string[] { "RightPocketLocator", "RightPlayLocator", "RightStackLocator", "RightComboLocator", "RightWinLocator", "RightExchangeLocator" },
            new string[] { "FrontPocketLocator", "FrontPlayLocator", "FrontStackLocator", "FrontComboLocator", "FrontWinLocator", "FrontExchangeLocator" },
            new string[] { "LeftPocketLocator", "LeftPlayLocator", "LeftStackLocator", "LeftComboLocator", "LeftWinLocator", "LeftExchangeLocator" },
        };

        Vector3[] direction = new Vector3[] { Vector3.right, Vector3.forward, Vector3.left, -Vector3.forward };
        for (int i = 0; i < 4; ++i)
        {
            _players [i].InitLocator(locators [i]);
            _players [i].InitDirection(direction [i]);
        }

        ArrangePlayer(_self.Proxy.Index, 4);

        // set user pick up pai camera
        //go = GameObject.Find("OCamera169");
        //EasyTouch.AddCamera (go.GetComponent<Camera>());

        //registerOperationTable ();

        //OnRefresh ();

        return(true);
    }