/// <summary> /// 更新红点状态,根据子物体改变它的父物体 /// </summary> public void UpdateStatus(RedPoint redPoint) { if (redPoint == null) { return; } int sunCount = redPoint.sunList.Count; if (sunCount != 0) { bool val = false; for (int i = sunCount - 1; i >= 0; i--) { RedPoint sunPoint = redPoint.sunList[i]; if (sunPoint.nodeVal) { val = true; break; } } redPoint.nodeVal = val; } UpdateUI(redPoint); if (redPoint.Parent != null) { UpdateStatus(redPoint.Parent); } }
/// <summary> /// 从红点dic里面取到一个红点 /// </summary> /// <returns></returns> public RedPoint GetRedPointFromDic(RedPointType redPointType, UInt64 id) { if (!RedPointDic.ContainsKey(redPointType)) { return(AddRedPointToDic(redPointType, id)); } else { //字典该类有这个id bool haveSameId = false; List <RedPoint> redPointList = RedPointDic[redPointType]; for (int i = 0; i < redPointList.Count; i++) { RedPoint thePoint = redPointList[i]; UInt64 theId = thePoint.id; if (id == theId) { haveSameId = true; return(thePoint); } } //字典该类没有id if (!haveSameId) { return(AddRedPointToDic(redPointType, id)); } } return(null); }
/// <summary> /// 更新UI /// </summary> /// <param name="redPoint"></param> public void UpdateUI(RedPoint redPoint) { if (redPoint.PointObj != null) { redPoint.PointObj.SetActive(redPoint.nodeVal); } }
//操作按钮逻辑 private void UpdateOperation() { if (GameSystem.InLoading) { return; } if (Actions == null) { return; } //move if (Actions.Move.IsPressed) { Move(Actions.Move.Value.normalized); } else if (Actions.Move.WasReleased) { StopMove(); } //slow InSlow = Actions.Get(EControllerBtns.SlowMove).IsPressed; RedPoint.SetVisible(InSlow); //shoot InShoot = !DialogMgr.InDrawingDialog && Actions.Get(EControllerBtns.Shoot).IsPressed; }
private I2DGameObject GetPoint() { var newPoint = new RedPoint("point-red"); var point = GameObjects.FirstOrDefault(gameObject => gameObject.Tags.Contains("collider") && gameObject.Collide(newPoint)); return(point); }
public void SetChildren(RedPoint red) { if (children == null) { children = new List <RedPoint>(); } children.Add(red); }
/// <summary> /// 绑定两个红点 /// </summary> public void BindRedPoint(RedPoint parent, RedPoint sun) { if (!parent.sunList.Contains(sun)) { parent.sunList.Add(sun); } sun.Parent = parent; }
/// <summary> /// /// </summary> /// <param name="redPoint"></param> public void RemoveObserver(RedPoint redPoint) { var redPointValue = (int)redPoint; redPointEventDic.Remove(redPointValue); redPointStatusDic.Remove(redPointValue); }
/// <summary> /// /// </summary> /// <param name="redPoint"></param> /// <returns></returns> public bool GetRedPointStatus(RedPoint redPoint) { CheckRedPointContains((int)redPoint); var redPointValue = (int)redPoint; return(redPointStatusDic[redPointValue]); }
public int tmpPreferedActionId; //倾向的行为(临时变量,不需要保存,邀请时给手机面板调用) public override void Init() { base.Init(); RedPoint son = RedPointManager.Instance.GetRedPointFromDic(RedPointType.AllChatMsg, 0); RedPoint parent = RedPointManager.Instance.GetRedPointFromDic(RedPointType.CellPhone, 0); RedPointManager.Instance.BindRedPoint(parent, son); }
/// <summary> /// 添加注释 /// </summary> /// <param name="redPoint"></param> /// <param name="content"></param> public void AddRedPointComment(RedPoint redPoint, string content) { if (!configData.CommentDic.ContainsKey((int)redPoint)) { configData.CommentDic.Add((int)redPoint, content); } configData.CommentDic[(int)redPoint] = content; }
/// <summary> /// /// </summary> /// <param name="redPoint"></param> /// <returns></returns> public string GetRedPointComment(RedPoint redPoint) { if (!configData.CommentDic.ContainsKey((int)redPoint)) { return(string.Empty); } return(configData.CommentDic[(int)redPoint]); }
public static void Main(String[] args) { Point[] a = new RedPoint[10]; // Length 10, element type RedPoint Point p1 = new Point(42, 117); // Compile-time type Point, class Point RedPoint cp = new RedPoint(3, 4); // Compile-time type RedPoint, class RedPoint Point p2 = cp; // Compile-time type Point, class RedPoint a[0] = cp; // OK, RedPoint is subclass of RedPoint a[1] = p2; // OK, RedPoint is subclass of RedPoint a[2] = p1; // Runtime error: Point not subclass of RedPoint }
/// <summary> /// 已读 /// </summary> public void CheckedChat(SinglePeopleChatData singlePeopleChatData) { for (int i = 0; i < singlePeopleChatData.ChatDataList.Count; i++) { singlePeopleChatData.ChatDataList[i].Checked = true; } RedPoint son = RedPointManager.Instance.GetRedPointFromDic(RedPointType.SinglePeopleChatMsg, singlePeopleChatData.Belong); RedPointManager.Instance.ChangeRedPointStatus(RedPointType.SinglePeopleChatMsg, singlePeopleChatData.Belong, false); //发消息给手机ui显示 EventCenter.Broadcast(TheEventType.CheckedWetalkMessage, singlePeopleChatData); }
/// <summary> /// /// </summary> /// <param name="redPoint"></param> /// <param name="callback"></param> public void AddObserver(RedPoint redPoint, Action <bool> callback) { CheckRedPointContains((int)redPoint); var redPointValue = (int)redPoint; if (redPointEventDic.ContainsKey(redPointValue)) { return; } redPointEventDic.Add(redPointValue, callback); }
public void BindRedPoint(GameObject go, uint pointKey, float deltaX = 0, float deltaY = 0, float scale = 1) { RedPoint redPoint = go.GetComponent <RedPoint>(); if (redPoint == null) { redPoint = go.AddComponent <RedPoint>(); } redPoint.DeltaX = deltaX; redPoint.DeltaY = deltaY; redPoint.Scale = scale; redPoint.PointKey = pointKey; }
/// <summary> /// dic里面增加一种红点 /// </summary> public RedPoint AddRedPointToDic(RedPointType redPointType, UInt64 id) { RedPoint point = new RedPoint(); point.id = id; point.redPointType = redPointType; if (!RedPointDic.ContainsKey(redPointType)) { RedPointDic.Add(redPointType, new List <RedPoint>()); } RedPointDic[redPointType].Add(point); //AddRedPointToDic() return(point); }
/// <summary> /// 重置红点状态 /// </summary> /// <param name="redPoint"></param> public void SetActive(RedPoint redPoint, bool active) { var curPoint = (int)redPoint; CheckRedPointContains(curPoint); while (curPoint != 0) { var childs = GetChilds(curPoint); var findRedChild = false; // 有没有儿子有红点 if (childs != null) { for (var i = 0; i < childs.Count; i++) { var childRedPointValue = childs[i]; CheckRedPointContains(childRedPointValue); if (redPointStatusDic[childRedPointValue]) { findRedChild = true; break; } } } var lastActive = redPointStatusDic[curPoint]; if (findRedChild) { redPointStatusDic[curPoint] = true; } else { redPointStatusDic[curPoint] = active; } var refresh = lastActive != redPointStatusDic[curPoint]; if (refresh && redPointEventDic.ContainsKey(curPoint)) // 状态改变,刷新 { redPointEventDic[curPoint](redPointStatusDic[curPoint]); } curPoint = GetParent(curPoint); } }
/// <summary> /// 改变某个红点状态 /// </summary> public void ChangeRedPointStatus(RedPointType redPointType, UInt64 id, bool status) { if (RedPointDic.ContainsKey(redPointType)) { List <RedPoint> redPointList = RedPointDic[redPointType]; for (int i = 0; i < redPointList.Count; i++) { RedPoint thePoint = redPointList[i]; UInt64 theId = thePoint.id; if (id == theId) { thePoint.nodeVal = status; UpdateStatus(thePoint); } } } }
/// <summary> /// 设置ui的显示 /// </summary> /// <param name="obj"></param> /// <param name=""></param> public void SetRedPointUI(GameObject obj, RedPointType redPointType, UInt64 id) { if (RedPointDic.ContainsKey(redPointType)) { List <RedPoint> redPointList = RedPointDic[redPointType]; for (int i = 0; i < redPointList.Count; i++) { RedPoint thePoint = redPointList[i]; UInt64 theId = thePoint.id; if (id == theId) { obj.gameObject.SetActive(thePoint.nodeVal); } } } else { Debug.Log("字典没有注册该红点就永不显示" + redPointType); obj.gameObject.SetActive(false); } }
private void CreatePoint() { if (Cursor.Position.X > GameCore.DeviceManager.PreferredBackBufferWidth || Cursor.Position.Y > GameCore.DeviceManager.PreferredBackBufferHeight) { return; } var newPoint = new RedPoint("point-red"); if (Menu.Items.FirstOrDefault(item => newPoint.GetRectangle() .Collide(GameHelper.GetRectangle(item.Position, item.Texture))) != null) { return; } var point = GetPoint(); if (point == null) { GameObjects.Add(newPoint); } }
/// <summary> /// 删除注释 /// </summary> /// <param name="redPoint"></param> /// <param name="content"></param> public void RemoveRedPointComment(RedPoint redPoint) { configData.CommentDic.Remove((int)redPoint); }
void Awake() { RED_POINT_DELTA_X = GameConstHelper.GetInt("HANDBOOK_RED_POINT_DELTA_X"); RED_POINT_DELTA_Y = GameConstHelper.GetInt("HANDBOOK_RED_POINT_DELTA_Y"); HANDBOOK_MIN_STAR = GameConstHelper.GetInt("HANDBOOK_MIN_STAR"); if (handbookName == null) { handbookName = this.transform.Find("Name").GetComponent <Text>(); } if (handbookPicture == null) { handbookPicture = this.transform.Find("Picture").GetComponent <RawImage>(); } if (handbookBorder == null) { handbookBorder = this.transform.Find("bg").GetComponent <Image>(); } if (handbookInactiveMark == null) { handbookInactiveMark = this.transform.Find("NotText").gameObject; } if (firstFiveStars == null || firstFiveStars.Count <= 0) { firstFiveStars = new List <GameObject>(); var starParent1 = this.transform.Find("StarPanel"); for (int i = 0; i < starParent1.childCount; i++) { firstFiveStars.Add(starParent1.GetChild(i).gameObject); } } if (moreThanFiveStars == null) { moreThanFiveStars = this.transform.Find("StarPanel2/StarBg_1").gameObject; } if (moreThanFiveStarsCount == null) { moreThanFiveStarsCount = this.transform.Find("StarPanel2/Text").GetComponent <Text>(); } if (handbookFullMark == null) { handbookFullMark = this.transform.Find("Max").gameObject; } if (handbookToggle == null) { handbookToggle = this.transform.GetComponent <Toggle>(); } if (handbookToggle != null) { handbookToggle.onValueChanged.AddListener((isOn) => { if (isOn) { OnHandBookItemClick?.Invoke(handbookID); } }); } if (redPoint == null) { redPoint = this.gameObject.AddComponent <RedPoint>(); redPoint.DeltaX = RED_POINT_DELTA_X; redPoint.DeltaY = RED_POINT_DELTA_Y; } //两个特效策划让对换一下 if (activateEff == null) { var trans = this.transform.Find("EF_UI_tujian_shengxing"); if (trans != null) { activateEff = trans.gameObject; } } if (upgradeEff == null) { var trans = this.transform.Find("EF_UI_tujian_jihuo"); if (trans != null) { upgradeEff = trans.gameObject; } } Reset(); }
public void SetFather(RedPoint tr) { parent = tr; }
/// <summary> /// 发信给玩家 暂时只记录在玩家手机里面 /// </summary> public void SendMsgToPlayer(People from, People to, WetalkMsgData wetalkMsgData) { SinglePeopleChatData singlePeopleChatData = null; UInt64 theOnlyId = 0; if (from.protoData.IsPlayer) { theOnlyId = to.protoData.OnlyId; } else { theOnlyId = from.protoData.OnlyId; } //红点 for (int i = 0; i < RoleManager.Instance.playerPeople.protoData.AllSinglePeopleChatDataList.Count; i++) { if (RoleManager.Instance.playerPeople.protoData.AllSinglePeopleChatDataList[i].Belong == theOnlyId) { singlePeopleChatData = RoleManager.Instance.playerPeople.protoData.AllSinglePeopleChatDataList[i]; //置顶 var tmp = RoleManager.Instance.playerPeople.protoData.AllSinglePeopleChatDataList[0]; RoleManager.Instance.playerPeople.protoData.AllSinglePeopleChatDataList[0] = singlePeopleChatData; RoleManager.Instance.playerPeople.protoData.AllSinglePeopleChatDataList[i] = tmp; break; } } //如果没有聊过天,则插到第一位 if (singlePeopleChatData == null) { singlePeopleChatData = new SinglePeopleChatData(); singlePeopleChatData.Belong = theOnlyId; RoleManager.Instance.playerPeople.protoData.AllSinglePeopleChatDataList.Insert(0, singlePeopleChatData); } OneChatData oneChatData = new OneChatData(); oneChatData.ChatType = (int)wetalkMsgData.wetalkMsgType; oneChatData.Belong = from.protoData.OnlyId; oneChatData.Content = wetalkMsgData.content; oneChatData.InviteActionId = wetalkMsgData.inviteActionId; if (from.protoData.IsPlayer) { oneChatData.Checked = true; } oneChatData.IsPlayer = from.protoData.IsPlayer; oneChatData.Valid = true; singlePeopleChatData.ChatDataList.Add(oneChatData); //上一条聊天记录需要失效(回复按钮取消等) if (singlePeopleChatData.ChatDataList.Count > 1) { singlePeopleChatData.ChatDataList[singlePeopleChatData.ChatDataList.Count - 2].Valid = false; } //后续可能只保留20条的聊天记录 //其它人发给玩家的 则有红点 if (!from.protoData.IsPlayer) { RedPoint son = RedPointManager.Instance.GetRedPointFromDic(RedPointType.SinglePeopleChatMsg, from.protoData.OnlyId); RedPoint parent = RedPointManager.Instance.GetRedPointFromDic(RedPointType.AllChatMsg, 0); RedPointManager.Instance.BindRedPoint(parent, son); RedPointManager.Instance.ChangeRedPointStatus(RedPointType.SinglePeopleChatMsg, from.protoData.OnlyId, true); } //发消息给手机ui显示 EventCenter.Broadcast(TheEventType.SendWetalkMessage, wetalkMsgData); EventCenter.Broadcast(TheEventType.ShowMainPanelRedPoint); }