コード例 #1
0
ファイル: skills.cs プロジェクト: lizhongwow/SceneTest
        public static void _update_pl_bstate(long cur_tm_s, IBaseUnit ply)
        {
            IMapUnit pl = ply.get_pack_data();
            if (pl.bstates == null || pl.bstates.Count <= 0)
                return;

            var bstates = pl.bstates;
            for (var idx = 0; idx < bstates.Count; ++idx)
            {
                var bstate = bstates[idx];

                if (bstate.end_tm < cur_tm_s)
                {
                    // 到时间,结束状态
                    bstates.RemoveAt(idx);
                    --idx;

                    // send bstate_change msg
                    //::send_rpc(ply.pinfo.sid, 19, { rmvid = bstate.id});

                    continue;
                }

                if (bstate.ticktm > 0 && bstate.ticktm < cur_tm_s)
                {
                    // 达到定时触发时间

                    bstate.ticktm = cur_tm_s + bstate.conf.eff.ticktm; // 更新下次触发时间

                    var par_change = 0;

                    if (bstate.conf.eff.tp == (int)bstate_eff_type.BET_ADD_HP)
                    {
                        // 增加生命状态

                        var hp_add = pl.max_hp - pl.hp;
                        if (hp_add <= 0)
                        {
                            continue;
                        }

                        if (hp_add > bstate.conf.eff.add)
                        {
                            hp_add = bstate.conf.eff.add;
                        }

                        if (hp_add > bstate.par)
                        {
                            hp_add = bstate.par;
                        }

                        ply.modify_hp(hp_add);

                        bstate.par -= hp_add; // 扣除存储值
                    }
                    else if (bstate.conf.eff.tp == (int)bstate_eff_type.BET_ADD_MP)
                    {
                        // 增加法力状态

                        var mp_add = pl.max_mp - pl.mp;
                        if (mp_add <= 0)
                        {
                            continue;
                        }

                        if (mp_add > bstate.conf.eff.add)
                        {
                            mp_add = bstate.conf.eff.add;
                        }

                        if (mp_add > bstate.par)
                        {
                            mp_add = bstate.par;
                        }

                        ply.modify_mp(mp_add);

                        bstate.par -= mp_add; // 扣除存储值
                    }
                    else
                    {
                        // err,错误的状态,需要删除
                        bstate.par = 0;
                    }

                    //var ret_msg = null;
                    if (bstate.par > 0)
                    {
                        //ret_msg = { mod ={ id = bstate.id, par = bstate.par} };
                    }
                    else
                    {
                        // 消耗完了存储值,删除状态
                        //ret_msg = { rmvid = bstate.id};

                        bstates.RemoveAt(idx);
                        --idx;
                    }

                    // send bstate_change msg
                    //::send_rpc(ply.pinfo.sid, 19, ret_msg);
                }
            }

            //if (ply.pinfo.bstates.len() <= 0)
            //{
            //    delete ply.pinfo.bstates;
            //}
        }