Exemplo n.º 1
0
        public static game_err_code check_target_type(IBaseUnit caster, IBaseUnit tar_sprite, int aff, map_pk_setting_type map_pk_seting)
        {
            IMapUnit pl = caster.get_pack_data();
            IMapUnit tar_pl = tar_sprite.get_pack_data();
            if (pl.iid != tar_pl.iid)
            {
                // 作用于其他角色          
                if ((aff & (int)skill_aff_type.SAT_ENERMY) != (int)skill_aff_type.SAT_ENERMY)
                {
                    if (caster.can_atk(tar_sprite))
                        return game_err_code.SKIL_INVALIDE_TAREGET;//敌人

                    // 根据aff判断盟友关系从而确定是否受此状态影响
                    var isaily = caster.isaily(tar_sprite);
                    if (isaily)
                    {
                        if ((aff & (int)skill_aff_type.SAT_ALLY) != (int)skill_aff_type.SAT_ALLY)
                            return game_err_code.SKIL_INVALIDE_TAREGET;
                        // 不对盟友产生影响                 
                    }
                    else
                    {//中立方
                        if ((aff & (int)skill_aff_type.SAT_MID) != (int)skill_aff_type.SAT_MID)
                            return game_err_code.SKIL_INVALIDE_TAREGET;
                    }
                }
                else if (caster.get_sprite_type() == map_sprite_type.MstPlayer)
                {// 根据地图、个人pk状态决定是否可以释放技能    
                    if (tar_sprite.get_sprite_type() == map_sprite_type.MstPlayer)
                    {
                        if (map_pk_seting == map_pk_setting_type.MPST_PEACE)
                            return game_err_code.CANT_PK_IN_PEACE_MAP;

                        if (pl.in_pczone || tar_pl.in_pczone)
                            return game_err_code.CANT_PK_IN_PEACE_ZONE;

                        if (map_pk_seting == map_pk_setting_type.MPST_NORMAL)
                        {
                            if (!tar_sprite.can_atk_direct())
                            {
                                //不可攻击的玩家
                                if (!caster.can_atk(tar_sprite))
                                    return game_err_code.CANT_ATK;
                            }
                        }
                        else
                        {
                            //pk地图
                            if (!caster.can_atk(tar_sprite))
                                return game_err_code.CANT_ATK;
                        }
                    }
                    else if (tar_sprite.get_sprite_type() == map_sprite_type.MstMonster)
                    {
                        if (tar_sprite.owner_ply != null)
                        {
                            //战宠     
                            var owner_sprite = tar_sprite.owner_ply;
                            var ower_pl = owner_sprite.get_pack_data();
                            if (ower_pl.iid == pl.iid)
                                return game_err_code.CANT_ATTACK_SELF_PET;

                            if (map_pk_seting == map_pk_setting_type.MPST_PEACE)
                                return game_err_code.CANT_PK_IN_PEACE_MAP;

                            if (pl.in_pczone || ower_pl.in_pczone)
                                return game_err_code.CANT_PK_IN_PEACE_ZONE;

                            if (map_pk_seting == map_pk_setting_type.MPST_NORMAL)
                            {
                                if (!owner_sprite.can_atk_direct())
                                {
                                    //不可攻击的玩家
                                    if (!caster.can_atk(owner_sprite))
                                        return game_err_code.CANT_ATK;
                                }
                            }
                            else
                            {
                                //pk地图
                                if (!caster.can_atk(owner_sprite))
                                    return game_err_code.CANT_ATK;
                            }
                        }
                        else
                        {
                            if (!caster.can_atk(tar_sprite))
                                return game_err_code.CANT_ATK;
                        }
                    }
                }
                else
                {
                    if (!caster.can_atk(tar_sprite))
                        return game_err_code.CANT_ATK;
                }
            }
            else
            {
                // 作用于自己
                if ((aff & (int)skill_aff_type.SAT_SELF) != (int)skill_aff_type.SAT_SELF)
                    return game_err_code.SKIL_INVALIDE_TAREGET; // 不对自己产生影响
            }

            return game_err_code.RES_OK;
        }
Exemplo n.º 2
0
 public void set_pk_seting(map_pk_setting_type pks)
 {
     this.pk_seting = pks;
 }
Exemplo n.º 3
0
 public void reset_pk_seting()
 {
     this.pk_seting = this.origin_pk_seting;
 }
Exemplo n.º 4
0
    public grid_map(int mapid)
    {
        map_conf = Utility.get_map_conf(mapid);

        this.grd = new Grd(map_conf);

        this.mapid = mapid;
        this.map_mons = new Dictionary<int, IBaseUnit>();
        this.map_mon_bymid = new Dictionary<int, List<IBaseUnit>>();
        this.map_sprites = new Dictionary<int, IBaseUnit>();
        this.map_players = new Dictionary<int, IBaseUnit>();
        this.map_players_bysid = new Dictionary<int, IBaseUnit>();
        this.map_players_bycid = new Dictionary<int, IBaseUnit>();
        this.pk_seting = this.get_map_pkseting();

        this.immrespawn = map_conf.immrespawn == 1;

        this.map_dpitms = new Dictionary<int, map_item>();

        this.last_check_tm = 0;
        this.map_skills = new Dictionary<int, SkillData>();

        var monster_count = this.get_monster_desc_count();
        this.petmon_cache = new Dictionary<int, List<IBaseUnit>>();

        //this.tmtriggers = { };
        //this.areatriggers = { };

        //this.useitmtriggers = { };
        //this.mistriggers = { };
        //this.othertriggers = { };
        this.callmon_added = new Dictionary<int, int>();

        //this.add_npcs = [];
        this.add_links = new List<link_conf>();
        //this.mapstats = [];
        this.paths = new Dictionary<int, List<Point2D>>();
        //this.team_drop_itm = {};

        //this.temp_sid_ary = int_ary.create_int_ary();





        var i = 0;
        for (; i < monster_count; ++i)
        {
            int mid = this.map_conf.map_mon[i].mid;
            var mon_conf = Utility.get_monster_conf(mid);
            if (null == mon_conf)
                throw new Exception("monsterconf not found for mid:" + mid);

            var m = new Monster(mon_conf);

            m.gmap = this;
            m.on_pos_change(m.mondata.x, m.mondata.y);
            IMapUnit mon = m.get_pack_data();

            this.map_mons[mon.iid] = m;
            this.map_sprites[mon.iid] = m;

            List<IBaseUnit> mons = null;
            if (this.map_mon_bymid.TryGetValue(mon.mid, out mons))
            {
                mons.Add(m);
            }
            else
            {
                mons = new List<IBaseUnit>();
                mons.Add(m);
                this.map_mon_bymid[mon.mid] = mons;
            }
        }
    }