public override void dispose() { base.dispose(); _scenePosLogic = null; _d = null; _pos = null; _dir = null; _specialMoveConfig = null; _groundState = UnitActGroundStateType.Ground; _isSpasticity = false; _isBlowHurt = false; _isBlowDown = true; _specialMoveConfig = null; _moveType = MapMoveType.Land; if (_drive != null) { _drive.dispose(); } _moveTargetPos.clear(); _sendLastTime = 0; _moveType = MapMoveType.Land; _walkSpeedRatio = 1f; }
public void Execute(Entity entity, int index, [ReadOnly] ref UnitSpawnData data, [ReadOnly] ref LocalToWorld location) { for (int x = 0; x < data.count_x; x++) { for (int y = 0; y < data.count_y; y++) { var instance = m_commandBuffer.Instantiate(data.prefab); //var position = math.transform(location.Value, new float3(x * 5, 0, y * 5)); var position = math.transform(location.Value, new float3(x * 2, (x + 1) % data.count_x, y * 2)); //something else... var rotatedata = new UnitRotateData { RotateSpeed = 5f, }; var movedata = new UnitMoveData { velocity = new float3(0, 1, 0), movespeed = 2, }; m_commandBuffer.SetComponent(instance, new Translation { Value = position }); //if want to add other compoments... //... m_commandBuffer.AddComponent(instance, rotatedata); m_commandBuffer.AddComponent(instance, movedata); } } m_commandBuffer.DestroyEntity(entity); }
public bool Deserialize(ref UnitMoveData packet) { bool ret = true; ret &= Deserialize(ref packet.unitId); ret &= Deserialize(ref packet.x); ret &= Deserialize(ref packet.y); return(ret); }
public bool Serialize(UnitMoveData packet) { bool ret = true; ret &= Serialize(packet.unitId); ret &= Serialize(packet.x); ret &= Serialize(packet.y); return(ret); }
public void OnReceiveUnitMovePacket(PacketId id, byte[] data) { UnitMovePacket packet = new UnitMovePacket(data); UnitMoveData moveData = packet.GetPacket(); int unit_id = moveData.unitId; float xPos = moveData.x; float yPos = moveData.y; Debug.Log("unit move packet received"); GameManager.GetInstance.getUnit(unit_id).ClientUnitMove(xPos, yPos); }
/// <summary> /// 回池 /// </summary> protected override void toRelease(DataPool pool) { this.instanceID = 0; this.identity = null; this.normal = null; this.pos = null; this.avatar = null; this.move = null; this.fight = null; this.fightEx = null; this.ai = null; this.func = null; }
public void unitMove(float _x, float _y) { x = _x; y = _y; if (GameManager.GetInstance.myTurn == true) { var m_network = GameObject.Find("Network").GetComponent <Network>(); UnitMoveData data = new UnitMoveData(); data.unitId = this.unitID; data.x = _x; data.y = _y; //네트워크 플롯 UnitMovePacket movePacket = new UnitMovePacket(data); if (m_network == null) { Debug.Log("can't find network tag"); } m_network.SendReliable(movePacket); Debug.Log("Unit move packet send"); } }
/// <summary> /// 复制(潜拷贝) /// </summary> protected override void toShadowCopy(BaseData data) { if (!(data is UnitData)) { return; } UnitData mData = (UnitData)data; this.instanceID = mData.instanceID; this.identity = mData.identity; this.normal = mData.normal; this.pos = mData.pos; this.avatar = mData.avatar; this.move = mData.move; this.fight = mData.fight; this.fightEx = mData.fightEx; this.ai = mData.ai; this.func = mData.func; }
/// <summary> /// 复制(潜拷贝) /// </summary> protected override void toShadowCopy(BaseData data) { if (!(data is UnitMoveData)) { return; } UnitMoveData mData = (UnitMoveData)data; this.baseMoveState = mData.baseMoveState; this.moveType = mData.moveType; this.baseMovePos = mData.baseMovePos; this.moveList = mData.moveList; this.specialMoveID = mData.specialMoveID; this.specialMoveArgs = mData.specialMoveArgs; this.specialMoveLastTime = mData.specialMoveLastTime; this.vehicleInstanceID = mData.vehicleInstanceID; this.driveData = mData.driveData; this.realMoveDir = mData.realMoveDir; this.realMoveSpeedRatio = mData.realMoveSpeedRatio; }
public override void init() { base.init(); _scenePosLogic = _scene.pos; _d = _data.move; _pos = _data.pos.pos; _dir = _data.pos.dir; //有战斗数据 if (_data.fight != null) { FightUnitConfig fightUnitConfig = _data.getFightIdentity().getFightUnitConfig(); _moveType = fightUnitConfig.mapMoveType; _walkSpeedRatio = fightUnitConfig.walkSpeedRatio; if (fightUnitConfig.needDrive) { if (_drive == null) { _drive = new DriveLogic(); } DriveLogic drive = _drive; drive.needDrive = true; drive.needDrive = fightUnitConfig.needDrive; drive.canDriveTurnAtPivot = fightUnitConfig.canDriveTurnAtPivot; drive.driveDirectionSpeed = fightUnitConfig.driveDirectionSpeedT; drive.driveTurnRadius = fightUnitConfig.driveTurnRadius; if (fightUnitConfig.driveAccelerateSpeed == 0) { drive.driveAccelerateSpeedM = 0f; drive.driveGroundFrictionM = 0f; } else { drive.driveAccelerateSpeedM = fightUnitConfig.driveAccelerateSpeed * Global.useMoveSpeedRatio / 1000000f; //先暂时取陆地的 drive.driveGroundFrictionM = MapBlockTypeConfig.get(MapBlockType.Land).groundFriction *Global.useMoveSpeedRatio / 1000000f; } } else { if (_drive != null) { _drive.needDrive = false; } } calculateUseMoveSpeed(); } else { if (_drive != null) { _drive.needDrive = false; } } }
/// <summary> /// 是否数据一致 /// </summary> protected override bool toDataEquals(BaseData data) { UnitMoveData mData = (UnitMoveData)data; if (this.baseMoveState != mData.baseMoveState) { return(false); } if (this.moveType != mData.moveType) { return(false); } if (mData.baseMovePos != null) { if (this.baseMovePos == null) { return(false); } if (!this.baseMovePos.dataEquals(mData.baseMovePos)) { return(false); } } else { if (this.baseMovePos != null) { return(false); } } if (mData.moveList != null) { if (this.moveList == null) { return(false); } if (this.moveList.size() != mData.moveList.size()) { return(false); } SList <PosData> moveListT = this.moveList; SList <PosData> moveListR = mData.moveList; int moveListLen = moveListT.size(); for (int moveListI = 0; moveListI < moveListLen; ++moveListI) { PosData moveListU = moveListT.get(moveListI); PosData moveListV = moveListR.get(moveListI); if (moveListV != null) { if (moveListU == null) { return(false); } if (!moveListU.dataEquals(moveListV)) { return(false); } } else { if (moveListU != null) { return(false); } } } } else { if (this.moveList != null) { return(false); } } if (this.specialMoveID != mData.specialMoveID) { return(false); } if (mData.specialMoveArgs != null) { if (this.specialMoveArgs == null) { return(false); } if (this.specialMoveArgs.Length != mData.specialMoveArgs.Length) { return(false); } int[] specialMoveArgsT = this.specialMoveArgs; int[] specialMoveArgsR = mData.specialMoveArgs; int specialMoveArgsLen = specialMoveArgsT.Length; for (int specialMoveArgsI = 0; specialMoveArgsI < specialMoveArgsLen; ++specialMoveArgsI) { int specialMoveArgsU = specialMoveArgsT[specialMoveArgsI]; int specialMoveArgsV = specialMoveArgsR[specialMoveArgsI]; if (specialMoveArgsU != specialMoveArgsV) { return(false); } } } else { if (this.specialMoveArgs != null) { return(false); } } if (this.specialMoveLastTime != mData.specialMoveLastTime) { return(false); } if (this.vehicleInstanceID != mData.vehicleInstanceID) { return(false); } if (mData.driveData != null) { if (this.driveData == null) { return(false); } if (!this.driveData.dataEquals(mData.driveData)) { return(false); } } else { if (this.driveData != null) { return(false); } } if (mData.realMoveDir != null) { if (this.realMoveDir == null) { return(false); } if (!this.realMoveDir.dataEquals(mData.realMoveDir)) { return(false); } } else { if (this.realMoveDir != null) { return(false); } } if (this.realMoveSpeedRatio != mData.realMoveSpeedRatio) { return(false); } return(true); }
/// <summary> /// 复制(深拷贝) /// </summary> protected override void toCopy(BaseData data) { if (!(data is UnitMoveData)) { return; } UnitMoveData mData = (UnitMoveData)data; this.baseMoveState = mData.baseMoveState; this.moveType = mData.moveType; if (mData.baseMovePos != null) { this.baseMovePos = (PosData)BytesControl.createData(PosData.dataID); this.baseMovePos.copy(mData.baseMovePos); } else { this.baseMovePos = null; } if (mData.moveList != null) { if (this.moveList != null) { this.moveList.clear(); this.moveList.ensureCapacity(mData.moveList.size()); } else { this.moveList = new SList <PosData>(); } SList <PosData> moveListT = this.moveList; if (!mData.moveList.isEmpty()) { PosData[] moveListVValues = mData.moveList.getValues(); for (int moveListVI = 0, moveListVLen = mData.moveList.length(); moveListVI < moveListVLen; ++moveListVI) { PosData moveListV = moveListVValues[moveListVI]; PosData moveListU; if (moveListV != null) { moveListU = (PosData)BytesControl.createData(PosData.dataID); moveListU.copy(moveListV); } else { moveListU = null; } moveListT.add(moveListU); } } } else { this.moveList = null; } this.specialMoveID = mData.specialMoveID; if (mData.specialMoveArgs != null) { int[] specialMoveArgsR = mData.specialMoveArgs; int specialMoveArgsLen = specialMoveArgsR.Length; if (this.specialMoveArgs == null || this.specialMoveArgs.Length != specialMoveArgsLen) { this.specialMoveArgs = new int[specialMoveArgsLen]; } BytesControl.arrayCopy(mData.specialMoveArgs, this.specialMoveArgs, specialMoveArgsLen); } else { this.specialMoveArgs = null; } this.specialMoveLastTime = mData.specialMoveLastTime; this.vehicleInstanceID = mData.vehicleInstanceID; if (mData.driveData != null) { this.driveData = (DriveData)mData.driveData.clone(); } else { this.driveData = null; } if (mData.realMoveDir != null) { this.realMoveDir = (DirData)BytesControl.createData(DirData.dataID); this.realMoveDir.copy(mData.realMoveDir); } else { this.realMoveDir = null; } this.realMoveSpeedRatio = mData.realMoveSpeedRatio; }
private HeroMovementController(IMovementInput movementInput, UnitMoveData moveData) : base(movementInput, moveData) { }
/// <summary> /// 读取字节流(简版) /// </summary> protected override void toReadBytesSimple(BytesReadStream stream) { this.instanceID = stream.readInt(); this.identity = (UnitIdentityData)stream.readDataSimpleNotNull(); this.normal = (UnitNormalData)stream.readDataSimpleNotNull(); if (stream.readBoolean()) { this.pos = (UnitPosData)stream.readDataSimpleNotNull(); } else { this.pos = null; } if (stream.readBoolean()) { this.avatar = (UnitAvatarData)stream.readDataSimpleNotNull(); } else { this.avatar = null; } if (stream.readBoolean()) { this.move = (UnitMoveData)stream.readDataSimpleNotNull(); } else { this.move = null; } if (stream.readBoolean()) { this.fight = (UnitFightData)stream.readDataSimpleNotNull(); } else { this.fight = null; } if (stream.readBoolean()) { this.fightEx = (UnitFightExData)stream.readDataSimpleNotNull(); } else { this.fightEx = null; } if (stream.readBoolean()) { this.ai = (UnitAIData)stream.readDataSimpleNotNull(); } else { this.ai = null; } if (stream.readBoolean()) { this.func = (UnitFuncData)stream.readDataSimpleNotNull(); } else { this.func = null; } }
/// <summary> /// 读取字节流(完整版) /// </summary> protected override void toReadBytesFull(BytesReadStream stream) { stream.startReadObj(); this.instanceID = stream.readInt(); BaseData identityT = stream.readDataFullNotNull(); if (identityT != null) { if (identityT is UnitIdentityData) { this.identity = (UnitIdentityData)identityT; } else { this.identity = new UnitIdentityData(); if (!(identityT.GetType().IsAssignableFrom(typeof(UnitIdentityData)))) { stream.throwTypeReadError(typeof(UnitIdentityData), identityT.GetType()); } this.identity.shadowCopy(identityT); } } else { this.identity = null; } BaseData normalT = stream.readDataFullNotNull(); if (normalT != null) { if (normalT is UnitNormalData) { this.normal = (UnitNormalData)normalT; } else { this.normal = new UnitNormalData(); if (!(normalT.GetType().IsAssignableFrom(typeof(UnitNormalData)))) { stream.throwTypeReadError(typeof(UnitNormalData), normalT.GetType()); } this.normal.shadowCopy(normalT); } } else { this.normal = null; } if (stream.readBoolean()) { BaseData posT = stream.readDataFullNotNull(); if (posT != null) { if (posT is UnitPosData) { this.pos = (UnitPosData)posT; } else { this.pos = new UnitPosData(); if (!(posT.GetType().IsAssignableFrom(typeof(UnitPosData)))) { stream.throwTypeReadError(typeof(UnitPosData), posT.GetType()); } this.pos.shadowCopy(posT); } } else { this.pos = null; } } else { this.pos = null; } if (stream.readBoolean()) { BaseData avatarT = stream.readDataFullNotNull(); if (avatarT != null) { if (avatarT is UnitAvatarData) { this.avatar = (UnitAvatarData)avatarT; } else { this.avatar = new UnitAvatarData(); if (!(avatarT.GetType().IsAssignableFrom(typeof(UnitAvatarData)))) { stream.throwTypeReadError(typeof(UnitAvatarData), avatarT.GetType()); } this.avatar.shadowCopy(avatarT); } } else { this.avatar = null; } } else { this.avatar = null; } if (stream.readBoolean()) { BaseData moveT = stream.readDataFullNotNull(); if (moveT != null) { if (moveT is UnitMoveData) { this.move = (UnitMoveData)moveT; } else { this.move = new UnitMoveData(); if (!(moveT.GetType().IsAssignableFrom(typeof(UnitMoveData)))) { stream.throwTypeReadError(typeof(UnitMoveData), moveT.GetType()); } this.move.shadowCopy(moveT); } } else { this.move = null; } } else { this.move = null; } if (stream.readBoolean()) { BaseData fightT = stream.readDataFullNotNull(); if (fightT != null) { if (fightT is UnitFightData) { this.fight = (UnitFightData)fightT; } else { this.fight = new UnitFightData(); if (!(fightT.GetType().IsAssignableFrom(typeof(UnitFightData)))) { stream.throwTypeReadError(typeof(UnitFightData), fightT.GetType()); } this.fight.shadowCopy(fightT); } } else { this.fight = null; } } else { this.fight = null; } if (stream.readBoolean()) { BaseData fightExT = stream.readDataFullNotNull(); if (fightExT != null) { if (fightExT is UnitFightExData) { this.fightEx = (UnitFightExData)fightExT; } else { this.fightEx = new UnitFightExData(); if (!(fightExT.GetType().IsAssignableFrom(typeof(UnitFightExData)))) { stream.throwTypeReadError(typeof(UnitFightExData), fightExT.GetType()); } this.fightEx.shadowCopy(fightExT); } } else { this.fightEx = null; } } else { this.fightEx = null; } if (stream.readBoolean()) { BaseData aiT = stream.readDataFullNotNull(); if (aiT != null) { if (aiT is UnitAIData) { this.ai = (UnitAIData)aiT; } else { this.ai = new UnitAIData(); if (!(aiT.GetType().IsAssignableFrom(typeof(UnitAIData)))) { stream.throwTypeReadError(typeof(UnitAIData), aiT.GetType()); } this.ai.shadowCopy(aiT); } } else { this.ai = null; } } else { this.ai = null; } if (stream.readBoolean()) { BaseData funcT = stream.readDataFullNotNull(); if (funcT != null) { if (funcT is UnitFuncData) { this.func = (UnitFuncData)funcT; } else { this.func = new UnitFuncData(); if (!(funcT.GetType().IsAssignableFrom(typeof(UnitFuncData)))) { stream.throwTypeReadError(typeof(UnitFuncData), funcT.GetType()); } this.func.shadowCopy(funcT); } } else { this.func = null; } } else { this.func = null; } stream.endReadObj(); }
/// <summary> /// 复制(深拷贝) /// </summary> protected override void toCopy(BaseData data) { if (!(data is UnitData)) { return; } UnitData mData = (UnitData)data; this.instanceID = mData.instanceID; if (mData.identity != null) { this.identity = (UnitIdentityData)mData.identity.clone(); } else { this.identity = null; nullObjError("identity"); } if (mData.normal != null) { this.normal = (UnitNormalData)mData.normal.clone(); } else { this.normal = null; nullObjError("normal"); } if (mData.pos != null) { this.pos = (UnitPosData)mData.pos.clone(); } else { this.pos = null; } if (mData.avatar != null) { this.avatar = (UnitAvatarData)mData.avatar.clone(); } else { this.avatar = null; } if (mData.move != null) { this.move = (UnitMoveData)mData.move.clone(); } else { this.move = null; } if (mData.fight != null) { this.fight = (UnitFightData)mData.fight.clone(); } else { this.fight = null; } if (mData.fightEx != null) { this.fightEx = (UnitFightExData)mData.fightEx.clone(); } else { this.fightEx = null; } if (mData.ai != null) { this.ai = (UnitAIData)mData.ai.clone(); } else { this.ai = null; } if (mData.func != null) { this.func = (UnitFuncData)mData.func.clone(); } else { this.func = null; } }
protected CommonMovementController(IMovementInput movementInput, UnitMoveData moveData) { MovementInput = movementInput; MoveData = moveData; }
private PatrolEnemyMovementController(IMovementInput movementInput, UnitMoveData moveData) : base(movementInput, moveData) { }