/// <summary> /// /// </summary> /// <param name="birthWorldPosition">世界坐标</param> public void Init(Vector3 birthWorldPosition, BallAgent ballAgent, RefPointAgent refPointAgent) { GetComponent <Transform>().position = birthWorldPosition; Vector3 oriScale = new Vector3(0.2f, 0.2f, 1); GetComponent <Transform>().localScale = oriScale; _refBallAgent = ballAgent; _refPointAgent = refPointAgent; // 设置图片 string detailCoverStr = "data/" + ballAgent.ballData.detailCover; _detailCover.sprite = Resources.Load <Sprite>(detailCoverStr); }
/// <summary> /// 打开卡片 /// </summary> /// <param name="refPointAgent"></param> /// <param name="ballAgent"></param> public void OpenCard(RefPointAgent refPointAgent, BallAgent ballAgent) { //if (refPointAgent.refPointStatus == RefPointAgent.RefPointStatusEnum.busy) //{ // var oriBallAgent = refPointAgent.ballAgent; // // 关闭原有卡片 // if (oriBallAgent.refCardAgent == null) // { // // 关闭数据球 // oriBallAgent.DestoryIt(); // refPointAgent.Clear(); // } // else { // // 关闭数据球、关闭卡片 // oriBallAgent.refCardAgent.DirectClose(); // oriBallAgent.DestoryIt(); // refPointAgent.Clear(); // } //} // 打开卡片 // agent 移动到 refpoint 的位置 refPointAgent.ballAgent = ballAgent; refPointAgent.refPointStatus = RefPointAgent.RefPointStatusEnum.busy; var to = refPointAgent.GetComponent <Transform>().position; var tweenerMove = ballAgent.GetComponent <Transform>().DOMove(to, 0.5f).OnComplete(() => { // 缩小到一定比例 Vector3 toScale = new Vector3(0.2f, 0.2f, 1f); var tweenerSmall = ballAgent.GetComponent <Transform>().DOScale(toScale, 1f).OnComplete(() => { // 创建卡片走向幕前 ballAgent.ballStatus = BallStatusEnum.opened; ballAgent.gameObject.SetActive(false); CardAgent cardAgent; if (refPointAgent.needReversal) { cardAgent = Instantiate(_cardAgentRePrefab, _cardContainer); } else { cardAgent = Instantiate(_cardAgentPrefab, _cardContainer); } //cardAgent var genWorldPosition = ballAgent.GetComponent <Transform>().position; cardAgent.Init(genWorldPosition, ballAgent, refPointAgent); //if (cardAgent.refPointAgent.needReversal) //{ // cardAgent.GetComponent<RectTransform>().Rotate(new Vector3(180, 180, 0), Space.Self); // //.DORotate(new Vector3(180, 180, 0), Time.deltaTime); //} // 放大 Vector3 cardToScale = new Vector3(1.6f, 1.6f, 1.6f); cardAgent.OpenTweener = cardAgent.GetComponent <Transform>().DOScale(cardToScale, 1f); ballAgent.refCardAgent = cardAgent; _cardAgents.Add(cardAgent); }); ballAgent.SmallTweener = tweenerSmall; }); ballAgent.MoveTweener = tweenerMove; refPointAgent.Mark(); }
public void Clear() { _ballAgent = null; _refPointStatus = RefPointStatusEnum.vacant; ClearMark(); }