Example #1
0
    /// <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;
    }
Example #2
0
 public void setShootDirByServer(DirData data)
 {
     _gd.shootDir = data;
     onSetShootDir();
 }
Example #3
0
    /// <summary>
    /// 读取字节流(简版)
    /// </summary>
    protected override void toReadBytesSimple(BytesReadStream stream)
    {
        this.baseMoveState = stream.readInt();

        this.moveType = stream.readInt();

        if (stream.readBoolean())
        {
            this.baseMovePos = (PosData)stream.createData(PosData.dataID);
            this.baseMovePos.readBytesSimple(stream);
        }
        else
        {
            this.baseMovePos = null;
        }

        if (stream.readBoolean())
        {
            int moveListLen = stream.readLen();
            if (this.moveList != null)
            {
                this.moveList.clear();
                this.moveList.ensureCapacity(moveListLen);
            }
            else
            {
                this.moveList = new SList <PosData>();
            }

            SList <PosData> moveListT = this.moveList;
            for (int moveListI = moveListLen - 1; moveListI >= 0; --moveListI)
            {
                PosData moveListV;
                if (stream.readBoolean())
                {
                    moveListV = (PosData)stream.createData(PosData.dataID);
                    moveListV.readBytesSimple(stream);
                }
                else
                {
                    moveListV = null;
                }

                moveListT.add(moveListV);
            }
        }
        else
        {
            this.moveList = null;
        }

        this.specialMoveID = stream.readInt();

        if (stream.readBoolean())
        {
            int specialMoveArgsLen = stream.readLen();
            if (this.specialMoveArgs == null || this.specialMoveArgs.Length != specialMoveArgsLen)
            {
                this.specialMoveArgs = new int[specialMoveArgsLen];
            }
            int[] specialMoveArgsT = this.specialMoveArgs;
            for (int specialMoveArgsI = 0; specialMoveArgsI < specialMoveArgsLen; ++specialMoveArgsI)
            {
                int specialMoveArgsV;
                specialMoveArgsV = stream.readInt();

                specialMoveArgsT[specialMoveArgsI] = specialMoveArgsV;
            }
        }
        else
        {
            this.specialMoveArgs = null;
        }

        this.specialMoveLastTime = stream.readInt();

        this.vehicleInstanceID = stream.readInt();

        if (stream.readBoolean())
        {
            this.driveData = (DriveData)stream.readDataSimpleNotNull();
        }
        else
        {
            this.driveData = null;
        }

        if (stream.readBoolean())
        {
            this.realMoveDir = (DirData)stream.createData(DirData.dataID);
            this.realMoveDir.readBytesSimple(stream);
        }
        else
        {
            this.realMoveDir = null;
        }

        this.realMoveSpeedRatio = stream.readInt();
    }
Example #4
0
    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;
            }
        }
    }
Example #5
0
 /** 创建怪物 */
 public Unit createAddMonster(int id, int level, PosData pos, DirData dir)
 {
     return(addNewUnit(createMonsterData(id, level), pos, dir));
 }
Example #6
0
    //元方法

    /** 只设置朝向 */
    public void setDir(DirData dir)
    {
        _dir.copyDir(dir);
        onSetDir();
    }
Example #7
0
    public virtual void onAttackDamage(Unit from, AttackConfig config, SkillTargetData targetData)
    {
        if (config.attackEffect > 0)
        {
            Unit target = null;

            switch (targetData.type)
            {
            case SkillTargetType.None:
            {
                target = from;
            }
            break;

            case SkillTargetType.Single:
            {
                target = _scene.getFightUnit(targetData.targetInstanceID);
            }
            break;

            case SkillTargetType.Ground:
            {
            }
            break;

            default:
            {
                target = from;
            }
            break;
            }

            if (target != null)
            {
                target.show.playEffect(config.attackEffect);
            }
        }

        if (config.attackGroundEffect > 0)
        {
            PosData pos = null;
            DirData dir = null;

            switch (targetData.type)
            {
            case SkillTargetType.None:
            {
                pos = from.pos.getPos();
                dir = from.pos.getDir();
            }
            break;

            case SkillTargetType.Single:
            {
                Unit target = _scene.getFightUnit(targetData.targetInstanceID);

                if (target != null)
                {
                    pos = target.pos.getPos();
                    dir = target.pos.getDir();
                }
            }
            break;

            case SkillTargetType.Ground:
            {
                pos = targetData.pos;
                dir = from.pos.getDir();
            }
            break;

            default:
            {
                pos = from.pos.getPos();
                dir = from.pos.getDir();
            }
            break;
            }

            if (pos != null)
            {
                playSceneEffect(config.attackGroundEffect, pos, dir);
            }
        }
    }
