コード例 #1
0
        /// <summary>
        /// 单位进入
        /// </summary>
        private void OnUnitEnter(PacketBase packet)
        {
            ss2c.UnitEnterAOI msg = packet as ss2c.UnitEnterAOI;
            Log.Debug("OnUnitEnter:" + msg.unit_idx.obj_idx);

            Unit unit = null;

            switch (msg.unit_idx.type)
            {
            case eUnitType.PLAYER: unit = new Player(); break;
            }
            if (unit == null)
            {
                Log.Warning("未定义类型:" + msg.unit_idx.type);
                return;
            }
            unit.obj_idx = msg.unit_idx.obj_idx;
            unit.Setup();
            unit.LoadData(msg.unit_info);
            UnitManager.Instance.AddUnit(unit);
        }
コード例 #2
0
        private void SendAOIEnter(long char_idx, long enter_unit_idx, int row, int col)
        {
            Player player = UnitManager.Instance.GetUnitByIdx(char_idx) as Player;

            if (player == null)
            {
                return;
            }
            Unit enter_unit = UnitManager.Instance.GetUnitByIdx(enter_unit_idx);

            if (enter_unit == null)
            {
                return;
            }

            //广播aoi消息
            ss2c.UnitEnterAOI rep_msg = PacketPools.Get(ss2c.msg.ENTER_AOI) as ss2c.UnitEnterAOI;
            rep_msg.unit_idx.Set(enter_unit.unit_type, 0, enter_unit.obj_idx);
            rep_msg.pos       = new Position2D(col, row);
            rep_msg.dir       = eDirection.TOP;
            rep_msg.flags     = 0;
            rep_msg.unit_info = enter_unit.GetUnitAOIInfo();
            ServerNetManager.Instance.SendProxy(player.client_uid, rep_msg, false);
        }