/// <summary> /// 更新手牌,保持与CardManager的同步 /// </summary> public void UpdateHandcards() { // TODO: 完善此方法 _handcardList.RemoveChildren(0, -1, true); foreach (string cardId in handcardList) { GObject item = UIPackage.CreateObject(pkgName, "handcardItem2"); item.icon = UIPackage.GetItemURL(handcardAssets, cardId); item.SetPivot(0.5f, 1f); _handcardList.AddChild(item); string id = string.Copy(cardId); item.onRollOver.Add(() => { // 切换当前鼠标防治上的卡牌最最上 _handcardList.apexIndex = _handcardList.GetChildIndex(item); // 获取并展示数据 JsonData data = CardManager.Instance().GetCardJsonData(id); _title.text = data["name"].ToString(); _effect.text = data["effect"].ToString(); _value.text = "冷却:" + data["cd"] + " " + "专注值:" + data["cost"] + "\n" + data["type"]; _cardDescribeWindow.Show(); }); item.onRollOut.Add(() => { _cardDescribeWindow.Hide(); }); } }
void PlaySoftEffect() { GComponent turningObj1 = _objects[2]; GComponent turningObj2 = _objects[3]; PolygonMesh mesh1 = GetSoftMesh(turningObj1); PolygonMesh mesh2 = GetSoftMesh(turningObj2); /** * a * / \ * f(0,0)------/ b--g(w,0) * | / / | * | / / | * | c / | * | \ / | * | \ / | * e(0,h)-----d--------h(w,h) */ Vector2 pa, pb, pc, pd, pe, pf, pg, ph; float k, angle; bool threePoints = false; pc = _dragPoint; pe = new Vector2(0, _pageHeight); pf = Vector2.zero; pg = new Vector2(_pageWidth, 0); ph = new Vector2(_pageWidth, _pageHeight); FlipPoint(ref pc, _pageWidth * 2, _pageHeight); pc.x -= _pageWidth; if (pc.x >= _pageWidth) { return; } k = (ph.y - pc.y) / (ph.x - pc.x); float k2 = 1 + Mathf.Pow(k, 2); float min; min = ph.x - _pageWidth * 2 / k2; if (pc.x < min) { pc.x = min; if (pc.x >= _pageWidth) { return; } pc.y = ph.y - k * (ph.x - pc.x); } min = ph.x - (_pageWidth + _pageHeight * k) * 2 / k2; if (pc.x < min) { pc.x = min; if (pc.x >= _pageWidth) { return; } pc.y = ph.y - k * (ph.x - pc.x); } angle = Mathf.Atan(k) * Mathf.Rad2Deg; pd = new Vector2(_pageWidth - k2 * (ph.x - pc.x) / 2, _pageHeight); pb = new Vector2(pd.x + _pageHeight * k, 0); pa = new Vector2(); if (pb.x > _pageWidth) { pb.x = _pageWidth; pa = new Vector2(_pageWidth, _pageHeight - (_pageWidth - pd.x) / k); threePoints = true; } FlipPoint(ref pa, _pageWidth, _pageHeight); FlipPoint(ref pb, _pageWidth, _pageHeight); FlipPoint(ref pd, _pageWidth, _pageHeight); FlipPoint(ref pc, _pageWidth, _pageHeight); if (_draggingCorner == Corner.BL || _draggingCorner == Corner.TL) { angle = -angle; } switch (_draggingCorner) { case Corner.BR: { turningObj1.SetPivot(0, 0, true); turningObj1.position = new Vector2(_pageWidth, 0); turningObj2.SetPivot(0, 1, true); turningObj2.position = new Vector2(_pageWidth + pc.x, pc.y); turningObj2.rotation = 2 * angle; if (_softShadow != null) { _softShadow.SetPivot(1, (_softShadow.height - 30) / _softShadow.height, true); _softShadow.position = new Vector2(Vector2.Distance(pc, pd), _pageHeight); _softShadow.rotation = -angle; if (_softShadow.x > _pageWidth - 20) { _softShadow.alpha = (_pageWidth - _softShadow.x) / 20; } else { _softShadow.alpha = 1; } } mesh1.points.Clear(); mesh1.Add(pe); mesh1.Add(pf); mesh1.Add(pb); if (threePoints) { mesh1.Add(pa); } mesh1.Add(pd); mesh2.points.Clear(); mesh2.Add(new Vector2(Vector2.Distance(pc, pd), _pageHeight)); mesh2.Add(new Vector2(0, _pageHeight)); if (threePoints) { mesh2.Add(new Vector2(0, _pageHeight - Vector2.Distance(pc, pa))); } else { mesh2.Add(new Vector2(0, 0)); mesh2.Add(new Vector2(Vector2.Distance(pg, pb), 0)); } break; } case Corner.TR: { turningObj1.SetPivot(0, 0, true); turningObj1.position = new Vector2(_pageWidth, 0); turningObj2.SetPivot(0, 0, true); turningObj2.position = new Vector2(_pageWidth + pc.x, pc.y); turningObj2.rotation = -2 * angle; if (_softShadow != null) { _softShadow.SetPivot(1, 30 / _softShadow.height, true); _softShadow.position = new Vector2(Vector2.Distance(pc, pd), 0); _softShadow.rotation = angle; if (_softShadow.x > _pageWidth - 20) { _softShadow.alpha = (_pageWidth - _softShadow.x) / 20; } else { _softShadow.alpha = 1; } } mesh1.points.Clear(); mesh1.Add(pe); mesh1.Add(pf); mesh1.Add(pd); if (threePoints) { mesh1.Add(pa); } mesh1.Add(pb); mesh2.points.Clear(); if (threePoints) { mesh2.Add(new Vector2(0, Vector2.Distance(pc, pa))); } else { mesh2.Add(new Vector2(Vector2.Distance(pb, ph), _pageHeight)); mesh2.Add(new Vector2(0, _pageHeight)); } mesh2.Add(new Vector2(0, 0)); mesh2.Add(new Vector2(Vector2.Distance(pc, pd), 0)); break; } case Corner.BL: { turningObj1.SetPivot(0, 0, true); turningObj1.position = Vector2.zero; turningObj2.SetPivot(1, 1, true); turningObj2.position = pc; turningObj2.rotation = 2 * angle; if (_softShadow != null) { _softShadow.SetPivot(1, 30 / _softShadow.height, true); _softShadow.position = new Vector2(_pageWidth - Vector2.Distance(pc, pd), _pageHeight); _softShadow.rotation = 180 - angle; if (_softShadow.x < 20) { _softShadow.alpha = (_softShadow.x - 20) / 20; } else { _softShadow.alpha = 1; } } mesh1.points.Clear(); mesh1.Add(pb); mesh1.Add(pg); mesh1.Add(ph); mesh1.Add(pd); if (threePoints) { mesh1.Add(pa); } mesh2.points.Clear(); if (!threePoints) { mesh2.Add(new Vector2(_pageWidth - Vector2.Distance(pf, pb), 0)); mesh2.Add(new Vector2(_pageWidth, 0)); } else { mesh2.Add(new Vector2(_pageWidth, _pageHeight - Vector2.Distance(pc, pa))); } mesh2.Add(new Vector2(_pageWidth, _pageHeight)); mesh2.Add(new Vector2(_pageWidth - Vector2.Distance(pc, pd), _pageHeight)); break; } case Corner.TL: { turningObj1.SetPivot(0, 0, true); turningObj1.position = Vector2.zero; turningObj2.SetPivot(1, 0, true); turningObj2.position = pc; turningObj2.rotation = -2 * angle; if (_softShadow != null) { _softShadow.SetPivot(1, (_softShadow.height - 30) / _softShadow.height, true); _softShadow.position = new Vector2(_pageWidth - Vector2.Distance(pc, pd), 0); _softShadow.rotation = 180 + angle; if (_softShadow.x < 20) { _softShadow.alpha = (_softShadow.x - 20) / 20; } else { _softShadow.alpha = 1; } } mesh1.points.Clear(); mesh1.Add(pd); mesh1.Add(pg); mesh1.Add(ph); mesh1.Add(pb); if (threePoints) { mesh1.Add(pa); } mesh2.points.Clear(); mesh2.Add(new Vector2(_pageWidth - Vector2.Distance(pc, pd), 0)); mesh2.Add(new Vector2(_pageWidth, 0)); if (threePoints) { mesh2.Add(new Vector2(_pageWidth, Vector2.Distance(pc, pa))); } else { mesh2.Add(new Vector2(_pageWidth, _pageHeight)); mesh2.Add(new Vector2(_pageWidth - Vector2.Distance(pe, pb), _pageHeight)); } break; } } }