Example #8
0
    /// <summary>
    /// 极坐标取点
    /// </summary>
    public PosData func_PosPolar(SceneTriggerExecutor e, TriggerArg a, PosData pos, float distance, DirData dir)
    {
        PosData re = new PosData();

        e.getScene().pos.polar2D(re, distance, dir);
        e.getScene().pos.addPos(re, pos);
        return(re);
    }
		VersionInfo GetVersionInfo (Repository vc, FilePath filepath, object dataObject, bool allowCacheMiss = true)
		{
			FilePath dir = filepath;
			dir = dir.ParentDirectory.CanonicalPath;

			DirData data;

				if (filePaths.TryGetValue (dir, out data)) {
					var fileData = data.FileData;
					if (fileData == null && allowCacheMiss) {
						fileData = new Dictionary<FilePath, VersionInfo> ();
						foreach (VersionInfo vin in vc.GetDirectoryVersionInfo (dir, false, false)) {
							// Console.WriteLine ("Storing {0} for {1}", vin.Status, vin.LocalPath.CanonicalPath);
							fileData [vin.LocalPath.CanonicalPath] = vin;
						}
						
						data.Timestamp = DateTime.Now;
						DispatchService.GuiDispatch(() => data.FileData = fileData);
					}
					VersionInfo vi;
					if (data.FileData != null && data.FileData.TryGetValue (filepath.CanonicalPath, out vi))
						return vi;
				}
				
				if (allowCacheMiss) {
					VersionInfo node = vc.GetVersionInfo (filepath, false);
					if (node != null) {
						if (data == null) {
							data = new DirData ();
							data.Object = dataObject;
							data.FileData = new Dictionary<FilePath, VersionInfo> ();
							DispatchService.GuiDispatch (() => filePaths[dir] = data);
						}
						// Console.WriteLine ("Storing {0} for {1}", node.Status, filepath.CanonicalPath);
						data.Timestamp = DateTime.Now;
						DispatchService.GuiDispatch (() => { if (data.FileData != null) data.FileData [filepath.CanonicalPath] = node; });
						return node;
					}
				}
			
			
			return null;
		}
Example #10
0
 /// <summary>
 /// 拷贝位置
 /// </summary>
 public void copyPos(PosData pos, DirData dir)
 {
     this.pos.copyPos(pos);
     this.dir.copyDir(dir);
 }
