Ejemplo n.º 1
0
 public void ExitFight(bool autoFull, int hp, int mp)
 {
     bool add = false;
     //自动加满
     if (autoFull)
     {
         this.HP = Math.Max(1, hp);
         this.MP = mp;
         Abrade();
         add = AutoFull();
     }
     SetActionState(ActionState.Standing);
     FightTime = DateTime.UtcNow;
     Fight = null;
     if (!add)
     {
         Variant v = new Variant(3);
         v["ShengMing"] = new MVPair(Life.ShengMing, HP);
         v["MoFa"] = new MVPair(Life.MoFa, MP);
         UpdataActorR(v);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 自动补满
 /// </summary>
 public bool AutoFull()
 {
     int total = AutoFullRHP();
     total += AutoFullRMP();
     if (total > 0)
     {
         m_assist.Save();
         Variant v = new Variant(6);
         v["ShengMing"] = new MVPair(m_life.ShengMing, this.HP);
         v["MoFa"] = new MVPair(m_life.MoFa, this.MP);
         v["JingYan"] = new MVPair(this.m_maxExp, this.m_exp);
         v["Level"] = m_level;
         v["Assist"] = m_assist;
         UpdataActorR(v);
         return true;
     }
     return false;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 产生BUFF前补满
        /// </summary>
        /// <param name="name"></param>
        private void FristAdd(string name)
        {
            int add = 0;
            //加满
            if (name == "RHP")
            {
                add = AutoFullRHP() + AutoFullRMP();
            }

            if (add > 0)
            {
                Variant v = new Variant(4);
                m_assist.Save();
                v["ShengMing"] = new MVPair(m_life.ShengMing, this.HP);
                v["MoFa"] = new MVPair(m_life.MoFa, this.MP);
                v["Assist"] = m_assist;
                UpdataActorR(v);
                return;
            }

            if (name == "PHP")
            {
                if (m_pet != null && m_pet.Value != null)
                {
                    add = AutoFullPHP(m_pet) + AutoFullPMP(m_pet);
                }
            }

            if (add > 0)
            {
                Variant v = new Variant(3);
                v["ShengMing"] = m_pet.Value.GetVariantOrDefault("ShengMing");
                v["MoFa"] = m_pet.Value.GetVariantOrDefault("MoFa");
                v["ID"] = m_pet.ID;
                this.Call(PetsCommand.UpdatePetR, true, v);
                this.Call(ClientCommand.UpdateActorR, new PlayerExDetail(m_assist));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 补充玩家的HP/MP
        /// </summary>
        /// <param name="v"></param>
        /// <returns></returns>
        public bool SupplyRole(Variant v)
        {
            double dhp = v.GetDoubleOrDefault("HP");
            double dmp = v.GetDoubleOrDefault("MP");
            int hp, mp;
            if (dhp <= 1)
            {
                hp = (int)(dhp * m_life.ShengMing); //百分比方式
            }
            else
            {
                hp = (int)(dhp);
            }
            if (dmp <= 1)
            {
                mp = (int)(dmp * m_life.MoFa); //百分比方式
            }
            else
            {
                mp = (int)(dmp);
            }

            bool use = false;
            if (hp > 0)
            {
                int need = m_life.ShengMing - this.HP;
                if (need > 0)
                {
                    this.HP += Math.Min(need, hp);
                    use = true;
                }
            }

            if (mp > 0)
            {
                int need = m_life.MoFa - this.MP;
                if (need > 0)
                {
                    this.MP += Math.Min(need, mp);
                    use = true;
                }
            }
            if (use)
            {
                Variant changed = new Variant(3);
                if (hp > 0) changed["ShengMing"] = new MVPair(m_life.ShengMing, this.HP);
                if (mp > 0) changed["MoFa"] = new MVPair(m_life.MoFa, this.MP);
                UpdataActorR(changed);
            }
            return use;
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="upLev"></param>
 private void UpdataActorR(PlayerProperty old)
 {
     Variant v = m_life.GetChange(old);
     v["ShengMing"] = new MVPair(m_life.ShengMing, this.HP);
     v["MoFa"] = new MVPair(m_life.MoFa, this.MP);
     v["JingYan"] = new MVPair(this.m_maxExp, this.m_exp);
     v["Level"] = m_level;
     UpdataActorR(v);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 更新玩家属性
 /// </summary>
 private void RefreshPlayer(string name, string value, Action<PlayerProperty> action)
 {
     PlayerProperty old = m_life;
     PlayerProperty p = new PlayerProperty();
     action(p);
     m_life = CreateProperty();
     if (this.HP > m_life.ShengMing)
     {
         this.HP = m_life.ShengMing;
     }
     if (this.MP > m_life.MoFa)
     {
         this.MP = m_life.MoFa;
     }
     Variant v = m_life.GetChange(old);
     if (!string.IsNullOrEmpty(name))
     {
         SceneBusiness scene = m_scene;
         if (scene != null)
         {
             Variant t = new Variant(2);
             t[name] = value;
             t["ID"] = this.ID;
             this.CallAll(ClientCommand.UpdateActorR, t);
         }
         else
         {
             v[name] = value;
         }
     }
     if (v.Count > 0)
     {
         if (v.ContainsKey("ShengMing"))
         {
             v["ShengMing"] = new MVPair(m_life.ShengMing, this.HP);
         }
         if (v.ContainsKey("MoFa"))
         {
             v["MoFa"] = new MVPair(m_life.MoFa, this.MP);
         }
         UpdataActorR(v);
     }
 }
Ejemplo n.º 7
0
        /// <summary>
        /// 失去经验
        /// </summary>
        /// <param name="b">百分比</param>
        public void LostExperience(double b, FinanceType eType, string remark = null)
        {
            if (b > 0 && b <= 1.0)
            {
                int experience = (int)(m_exp * b);
                if (experience > 0)
                {
                    m_exp -= experience;
                    Variant v = new Variant(2);
                    v["JingYan"] = new MVPair(this.m_maxExp, this.m_exp);
                    UpdataActorR(v);

                    PlayerAccess.Instance.Save(this);

                    PlayerLog log = new PlayerLog(ServerLogger.zoneid, Actiontype.RoleExp);
                    log.level = m_level;
                    log.modifyexp = -experience;
                    log.totalexp = m_exp;
                    log.reserve_1 = (int)eType;
                    log.remark = remark;
                    this.WriteLog(log);
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 添加玩家经验
        /// </summary>
        /// <param name="experience">经验值</param>
        /// <param name="eType"></param>
        /// <param name="des"></param>
        /// <returns></returns>
        public int AddExperience(int experience, FinanceType eType, string remark = null)
        {
            if (experience <= 0)
            {
                return 0;
            }
            int upLev = 0;
            int curExp = Interlocked.Add(ref m_exp, experience);
            if (curExp >= m_maxExp)
            {
                upLev = UpLevel();
                if (upLev > 0)
                {
                    UserNote note = new UserNote(this, TaskCommand.PlayerActivation, new object[] { upLev, this.Level });
                    Notifier.Instance.Publish(note);
                    //成就执行
                    this.FinishNote(FinishCommand.RoleUpLev, upLev);
                    //通知场景上的玩家
                    Variant v = new Variant(2);
                    v["ID"] = this.ID;
                    v["Level"] = this.m_level;
                    this.CallAll(ClientCommand.UpdateActorR, v);
                    //获取技能
                    NewSkill(upLev);
                }
            }
            else
            {
                Variant v = new Variant(2);
                v["JingYan"] = new MVPair(this.m_maxExp, this.m_exp);
                UpdataActorR(v);
            }
            PlayerAccess.Instance.Save(this);

            PlayerLog log = new PlayerLog(ServerLogger.zoneid, Actiontype.RoleExp);
            log.level = m_level;
            log.modifyexp = experience;
            log.totalexp = curExp;
            log.reserve_1 = (int)eType;
            log.remark = remark;
            this.WriteLog(log);
            return upLev;
        }
Ejemplo n.º 9
0
 /// <summary>
 /// 开始计算战斗
 /// </summary>
 /// <returns>是否结束</returns>
 private bool StartAttack()
 {
     StartBuffer();
     bool over = false;
     // 开始攻击..
     m_actions.Clear();
     for (int i = 0; i < m_fighter.Count; i++)
     {
         FightObject fighter = m_fighter[i];
         if (fighter.Action != null && fighter.IsLive && fighter.CanActive)
         {
             over = SingleAttack(fighter);
             if (over) break;
         }
     }
     var results = GetFightResults();
     foreach (var player in results)
     {
         if (player.Action.ActionType == ActionType.JiNeng && player is FightPlayer)
         {
             Variant v = new Variant(2);
             v["ID"] = player.ID;
             v["MoFa"] = new MVPair(player.Life.MoFa, player.MP);
             if (player is FightPet)
             {
                 SendToClinet(PetsCommand.UpdatePetR, true, v);
             }
             else
             {
                 SendToClinet(ClientCommand.UpdateActorR, v);
             }
         }
     }
     DecrementAutoFight();
     SendToClinet(FightCommand.FightTurnEndR, m_buffer, m_actions);
     //m_showOver = DateTime.UtcNow.AddMilliseconds(m_actions.Count * 500);
     m_actions.Clear();
     return over;
 }