Beispiel #1
0
    internal static void Execute(object msg, NetConnection conn, NetworkSystem networkSystem)
    {
        Msg_RC_UpdateCoefficient _msg = msg as Msg_RC_UpdateCoefficient;

        if (null == _msg)
        {
            return;
        }
    }
        protected override bool ExecCommand(StoryInstance instance, long delta)
        {
            Scene scene = instance.Context as Scene;

            if (null != scene)
            {
                if (m_HaveParam)
                {
                    int      objId = m_ObjId.Value;
                    UserInfo user  = scene.UserManager.GetUserInfo(objId);
                    if (null != user)
                    {
                        Msg_RC_UpdateCoefficient msg = new Msg_RC_UpdateCoefficient();
                        msg.obj_id            = user.GetId();
                        msg.hpmax_coefficient = user.HpMaxCoefficient;
                        scene.NotifyAllUser(msg);

                        Msg_RC_SyncProperty propMsg = DataSyncUtility.BuildSyncPropertyMessage(user);
                        scene.NotifyAllUser(propMsg);

                        for (LinkedListNode <UserInfo> linkNode = scene.UserManager.Users.FirstValue; null != linkNode; linkNode = linkNode.Next)
                        {
                            UserInfo info     = linkNode.Value;
                            User     reporter = user.CustomData as User;
                            if (null != reporter && null != info && objId != info.GetId())
                            {
                                Msg_RC_UpdateCoefficient factorMsg = new Msg_RC_UpdateCoefficient();
                                factorMsg.obj_id            = info.GetId();
                                factorMsg.hpmax_coefficient = info.HpMaxCoefficient;
                                reporter.SendMessage(factorMsg);

                                Msg_RC_SyncProperty otherPropMsg = DataSyncUtility.BuildSyncPropertyMessage(info);
                                reporter.SendMessage(otherPropMsg);
                            }
                        }
                    }
                }
                else
                {
                    Room     room = scene.GetRoom();
                    UserInfo one = null, two = null;
                    LinkedListNode <UserInfo> node = scene.UserManager.Users.FirstValue;
                    if (null != node)
                    {
                        one  = node.Value;
                        node = node.Next;
                        if (null != node)
                        {
                            two = node.Value;
                        }
                    }
                    if (null != one && null != two)
                    {
                        float  lvl1 = one.GetLevel();
                        float  lvl2 = two.GetLevel();
                        float  lvl  = (lvl1 + lvl2) / 2;
                        double c    = 6;// 4.09 * 1.2 * 1.3 * (1 + lvl * 0.04) * (1 + (0.15 * (1.62 - 1) / 50 * lvl) + (1.05 + 0.55 / 50 * lvl - 1) * 0.5 + (1.05 + 0.55 / 50 * lvl - 1) * 0.5);
                        one.HpMaxCoefficient     = (float)c;
                        two.HpMaxCoefficient     = (float)c;
                        one.EnergyMaxCoefficient = (float)c;
                        two.EnergyMaxCoefficient = (float)c;
                        UserAttrCalculator.Calc(one);
                        UserAttrCalculator.Calc(two);
                        one.SetHp(Operate_Type.OT_Absolute, one.GetActualProperty().HpMax);
                        one.SetEnergy(Operate_Type.OT_Absolute, one.GetActualProperty().EnergyMax);
                        two.SetHp(Operate_Type.OT_Absolute, two.GetActualProperty().HpMax);
                        two.SetEnergy(Operate_Type.OT_Absolute, two.GetActualProperty().EnergyMax);

                        Msg_RC_UpdateCoefficient msg1 = new Msg_RC_UpdateCoefficient();
                        msg1.obj_id            = one.GetId();
                        msg1.hpmax_coefficient = one.HpMaxCoefficient;
                        scene.NotifyAllUser(msg1);

                        Msg_RC_UpdateCoefficient msg2 = new Msg_RC_UpdateCoefficient();
                        msg2.obj_id            = two.GetId();
                        msg2.hpmax_coefficient = two.HpMaxCoefficient;
                        scene.NotifyAllUser(msg2);

                        Msg_RC_SyncProperty propMsg1 = DataSyncUtility.BuildSyncPropertyMessage(one);
                        scene.NotifyAllUser(propMsg1);

                        Msg_RC_SyncProperty propMsg2 = DataSyncUtility.BuildSyncPropertyMessage(two);
                        scene.NotifyAllUser(propMsg2);
                    }
                }
            }
            return(false);
        }