Example #11
0
 /// <summary>
 /// 回池
 /// </summary>
 protected override void toRelease(DataPool pool)
 {
     this.pos = null;
     this.dir = null;
 }
    /// <summary>
    /// Creates the voxels from ray casting through the face from rayDirection
    /// </summary>
    private IEnumerator CreateVoxelsFromDirection(int rayDirection)
    {
        int3    blobBounds = new int3(m_manager.m_blob.width, m_manager.m_blob.height, m_manager.m_blob.depth);
        DirData dirData    = m_data.dirData[rayDirection];
        int3    dataIndex  = new int3();
        int     planeAxis0 = ((rayDirection + 1) % 3);
        int     planeAxis1 = ((rayDirection + 2) % 3);

        for (; dirData.i < m_voxelEnd[planeAxis0]; ++dirData.i)
        {
            int i = dirData.i;
            if (i < 0 || i >= blobBounds[planeAxis0])
            {
                continue;
            }
            for (; dirData.j < m_voxelEnd[planeAxis1]; ++dirData.j)
            {
                int j = dirData.j;
                if (j < 0 || j >= blobBounds[planeAxis1])
                {
                    continue;
                }
                if (Scheduler.ShouldYield())
                {
                    yield return(null);
                }
                if (shouldAbort)
                {
                    yield break;
                }

                Vector3 point = Vector3.zero;
                point[planeAxis0] = i + 0.5f;
                point[planeAxis1] = j + 0.5f;

                SortedDictionary <float, bool> intersections = BuildIntersections(rayDirection, planeAxis0, planeAxis1, point);

                int3          index       = new int3(Mathf.FloorToInt(point.x), Mathf.FloorToInt(point.y), Mathf.FloorToInt(point.z));
                Stack <float> startPoints = new Stack <float>();
                float         last        = -1f;
                foreach (KeyValuePair <float, bool> kvp in intersections)
                {
                    if (Mathf.Approximately(kvp.Key, last))
                    {
                        continue;
                    }

                    if (kvp.Value)
                    {
                        if (startPoints.Count > 0)
                        {
                            for (int k = Mathf.RoundToInt(startPoints.Peek()); k < Mathf.RoundToInt(kvp.Key); ++k)
                            {
                                index[rayDirection] = k;
                                for (int dim = 0; dim < 3; ++dim)
                                {
                                    dataIndex[dim] = index[dim] - m_voxelStart[dim];
                                }
                                m_data.voxelData[dataIndex[0], dataIndex[1], dataIndex[2]]++;
                            }
                            if (startPoints.Count > 1)
                            {
                                startPoints.Pop();
                            }
                        }
                    }
                    else
                    {
                        startPoints.Push(kvp.Key);
                    }

                    last = kvp.Key;
                }

                for (int k = m_voxelStart[rayDirection]; k < m_voxelEnd[rayDirection]; ++k)
                {
                    index[rayDirection] = k;
                    for (int dim = 0; dim < 3; ++dim)
                    {
                        dataIndex[dim] = index[dim] - m_voxelStart[dim];
                    }
                    m_data.voxelData[dataIndex.x, dataIndex.y, dataIndex.z] += 10;
                    if (m_data.voxelData[dataIndex.x, dataIndex.y, dataIndex.z] >= 32)
                    {
                        if (m_manager.m_blob.IsValidPoint(index))
                        {
                            byte oldMat = m_manager.m_blob[index];
                            if (oldMat == MeshManager.kVoxelEmpty)
                            {
                                oldMat = MeshManager.kVoxelSubtract;
                            }
                            m_delta.blobDelta[index] = oldMat;
                            m_manager.m_blob[index]  = m_data.material;
                            m_manager.MarkChunksForRegenForPoint(index);
                        }
                    }
                }
            }
            dirData.j = m_voxelStart[planeAxis1];
        }

        yield return(null);
    }
Example #13
0
 /** 创建并添加场景特效 */
 public Unit createAddSceneEffect(int id, PosData pos, DirData dir)
 {
     return(addNewUnit(createSceneEffectData(id), pos, dir));
 }
Example #14
0
 /** 创建傀儡 */
 public Unit createAddPuppet(int id, int level, PosData pos, DirData dir, Unit master, int lastTime)
 {
     return(addNewUnit(createPuppetData(id, level, master, lastTime), pos, dir));
 }
