Example #1
0
    /// <summary>
    /// NPC答应玩家邀请
    /// </summary>
    /// <param name="people"></param>
    public void NPCApplyPlayerInvite(People people, ActionSetting actionSetting)
    {
        bool doubleAsked = false;

        for (int i = 0; i < people.meInviteOtherList.Count; i++)
        {
            //如果npc也邀请了玩家,则顺从玩家
            if (people.meInviteOtherList[i].people.protoData.OnlyId == RoleManager.Instance.playerPeople.protoData.OnlyId)
            {
                doubleAsked = true;
                break;
            }
            //这里应该直接进入了
            //GameModuleManager.Instance.curGameModule = GameModuleType.SingleOutsideScene;
        }
        WetalkMsgData wetalkMsgData;// = new WetalkMsgData(WetalkMsgType.Nonsense, "嗯,那听你的吧。", people, RoleManager.Instance.playerPeople, 0);

        if (doubleAsked)
        {
            wetalkMsgData = new WetalkMsgData(WetalkMsgType.Nonsense, "嗯,那听你的吧。", people, RoleManager.Instance.playerPeople, 0);
        }
        else
        {
            wetalkMsgData = new WetalkMsgData(WetalkMsgType.Nonsense, "虽然对" + actionSetting.name + "不太感冒,不过和你一起去倒还不错。", people, RoleManager.Instance.playerPeople, 0);
        }
        SendMsgToPlayer(people, RoleManager.Instance.playerPeople, wetalkMsgData);
        RoleManager.Instance.playerPeople.protoData.ValidWithPeople.Add(people.protoData.OnlyId);
        //该NPC把鱼拒绝掉(这个不一定 看后续需不需要这样做TODO
        RefusePeopleWhoInviteMe(people, RoleManager.Instance.playerPeople, RoleManager.Instance.playerPeople.actionName);
        ForgivePeopleWhoIInvite(people, RoleManager.Instance.playerPeople, RoleManager.Instance.playerPeople.actionName);
        //刷新面板显示
        EventCenter.Broadcast(TheEventType.NPCAppliedInvite);
    }
Example #2
0
 void ClearChatGrid()
 {
     startWaitChatInput = false;
     waitToShowChatMsg  = null;
     allChatItemViewList.Clear();
     PanelManager.Instance.CloseAllSingle(trans_chatGrid);
 }
Example #3
0
    public void InviteCalc()
    {
        //定计划
        for (int i = 0; i < RoleManager.Instance.NPCPeopleList.Count; i++)
        {
            People        me      = RoleManager.Instance.NPCPeopleList[i];
            List <People> tmpList = new List <People>();

            //tmpList.Clear();
            List <ActionSetting> actionSettingList = DataTable._actionList;
            int           actionIndex   = RandomManager.Next(0, actionSettingList.Count);
            ActionSetting actionSetting = actionSettingList[actionIndex];
            me.actionName         = actionSetting.name;
            me.protoData.ActionId = actionSetting.id.ToInt32();
            //邀请0-5人(不能重复邀请
            if (me.protoData.WetalkFriends.Count > 0 && actionSetting.socializationType.ToInt32() != (int)ActionSocializationProperty.MustAlone)
            {
                //暂时一定邀请 这里改成1
                int num = RandomManager.Next(0, me.protoData.WetalkFriends.Count + 1);
                if (num > 0)
                {
                    for (int j = 0; j < num; j++)
                    {
                        People choosed = null;
                        while (choosed == null ||
                               choosed == me ||
                               tmpList.Contains(choosed))
                        {
                            int index = RandomManager.Next(0, me.protoData.WetalkFriends.Count);
                            choosed = RoleManager.Instance.FindPeopleWithOnlyId(me.protoData.WetalkFriends[index]);
                        }
                        tmpList.Add(choosed);
                        if (choosed.isPlayer)
                        {
                            WetalkMsgData wetalkMsgData = new WetalkMsgData(WetalkMsgType.InviteAction,
                                                                            "一起" + actionSetting.name + "吗?", me, choosed, me.protoData.ActionId);
                            SendMsgToPlayer(me, choosed, wetalkMsgData);
                            //SendMsgToPlayer(me, choosed, actionSetting);TODO
                        }
                        me.Invite(choosed);
                        me.Record("邀请" + choosed.protoData.Name + me.actionName);
                        choosed.Record("被" + me.protoData.Name + "邀请" + me.actionName);
                    }
                }
                else
                {
                    me.Record("想今天一个人" + me.actionName);
                }
            }

            else
            {
                //planList.Add(new Plan(me.actionName, me, null));
                me.Record("想今天一个人" + me.actionName);
            }
        }

        //这里如果玩家有被邀请,则发一封信给玩家
    }
