public static void sincos(out VFactor s, out VFactor c, VFactor angle) { int index = SinCosLookupTable.getIndex(angle.nom, angle.den); s = new VFactor((long)SinCosLookupTable.sin_table[index], (long)SinCosLookupTable.FACTOR); c = new VFactor((long)SinCosLookupTable.cos_table[index], (long)SinCosLookupTable.FACTOR); }
public void Update(ActorRoot _parent) { if (!this.childActorRoot) { return; } VInt3 vInt = _parent.location + this.translation; if (this.translation.x != 0 || this.translation.z != 0) { VInt3 forward = VInt3.forward; VFactor b = VInt3.AngleInt(_parent.forward, forward); int num = _parent.forward.x * forward.z - forward.x * _parent.forward.z; if (num < 0) { b = VFactor.twoPi - b; } VInt3 vInt2 = this.translation.RotateY(ref b); vInt = _parent.location + vInt2.NormalizeTo(this.distance.i); vInt.y += this.translation.y; } this.childActorRoot.handle.location = vInt; this.childActorRoot.handle.forward = _parent.forward; this.UpdateMoveDelta(vInt); }
protected void UpdateRotateDir(VInt3 targetDir, int dt) { ActorRoot actor = this.Parent.actor; if (targetDir == VInt3.zero) { return; } actor.ObjLinker.SetForward(targetDir, this.Parent.actor.ActorControl.curMoveSeq); if (actor.ActorControl.GetNoAbilityFlag(ObjAbilityType.ObjAbility_MoveRotate)) { return; } actor.forward = targetDir; if (actor.InCamera) { Vector3 forward = this.Parent.actor.myTransform.forward; ((Vector3)targetDir).y = 0f; forward.y = 0f; VFactor b = VInt3.AngleInt(targetDir, VInt3.forward); int num = targetDir.x * VInt3.forward.z - VInt3.forward.x * targetDir.z; if (num < 0) { b = VFactor.twoPi - b; } Quaternion quaternion = Quaternion.AngleAxis(b.single * 57.29578f, Vector3.up); actor.rotation = Quaternion.RotateTowards(actor.rotation, quaternion, (float)(this.Parent.RotateSpeed * dt) * 0.001f); } }
protected void UpdateRotateDir(VInt3 targetDir, int dt) { ActorRoot actor = this.Parent.actor; if (targetDir != VInt3.zero) { actor.ObjLinker.SetForward(targetDir, this.Parent.actor.ActorControl.curMoveSeq); if (!actor.ActorControl.GetNoAbilityFlag(ObjAbilityType.ObjAbility_MoveRotate)) { actor.forward = targetDir; if (actor.InCamera) { Vector3 forward = this.Parent.gameObject.transform.forward; Vector3 vector2 = (Vector3)targetDir; vector2.y = 0f; forward.y = 0f; VFactor factor = VInt3.AngleInt(targetDir, VInt3.forward); int num = (targetDir.x * VInt3.forward.z) - (VInt3.forward.x * targetDir.z); if (num < 0) { factor = VFactor.twoPi - factor; } Quaternion to = Quaternion.AngleAxis(factor.single * 57.29578f, Vector3.up); actor.rotation = Quaternion.RotateTowards(actor.rotation, to, (this.Parent.RotateSpeed * dt) * 0.001f); } } } }
public static VInt3 SegmentIntersectionPoint(VInt3 start1, VInt3 end1, VInt3 start2, VInt3 end2, out bool intersects) { VInt3 a = end1 - start1; VInt3 vInt = end2 - start2; long num = (long)(vInt.z * a.x - vInt.x * a.z); if (num == 0L) { intersects = false; return(start1); } long num2 = (long)(vInt.x * (start1.z - start2.z) - vInt.z * (start1.x - start2.x)); long num3 = (long)(a.x * (start1.z - start2.z) - a.z * (start1.x - start2.x)); VFactor vFactor = new VFactor { nom = num2 * 1000L, den = num }; VFactor vFactor2 = default(VFactor); vFactor2.nom = num3 * 1000L; vFactor2.den = num; int integer = vFactor.integer; int integer2 = vFactor.integer; if (integer < 0 || integer > 1000 || integer2 < 0 || integer2 > 1000) { intersects = false; return(start1); } intersects = true; return(start1 + IntMath.Divide(a, (long)integer, 1000L)); }
private void SetSkillSpeed(PoolObjHandle <ActorRoot> _user) { int num = 0; if (this.curAction) { PoolObjHandle <ActorRoot> poolObjHandle = _user; MonsterWrapper monsterWrapper = _user.handle.ActorControl as MonsterWrapper; if (monsterWrapper != null && monsterWrapper.isCalledMonster && monsterWrapper.UseHostValueProperty) { poolObjHandle = monsterWrapper.hostActor; } ValueDataInfo valueDataInfo = poolObjHandle.handle.ValueComponent.mActorValue[RES_FUNCEFT_TYPE.RES_PROPERTY_ATTACKSPEED]; int totalValue = valueDataInfo.totalValue; int num2 = totalValue + poolObjHandle.handle.ValueComponent.mActorValue.actorLvl * (int)this.battleParam.dwM_AttackSpeed + (int)this.battleParam.dwN_AttackSpeed; if (num2 != 0) { num = totalValue * 10000 / num2; } num += poolObjHandle.handle.ValueComponent.mActorValue[RES_FUNCEFT_TYPE.RES_FUNCEFT_ATKSPDADD].totalValue; if (this.cfgData != null && this.cfgData.bNoInfluenceAnim == 1) { num = 0; } VFactor playSpeed = new VFactor((long)(10000 + num), 10000L); this.curAction.handle.SetPlaySpeed(playSpeed); } }
public static bool IntersectionFactor(VInt3 start1, VInt3 end1, VInt3 start2, VInt3 end2, out VFactor factor1, out VFactor factor2) { VInt3 vInt = end1 - start1; VInt3 vInt2 = end2 - start2; long num = (long)(vInt2.z * vInt.x - vInt2.x * vInt.z); if (num == 0L) { factor1 = VFactor.zero; factor2 = VFactor.zero; return(false); } long nom = (long)(vInt2.x * (start1.z - start2.z) - vInt2.z * (start1.x - start2.x)); long nom2 = (long)(vInt.x * (start1.z - start2.z) - vInt.z * (start1.x - start2.x)); factor1 = default(VFactor); VFactor vFactor = factor1; vFactor.nom = nom; vFactor.den = num; factor1 = vFactor; factor2 = default(VFactor); vFactor = factor2; vFactor.nom = nom2; vFactor.den = num; factor2 = vFactor; return(true); }
protected void UpdateRotateDir(VInt3 targetDir, int dt) { ActorRoot actor = this.Parent.actor; if (targetDir == VInt3.zero) { return; } actor.ObjLinker.SetForward(targetDir, this.Parent.actor.ActorControl.curMoveSeq); if (actor.ActorControl.GetNoAbilityFlag(ObjAbilityType.ObjAbility_MoveRotate)) { return; } actor.forward = targetDir; if (actor.InCamera) { Vector3 forward = this.Parent.actor.myTransform.forward; ((Vector3)targetDir).y = 0f; forward.y = 0f; VFactor vFactor = VInt3.AngleInt(targetDir, VInt3.forward); int arg_B8_0 = targetDir.x; VInt3 forward2 = VInt3.forward; int arg_CF_0 = arg_B8_0 * forward2.z; VInt3 forward3 = VInt3.forward; int num = arg_CF_0 - forward3.x * targetDir.z; if (num < 0) { vFactor = VFactor.twoPi - vFactor; } Quaternion to = Quaternion.AngleAxis(vFactor.get_single() * 57.29578f, Vector3.up); actor.rotation = Quaternion.RotateTowards(actor.rotation, to, (float)(this.Parent.RotateSpeed * dt) * 0.001f); } }
private void SetCollisionScale(int _scaleRate) { if (this.actorObj != 0) { VFactor factor = new VFactor((long)this.scaleRate, 0x2710L); VCollisionShape shape = this.actorObj.handle.shape; if (shape != null) { int roundInt = factor.roundInt; if (shape is VCollisionSphere) { VCollisionSphere sphere = shape as VCollisionSphere; if (sphere != null) { this.originalRadius = sphere.Radius; sphere.Radius *= roundInt; } } else if (shape is VCollisionBox) { VCollisionBox box = shape as VCollisionBox; if (box != null) { VInt3 num2; this.originalSize = box.Size; num2.x = box.Size.x * roundInt; num2.y = box.Size.y * roundInt; num2.z = box.Size.z * roundInt; box.Size = num2; } } } } }
public VFactor GetCosineAngle(VInt3 dest, MoveDirectionState state, out int edgeIndex) { VInt3 vInt = this.v1 - this.v0; VInt3 vInt2 = this.v2 - this.v0; VInt3 vInt3 = dest - this.v0; vInt3.NormalizeTo(1000); vInt.NormalizeTo(1000); vInt2.NormalizeTo(1000); long num = VInt3.DotXZLong(ref vInt3, ref vInt); long num2 = VInt3.DotXZLong(ref vInt3, ref vInt2); VFactor result = default(VFactor); result.den = 1000000L; if (num > num2) { edgeIndex = this.vi; result.nom = num; } else { edgeIndex = (this.vi + 2) % 3; result.nom = num2; } return(result); }
public override void OnRelease() { this.playSpeedOnPause = VFactor.zero; this.deltaTime = 0; this.started_ = false; this.nextDestroy = false; this.enabled = true; this.name = string.Empty; this.length = 0x1388; this.loop = false; this.playSpeed = VFactor.one; this.unstoppable = false; this.actionName = string.Empty; this.refGameObjectsCount = -1; this.time = 0; this.updateFrameIdx = 0; this.parentAction = null; this.actorHandles.Clear(); this.gameObjects.Clear(); this.tracks.Clear(); this.conditions.Clear(); this.conditionChanged = true; this.refParams.Reset(); this.refParamsSrc = null; this.templateObjectIds.Clear(); this.tempObjsAffectedByPlaySpeed.Clear(); this.onActionStop = (ActionStopDelegate)Delegate.RemoveAll(this.onActionStop, this.onActionStop); }
public void CustumLateUpdate() { if (((this.myRenderer != null) && (this.ActorObj != null)) && (this.myRenderer.isVisible != this.ActorObj.InCamera)) { this.ActorObj.InCamera = this.myRenderer.isVisible; if (this.ActorObj.InCamera) { if (this.ActorObj.isMovable) { this.oldLocation = this.ActorObj.location; base.gameObject.transform.position = (Vector3)this.ActorObj.location; } if (this.ActorObj.isRotatable) { VFactor factor = VInt3.AngleInt(this.ActorObj.forward, VInt3.forward); int num = (this.ActorObj.forward.x * VInt3.forward.z) - (VInt3.forward.x * this.ActorObj.forward.z); if (num < 0) { factor = VFactor.twoPi - factor; } this.tarRotation = Quaternion.AngleAxis(factor.single * 57.29578f, Vector3.up); base.gameObject.transform.rotation = this.tarRotation; } } } }
/// <summary> /// 解二次方程 /// </summary> /// <returns></returns> public static void ResolveQuadraticEquation(VFactor a, VFactor b, VFactor c, ref VFactor root1, ref VFactor root2) { VFactor _delta = new VFactor(Sqrt(((b * b - a * c * 4) * 10000).roundInt), 100); root1 = (-b + _delta) / a / 2; root2 = (-b - _delta) / a / 2; }
private void SetSkillSpeed(PoolObjHandle <ActorRoot> user) { int totalValue = 0; int num2 = 0; int num3 = 0; ValueDataInfo info = null; if (base.curAction != 0) { info = user.handle.ValueComponent.mActorValue[RES_FUNCEFT_TYPE.RES_PROPERTY_ATTACKSPEED]; totalValue = info.totalValue; num3 = (int)((totalValue + (user.handle.ValueComponent.mActorValue.actorLvl * this.battleParam.dwM_AttackSpeed)) + this.battleParam.dwN_AttackSpeed); if (num3 != 0) { num2 = (totalValue * 0x2710) / num3; } num2 += user.handle.ValueComponent.mActorValue[RES_FUNCEFT_TYPE.RES_FUNCEFT_ATKSPDADD].totalValue; if ((this.cfgData != null) && (this.cfgData.bNoInfluenceAnim == 1)) { num2 = 0; } VFactor factor = new VFactor((long)(0x2710 + num2), 0x2710L); this.curAction.handle.SetPlaySpeed(factor); } }
public override void Fight() { base.Fight(); this.nHpRecoveryTick = 0; this.nEpRecoveryTick = 0; DebugHelper.Assert(this.mActorValue != null, "mActorValue = null data is error"); if (this.mActorValue != null) { VFactor hpRate = this.GetHpRate(); DebugHelper.Assert(this.actor != null, "actor is null ? impossible..."); if (this.actor != null) { bool bPVPLevel = true; SLevelContext curLvelContext = Singleton <BattleLogic> .GetInstance().GetCurLvelContext(); if (curLvelContext != null) { bPVPLevel = curLvelContext.IsMobaMode(); } this.mActorValue.AddSymbolPageAttToProp(ref this.actor.TheActorMeta, bPVPLevel); IGameActorDataProvider actorDataProvider = Singleton <ActorDataCenter> .instance.GetActorDataProvider(GameActorDataProviderType.ServerDataProvider); ActorServerData actorServerData = default(ActorServerData); if (actorDataProvider != null && actorDataProvider.GetActorServerData(ref this.actor.TheActorMeta, ref actorServerData)) { this.mActorValue.SetSkinProp((uint)this.actor.TheActorMeta.ConfigId, actorServerData.SkinId, true); } } this.SetHpByRate(hpRate); } }
public static VFactor operator -(VFactor a, VFactor b) { VFactor factor = new VFactor(); factor.nom = (a.nom * b.den) - (b.nom * a.den); factor.den = a.den * b.den; return(factor); }
public void SetHpByRate(VFactor hpRate) { DebugHelper.Assert(hpRate.den != 0L, "SetHpByRate hpRate den is zero"); if (hpRate.den != 0L) { this.actorHp = (hpRate * (long)this.actorHpTotal).get_roundInt(); } }
private void Check_hp() { Player hostPlayer = Singleton <GamePlayerCenter> .instance.GetHostPlayer(); if (((hostPlayer == null) || (hostPlayer.Captain == 0)) || ((hostPlayer.Captain.handle.ActorControl == null) || (hostPlayer.Captain.handle.ValueComponent == null))) { this.Clear(); } else { VFactor factor = (VFactor)(hostPlayer.Captain.handle.ValueComponent.GetHpRate() * 100L); int roundInt = factor.roundInt; if (hostPlayer.Captain.handle.ActorControl.IsDeadState || (hostPlayer.Captain.handle.ValueComponent.actorHp <= 0)) { this.bIn10 = this.bIn30 = false; this.bNormal = true; if (this.animationScript != null) { this.animationScript.PlayAnimator("Rid_Close"); } } else if (roundInt > 30) { this.bIn10 = this.bIn30 = false; if (!this.bNormal) { if (this.animationScript != null) { this.animationScript.PlayAnimator("Rid_Close"); } this.bNormal = true; } } else if (roundInt <= 10) { if (!this.bIn10) { this.bIn10 = true; this.bNormal = false; this.bIn30 = false; if (this.animationScript != null) { this.animationScript.PlayAnimator("Rid_02"); } } } else if ((roundInt <= 30) && !this.bIn30) { this.bIn30 = true; this.bIn10 = false; this.bNormal = false; if (this.animationScript != null) { this.animationScript.PlayAnimator("Rid_Stat"); } } } }
static VFactor() { zero = new VFactor(0L, 1L); one = new VFactor(1L, 1L); pi = new VFactor(0x7ab8L, 0x2710L); twoPi = new VFactor(0xf570L, 0x2710L); mask_ = 0x7fffffffffffffffL; upper_ = 0xffffffL; }
public void Play() { if (!this.enabled) { this.enabled = true; this.playSpeed = this.playSpeedOnPause; this.SetPlaySpeed(this.playSpeedOnPause); } }
public void Pause() { if (this.enabled) { this.enabled = false; this.playSpeedOnPause = this.playSpeed; this.SetPlaySpeed(VFactor.zero); } }
public void SetHpByRate(VFactor hpRate) { DebugHelper.Assert(hpRate.den != 0L, "SetHpByRate hpRate den is zero"); if (hpRate.den != 0) { VFactor factor = hpRate * this.actorHpTotal; this.actorHp = factor.roundInt; } }
public void Play() { if (this.enabled) { return; } this.enabled = true; this.playSpeed = this.playSpeedOnPause; this.SetPlaySpeed(this.playSpeedOnPause); }
public override void Process(Action _action, Track _track, int _localTime) { if (!this.actorTarget) { return; } int num = _localTime - this.lastTime; this.lastTime = _localTime; if (this.actorTarget.get_handle().ActorControl.curMoveCommand != null) { FrameCommand <MoveDirectionCommand> frameCommand = (FrameCommand <MoveDirectionCommand>) this.actorTarget.get_handle().ActorControl.curMoveCommand; VInt3 vInt = this.actorTarget.get_handle().forward; VInt3 right = VInt3.right; this.destDir = right.RotateY((int)frameCommand.cmdData.Degree); if (this.destDir != vInt) { this.bNeedRotate = true; this.curRotateSpd = this.rotateSpeed; int num2 = this.destDir.x * vInt.z - vInt.x * this.destDir.z; if (num2 == 0) { int num3 = VInt3.Dot(this.destDir, vInt); if (num3 >= 0) { return; } this.curRotateSpd = this.rotateSpeed; } else if (num2 < 0) { this.curRotateSpd = -this.rotateSpeed; } VFactor vFactor = VInt3.AngleInt(this.destDir, vInt); VFactor vFactor2 = VFactor.pi * (long)num * (long)this.curRotateSpd / 180L / 1000L; if (vFactor <= vFactor2) { vInt = vInt.RotateY(ref vFactor); this.bNeedRotate = false; } else { vInt = vInt.RotateY(ref vFactor2); } this.actorTarget.get_handle().MovementComponent.SetRotate(vInt, true); } } else { this.destDir = this.actorTarget.get_handle().forward; this.bNeedRotate = false; this.curRotateSpd = 0; } base.Process(_action, _track, _localTime); }
public static VFactor acos(long nom, long den) { int index = ((int)Divide((long)(nom * AcosLookupTable.HALF_COUNT), den)) + AcosLookupTable.HALF_COUNT; index = Mathf.Clamp(index, 0, AcosLookupTable.COUNT); VFactor factor = new VFactor(); factor.nom = AcosLookupTable.table[index]; factor.den = 0x2710L; return(factor); }
public static VFactor NearestPointFactor(ref VInt3 lineStart, ref VInt3 lineEnd, ref VInt3 point) { VInt3 rhs = lineEnd - lineStart; long sqrMagnitudeLong = rhs.sqrMagnitudeLong; VFactor zero = VFactor.zero; zero.nom = VInt3.DotLong(point - lineStart, rhs); if (sqrMagnitudeLong != 0) { zero.den = sqrMagnitudeLong; } return(zero); }
/// <summary> /// 向量旋转 /// </summary> /// <param name="start"></param> /// <param name="end"></param> /// <param name="max_radians"></param> /// <returns></returns> public static VInt3 RotateTowards(VInt3 start, VInt3 end, VFactor max_radians) { VFactor angle = AngleInt(start, end); if (angle == VFactor.zero) { return(end); } VFactor percent = IntMath.Min(max_radians / angle, VFactor.one); return(Slerp(start, end, percent)); }
public static VFactor NearestPointFactorXZ(ref VInt3 lineStart, ref VInt3 lineEnd, ref VInt3 point) { VInt2 b = new VInt2(lineEnd.x - lineStart.x, lineEnd.z - lineStart.z); VInt2 a = new VInt2(point.x - lineStart.x, point.z - lineStart.z); long sqrMagnitudeLong = b.sqrMagnitudeLong; VFactor zero = VFactor.zero; zero.nom = VInt2.DotLong(a, b); if (sqrMagnitudeLong != 0) { zero.den = sqrMagnitudeLong; } return(zero); }
public void OnApChangeByMgcEffect() { int totalEftRatioByMgc = base.actor.ValueComponent.mActorValue[RES_FUNCEFT_TYPE.RES_FUNCEFT_MAXHP].totalEftRatioByMgc; int totalOldEftRatioByMgc = base.actor.ValueComponent.mActorValue[RES_FUNCEFT_TYPE.RES_FUNCEFT_MAXHP].totalOldEftRatioByMgc; base.actor.ValueComponent.mActorValue[RES_FUNCEFT_TYPE.RES_FUNCEFT_MAXHP].totalEftRatioByMgc = totalOldEftRatioByMgc; VFactor factor = new VFactor((long)base.actor.ValueComponent.actorHp, (long)base.actor.ValueComponent.mActorValue[RES_FUNCEFT_TYPE.RES_FUNCEFT_MAXHP].totalValue); base.actor.ValueComponent.mActorValue[RES_FUNCEFT_TYPE.RES_FUNCEFT_MAXHP].totalEftRatioByMgc = totalEftRatioByMgc; if ((totalOldEftRatioByMgc < totalEftRatioByMgc) && !base.actor.ActorControl.IsDeadState) { VFactor factor2 = factor * base.actor.ValueComponent.mActorValue[RES_FUNCEFT_TYPE.RES_FUNCEFT_MAXHP].totalValue; base.actor.ValueComponent.actorHp = factor2.roundInt; } }
public VInt3 RotateY(ref VFactor radians) { VFactor vFactor; VFactor vFactor2; IntMath.sincos(out vFactor, out vFactor2, radians.nom, radians.den); long num = vFactor2.nom * vFactor.den; long num2 = vFactor2.den * vFactor.nom; long b = vFactor2.den * vFactor.den; VInt3 vInt; vInt.x = (int)IntMath.Divide((long)this.x * num + (long)this.z * num2, b); vInt.z = (int)IntMath.Divide((long)(-(long)this.x) * num2 + (long)this.z * num, b); vInt.y = 0; return(vInt.NormalizeTo(1000)); }