public override bool LogicTick() { if (mMoveData == null) { return(false); } float time = Time.realtimeSinceStartup - mStartTime; if (mMoveData.mMoveDataType == SkillMoveDataType.MoveType1) { SkillMoveData1 moveData = mMoveData as SkillMoveData1; float t = time / moveData.mTime; Vector3 dir = moveData.mDestPos - moveData.mSrcPos; Vector3 curPos = moveData.mSrcPos + dir * t; Vector3 curDir = dir.normalized; mOwner.Position = curPos; mOwner.Direction = curDir; if (time >= moveData.mTime) { return(false); } } if (mMoveData.mMoveDataType == SkillMoveDataType.MoveType2) { SkillMoveData2 moveData = mMoveData as SkillMoveData2; Vector3 curPos = moveData.mSrcPos + moveData.mTime * moveData.mSpeed * moveData.mDir; mOwner.Position = curPos; mOwner.Direction = moveData.mDir; if (time >= moveData.mTime) { return(false); } } Vector3 pos = mOwner.Position; pos.y += 10.0f; float h = 0.0f; if (NavigationSystem.GetLayerHeight(pos, mOwner.NavLayer, out h)) { pos.y = h; mOwner.Position = pos; } return(true); }
public void Init2(Character owner, Vector3 dir, float speed, float time) { mOwner = owner; SkillMoveData2 moveData2 = new SkillMoveData2(); mMoveData = moveData2; moveData2.mMoveDataType = SkillMoveDataType.MoveType2; moveData2.mSrcPos = owner.Position; moveData2.mDir = dir; moveData2.mDir.y = 0.0f; moveData2.mDir.Normalize(); moveData2.mSpeed = speed; moveData2.mTime = time; }
public override bool LogicTick() { if (mMoveData == null) { return(false); } float time = Time.ElapsedSeconds - mStartTime; if (mMoveData.mMoveDataType == SkillMoveDataType.MoveType1) { SkillMoveData1 moveData = mMoveData as SkillMoveData1; float t = time / moveData.mTime; Vector3 dir = moveData.mDestPos - moveData.mSrcPos; Vector3 curPos = moveData.mSrcPos + dir * t; Vector3 curDir = dir.normalize; mOwner.Position = curPos; mOwner.Direction = curDir; if (time >= moveData.mTime) { return(false); } } if (mMoveData.mMoveDataType == SkillMoveDataType.MoveType2) { SkillMoveData2 moveData = mMoveData as SkillMoveData2; Vector3 curPos = moveData.mSrcPos + moveData.mTime * moveData.mSpeed * moveData.mDir; mOwner.Position = curPos; mOwner.Direction = moveData.mDir; if (time >= moveData.mTime) { return(false); } } return(true); }