Example #4
0
    /// <summary>
    /// NPC拒绝玩家
    /// </summary>
    public void NPCRefusePlayerInvite(People people)
    {
        WetalkMsgData wetalkMsgData = new WetalkMsgData(WetalkMsgType.Nonsense, "不是很想去……", people, RoleManager.Instance.playerPeople, 0);

        SendMsgToPlayer(people, RoleManager.Instance.playerPeople, wetalkMsgData);

        people.Refuse(RoleManager.Instance.playerPeople);
    }
 /// <summary>
 /// 加微信 2+1的微信
 /// </summary>
 /// <param name="p1"></param>
 /// <param name="p2"></param>
 public void AddedWetalk(People p1, People p2)
 {
     p1.protoData.WetalkFriends.Add(p2.protoData.OnlyId);
     p2.protoData.WetalkFriends.Add(p1.protoData.OnlyId);
     //有人和玩家加了微信 发信息到手机ui上
     if (p1.isPlayer)
     {
         WetalkMsgData wetalkMsgData = new WetalkMsgData(WetalkMsgType.Nonsense, "我们已经是好友了,以后请多多指教", p2, p1, 0);
         SocializationManager.Instance.SendMsgToPlayer(p2, p1, wetalkMsgData);
     }
 }
Example #6
0
    /// <summary>
    /// 玩家答应邀请
    /// </summary>
    /// <param name="people"></param>
    public void ApplyInvite(People people)
    {
        RoleManager.Instance.playerPeople.protoData.ValidWithPeople.Add(people.protoData.OnlyId);
        //发消息
        WetalkMsgData wetalkMsgData = new WetalkMsgData(WetalkMsgType.Nonsense, "好呀。", RoleManager.Instance.playerPeople, people, 0);

        SendMsgToPlayer(RoleManager.Instance.playerPeople, people, wetalkMsgData);
        //对方回复
        WetalkMsgData wetalkMsgData2 = new WetalkMsgData(WetalkMsgType.Nonsense, "嗯!那不见不散。", people, RoleManager.Instance.playerPeople, 0);

        SendMsgToPlayer(people, RoleManager.Instance.playerPeople, wetalkMsgData2);
    }
Example #7
0
    /// <summary>
    /// 邀请npc
    /// </summary>
    public void InviteNPC(People people)
    {
        ActionSetting actionSetting = DataTable.FindActionSetting(RoleManager.Instance.playerPeople.protoData.ActionId);

        WetalkMsgData wetalkMsgData = new WetalkMsgData(WetalkMsgType.Nonsense, "一起" + actionSetting.name + "吗?", RoleManager.Instance.playerPeople, people, 0);

        SendMsgToPlayer(RoleManager.Instance.playerPeople, people, wetalkMsgData);
        //NPC把玩家和邀请自己的人和自己邀请的人一起比较,然后酌情拒绝玩家
        List <People> candidateList = new List <People>();//所有可能配对的人的列表

        //List<People> candidateInviteMeList = new List<People>();//邀请我的人的列表
        //List<People> candidateMeInviteOtherList = new List<People>();//我邀请的人的列表

        for (int m = 0; m < people.meInviteOtherList.Count; m++)
        {
            People theOther = people.meInviteOtherList[m].people;
            if (!candidateList.Contains(theOther))
            {
                candidateList.Add(theOther);
            }
        }
        for (int m = 0; m < people.otherInviteMeList.Count; m++)
        {
            People theOther = people.otherInviteMeList[m].people;
            if (!candidateList.Contains(theOther))
            {
                candidateList.Add(theOther);
            }
        }
        //我邀请玩家 玩家也邀请我 则直接答应 并迁就玩家
        if (candidateList.Contains(RoleManager.Instance.playerPeople))
        {
            //这里执行NPC答应玩家的行为
            NPCApplyPlayerInvite(people, actionSetting);
        }
        //没有互相邀请的情况 则随机拒绝或答应
        else
        {
            int val = RandomManager.Next(0, 101);
            //答应
            if (val < 30)
            {
                //这里执行NPC答应玩家的行为
                NPCApplyPlayerInvite(people, actionSetting);
            }
            //拒绝
            else
            {
                //这里执行NPC拒绝玩家的行为
                NPCRefusePlayerInvite(people);
            }
        }
    }