Example #15
0
    /// <summary>
    /// 读取字节流(完整版)
    /// </summary>
    protected override void toReadBytesFull(BytesReadStream stream)
    {
        stream.startReadObj();

        this.baseMoveState = stream.readInt();

        this.moveType = stream.readInt();

        if (stream.readBoolean())
        {
            this.baseMovePos = (PosData)stream.createData(PosData.dataID);
            this.baseMovePos.readBytesFull(stream);
        }
        else
        {
            this.baseMovePos = null;
        }

        if (stream.readBoolean())
        {
            int moveListLen = stream.readLen();
            if (this.moveList != null)
            {
                this.moveList.clear();
                this.moveList.ensureCapacity(moveListLen);
            }
            else
            {
                this.moveList = new SList <PosData>();
            }

            SList <PosData> moveListT = this.moveList;
            for (int moveListI = moveListLen - 1; moveListI >= 0; --moveListI)
            {
                PosData moveListV;
                if (stream.readBoolean())
                {
                    moveListV = (PosData)stream.createData(PosData.dataID);
                    moveListV.readBytesFull(stream);
                }
                else
                {
                    moveListV = null;
                }

                moveListT.add(moveListV);
            }
        }
        else
        {
            this.moveList = null;
        }

        this.specialMoveID = stream.readInt();

        if (stream.readBoolean())
        {
            int specialMoveArgsLen = stream.readLen();
            if (this.specialMoveArgs == null || this.specialMoveArgs.Length != specialMoveArgsLen)
            {
                this.specialMoveArgs = new int[specialMoveArgsLen];
            }
            int[] specialMoveArgsT = this.specialMoveArgs;
            for (int specialMoveArgsI = 0; specialMoveArgsI < specialMoveArgsLen; ++specialMoveArgsI)
            {
                int specialMoveArgsV;
                specialMoveArgsV = stream.readInt();

                specialMoveArgsT[specialMoveArgsI] = specialMoveArgsV;
            }
        }
        else
        {
            this.specialMoveArgs = null;
        }

        this.specialMoveLastTime = stream.readInt();

        this.vehicleInstanceID = stream.readInt();

        if (stream.readBoolean())
        {
            BaseData driveDataT = stream.readDataFullNotNull();
            if (driveDataT != null)
            {
                if (driveDataT is DriveData)
                {
                    this.driveData = (DriveData)driveDataT;
                }
                else
                {
                    this.driveData = new DriveData();
                    if (!(driveDataT.GetType().IsAssignableFrom(typeof(DriveData))))
                    {
                        stream.throwTypeReadError(typeof(DriveData), driveDataT.GetType());
                    }
                    this.driveData.shadowCopy(driveDataT);
                }
            }
            else
            {
                this.driveData = null;
            }
        }
        else
        {
            this.driveData = null;
        }

        if (stream.readBoolean())
        {
            this.realMoveDir = (DirData)stream.createData(DirData.dataID);
            this.realMoveDir.readBytesFull(stream);
        }
        else
        {
            this.realMoveDir = null;
        }

        this.realMoveSpeedRatio = stream.readInt();

        stream.endReadObj();
    }
Example #16
0
 /// <summary>
 /// 是否相等
 /// </summary>
 public bool isEquals(DirData dir)
 {
     return(MathUtils.floatEquals(direction, dir.direction) && MathUtils.floatEquals(directionX, dir.directionX));
 }
Example #17
0
 /** 单位更改朝向 */
 public virtual void onSetDir(DirData dir)
 {
 }
Example #18
0
 /// <summary>
 /// 拷贝位置
 /// </summary>
 public void copyDir(DirData dir)
 {
     this.direction  = dir.direction;
     this.directionX = dir.directionX;
 }
Example #19
0
 /** 播放场景特效 */
 public void playSceneEffect(int effectID, PosData pos, DirData dir)
 {
     _scene.unitFactory.createAddSceneEffectBySignEffect(effectID, pos, dir);
 }
Example #20
0
 protected virtual void doSetDir(DirData dir)
 {
 }
    /// <summary>
    /// 回池
    /// </summary>
    protected override void toRelease(DataPool pool)
    {
        base.toRelease(pool);

        this.dir = null;
    }
Example #22
0
 private void makeShootDir(DirData data)
 {
     data.copyDir(((GUnitPosData)_unit.getUnitData().pos).shootDir);
 }
		public override void OnNodeAdded (object dataObject)
		{
			FilePath path = GetPath (dataObject);
			if (path != FilePath.Null) {
				DirData dd = new DirData ();
				dd.Object = dataObject;
				filePaths [path.CanonicalPath] = dd;
			}
		}
Example #24
0
    protected override void doSetDir(DirData dir)
    {
        base.doSetDir(dir);

        setShootDir(((GUnitPosData)_unit.getUnitData().pos).shootDir);
    }