Example #8
0
 /// <summary>
 /// 玩家选择完计划以后NPC的反应
 /// </summary>
 public void NPCReactionAfterPeopleChoosePlan(People choosedWithPeople)
 {
     //其它NPC执行邀约完毕以后,要给玩家发个信息
     for (int i = 0; i < RoleManager.Instance.playerPeople.otherInviteMeList.Count; i++)
     {
         People people = RoleManager.Instance.playerPeople.otherInviteMeList[i].people;
         if (choosedWithPeople == null ||
             (people.protoData.OnlyId != choosedWithPeople.protoData.OnlyId &&
              !people.protoData.PlayerVocalRefusedMe))
         {
             string theStr = "";
             if (!people.protoData.PlayerVocalRefusedMe)
             {
                 if (people.protoData.CurPlanWithPeople != 0)
                 {
                     People otherWithPeople = RoleManager.Instance.FindPeopleWithOnlyId(people.protoData.CurPlanWithPeople);
                     theStr = "没收到你的回复,我就和" + otherWithPeople.protoData.Name + "一起" + DataTable.FindActionSetting(people.protoData.ChoosedActionId).name + "了";
                 }
                 else
                 {
                     theStr = "没收到你的回复,我就自己" + DataTable.FindActionSetting(people.protoData.ChoosedActionId).name + "了";
                 }
                 WetalkMsgData wetalkMsgData = new WetalkMsgData(WetalkMsgType.Nonsense, theStr, people, RoleManager.Instance.playerPeople, 0);
                 SocializationManager.Instance.SendMsgToPlayer(people, RoleManager.Instance.playerPeople, wetalkMsgData);
             }
         }
     }
     for (int i = 0; i < RoleManager.Instance.playerPeople.meInviteOtherList.Count; i++)
     {
         People people = RoleManager.Instance.playerPeople.meInviteOtherList[i].people;
         if (people.protoData.OnlyId != choosedWithPeople.protoData.OnlyId &&
             !people.protoData.PlayerVocalRefusedMe)
         {
             string theStr = "";
             if (!people.protoData.PlayerVocalRefusedMe)
             {
                 if (people.protoData.CurPlanWithPeople != 0)
                 {
                     People otherWithPeople = RoleManager.Instance.FindPeopleWithOnlyId(people.protoData.CurPlanWithPeople);
                     theStr = "没等到你,我就和" + otherWithPeople.protoData.Name + "一起" + DataTable.FindActionSetting(people.protoData.ChoosedActionId).name + "了";
                 }
                 else
                 {
                     theStr = "没等到你,我就自己" + DataTable.FindActionSetting(people.protoData.ChoosedActionId).name + "了";
                 }
                 WetalkMsgData wetalkMsgData = new WetalkMsgData(WetalkMsgType.Nonsense, theStr, people, RoleManager.Instance.playerPeople, 0);
                 SocializationManager.Instance.SendMsgToPlayer(people, RoleManager.Instance.playerPeople, wetalkMsgData);
             }
         }
     }
 }
Example #9
0
    /// <summary>
    /// 发消息
    /// </summary>
    void OnSendMessage(object[] param)
    {
        WetalkMsgData wetalkMsgData = param[0] as WetalkMsgData;


        //红点
        for (int i = 0; i < messageFriendViewList.Count; i++)
        {
            if (messageFriendViewList[i].singlePeopleChatData.Belong == wetalkMsgData.from.protoData.OnlyId)
            {
                messageFriendViewList[i].RedPointShow();
            }
        }

        RedPointShow();
        //重新赋值chatdata,并且上一条失效
        if (curSinglePeopleChatData.ChatDataList.Count > 1)
        {
            for (int i = 0; i < allChatItemViewList.Count; i++)
            {
                allChatItemViewList[i].oneChatData = curSinglePeopleChatData.ChatDataList[i];
                allChatItemViewList[i].ValidShow();
            }
            //allChatItemViewList[curSinglePeopleChatData.ChatDataList.Count - 2].ValidShow();
            //curSinglePeopleChatData.ChatDataList.Count
        }

        //如果是在聊天页面,且正在和他聊天 则已读 并且这里做一个延迟显示的动画(仅显示
        if (curShowType == CellPhoneShowType.Chat)
        {
            //如果是在聊天页面,且正在和他聊天 则已读 并且这里做一个延迟显示的动画(仅显示
            if (curSinglePeopleChatData.Belong == wetalkMsgData.from.protoData.OnlyId)
            {
                SocializationManager.Instance.CheckedChat(curSinglePeopleChatData);

                chatReactTimer     = 0;
                startWaitChatInput = true;
                waitToShowChatMsg  = wetalkMsgData;
                txt_chatLabel.SetText("对方正在输入中……");
            }
            //如果是玩家发的 则直接显示聊天内容
            if (curSinglePeopleChatData.Belong == wetalkMsgData.to.protoData.OnlyId &&
                wetalkMsgData.from.protoData.OnlyId == RoleManager.Instance.playerPeople.protoData.OnlyId)
            {
                AddAChat(wetalkMsgData);
            }
        }
    }
Example #10
0
    /// <summary>
    /// 添加一项聊天
    /// </summary>
    void AddAChat(WetalkMsgData wetalkMsgData)
    {
        People people = RoleManager.Instance.FindPeopleWithOnlyId(curSinglePeopleChatData.Belong);

        txt_chatLabel.SetText(people.protoData.Name);

        PanelManager.Instance.OpenSingle <SingleChatItemView>(trans_chatGrid, curSinglePeopleChatData.ChatDataList[curSinglePeopleChatData.ChatDataList.Count - 1]);

        //自动定位
        if (rectTrans_chatScroll.sizeDelta.y < trans_chatGrid.GetComponent <RectTransform>().sizeDelta.y)
        {
            float offset = trans_chatGrid.GetComponent <RectTransform>().sizeDelta.y - rectTrans_chatScroll.sizeDelta.y;
            trans_chatGrid.GetComponent <RectTransform>().anchoredPosition = new Vector2(trans_chatGrid.localPosition.x, offset);
        }
        OnCheckedRedPoint(curSinglePeopleChatData);
    }
Example #11
0
    /// <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);
    }