public override bool ClientCastSkillByID(int skillID) { if (!GlobalBattleNetwork.Instance.IsServerEnable) { if (this.IsOpenLog) { Debug.LogError("return 4"); } return(false); } Skill skill = DataReader <Skill> .Get(skillID); if (skill.rush > 0) { this.owner.GetSkillManager().SetTargetBySkillID(skillID, TargetRangeType.SkillRange, (float)skill.rush); } else { this.owner.GetSkillManager().SetTargetBySkillID(skillID, TargetRangeType.SkillRange, 0f); } if (skill.rush > 0 && this.owner.AITarget != null && this.owner.AITarget.Actor) { float num = XUtility.DistanceNoY(this.ownerActor.FixTransform.get_position(), this.owner.AITarget.Actor.FixTransform.get_position()) - (float)skill.reach.get_Item(0) * 0.01f - XUtility.GetHitRadius(this.owner.AITarget.Actor.FixTransform); if (!this.owner.IsStatic && !this.owner.IsDizzy && !this.owner.IsWeak && !this.owner.IsFixed && !this.owner.IsAssault && !this.owner.IsHitMoving && num <= (float)skill.rush * 0.01f && num > 0f && (!ActionStatusName.IsSkillAction(this.ownerActor.CurActionStatus) || this.ownerActor.IsUnderTermination) && this.ownerActor.CanChangeActionTo("rush", true, 0, false) && this.CheckClientHandleSkillByID(skillID)) { this.ClientBeginAssault(skillID, this.owner.AITarget); return(false); } } return(base.ClientCastSkillByID(skillID)); }
public override void ShowEffect() { if (Owner != null && Owner is Hero) { if (GamingSys.Instance.Player.Bullet > 0)//子弹数判断 { GameObject cCastEffect = EffectManager.Create("GenericMuzzleFlash", true, (Owner as Hero).FirePoint); if (null != cCastEffect) { cCastEffect.transform.forward = Owner.transform.forward; } GameObject go = EffectManager.Create("Z_bullet", false); go.transform.position = (Owner as Actor).FirePoint.position - (Owner as Actor).FirePoint.forward; FlyBullet bullet = go.AddUniqueComponent <FlyBullet>(); bullet.Skill = this; bullet.Forward = XUtility.DirectionNoY((Owner as Actor).AttackTarget.position - go.transform.position).normalized; bullet.LayerMask = mCollisionMask ^ (1 << Owner.gameObject.layer); bullet.EnterScene(); GamingSys.Instance.Player.Bullet--; } else { GamingSys.Instance.Player.ChangeWeapon(); } } }
public void ServerAssault(Vector3 endPosition, int actionPriority) { this.assaultEndPos = endPosition; this.assaultSpeed = base.OriginAssaultSpeed * base.LogicMoveSpeed / base.ModelOriginSpeed; this.assaultTime = XUtility.DistanceNoY(base.FixTransform.get_position(), endPosition) / this.assaultSpeed; base.ServerCastAction("rush", actionPriority, ActorParent.EffectFrameSetMode.Server, 1f, 0, 0, string.Empty); }
public bool MoveToCurrentBatchPoint() { if (this.owner.IsWeak) { return(false); } if (!this.ownerActor) { return(false); } if (this.owner.AITarget != null) { return(false); } List <EntityParent> values = EntityWorld.Instance.AllEntities.Values; for (int i = 0; i < values.get_Count(); i++) { if (values.get_Item(i).Camp != this.owner.Camp) { return(false); } } Vector2 zero = Vector2.get_zero(); if (InstanceManager.GetCurrentBattlePathPoint(out zero)) { if (XUtility.DistanceNoY(this.ownerActor.FixTransform.get_position(), new Vector3(zero.x, this.ownerActor.FixTransform.get_position().y, zero.y)) > 0.5f) { this.ownerActor.MoveToPoint(new Vector3(zero.x, this.ownerActor.FixTransform.get_position().y, zero.y), 0f, null); } return(true); } return(false); }
public override bool FindAttackTarget() { AttackTarget = null; Dictionary <long, Monster> hero = ActorManager.Instance.EnemyDict; float temp, dire = float.MaxValue; foreach (Actor actor in hero.Values) { if (actor.IsDead) { continue; } temp = XUtility.DistanceNoY(actor.transform.position, transform.position); if (temp <= CurSkill.Attr.FindDist && temp < dire) { dire = temp; AttackTarget = actor; } } if (null != AttackTarget) { SetBool("findTarget", true); //mCurSpeed = Attr.CrouchSpeed; return(true); } else { SetBool("findTarget", false); //mCurSpeed = Attr.MoveSpeed; return(false); } }
private void ResetPetInfos() { this.mPetInfos.Clear(); using (Dictionary <long, PetInfo> .ValueCollection.Enumerator enumerator = PetManager.Instance.MaplistPet.get_Values().GetEnumerator()) { while (enumerator.MoveNext()) { PetInfo current = enumerator.get_Current(); this.mPetInfos.Add(current); } } for (int i = 0; i < this.mPetInfos.get_Count(); i++) { int num = i; for (int j = i + 1; j < this.mPetInfos.get_Count(); j++) { Pet pet = DataReader <Pet> .Get(this.mPetInfos.get_Item(num).petId); Pet pet2 = DataReader <Pet> .Get(this.mPetInfos.get_Item(j).petId); if (pet.summonEnergy < pet2.summonEnergy) { num = j; } } if (num != i) { XUtility.ListExchange <PetInfo>(this.mPetInfos, num, i); } } }
private void SetWeapon2Slot(string realSlot, bool resetlocal) { if (string.IsNullOrEmpty(realSlot)) { return; } this.CurrentSlot = realSlot; if (this.m_goWeapons.get_Count() >= 1) { Transform transform = null; if (realSlot != string.Empty) { transform = XUtility.RecursiveFindTransform(this.ActorTarget.get_transform(), realSlot); if (transform == null) { return; } } GameObject gameObject = this.m_goWeapons.get_Item(0); if (gameObject != null) { Vector3 localScale = gameObject.get_transform().get_localScale(); Vector3 position = gameObject.get_transform().get_position(); gameObject.get_transform().set_parent(transform); gameObject.get_transform().set_position(position); if (resetlocal) { gameObject.get_transform().set_localPosition(Vector3.get_zero()); gameObject.get_transform().set_localEulerAngles(Vector3.get_zero()); gameObject.get_transform().set_localScale(localScale); } } } if (this.m_goWeapons.get_Count() >= 2) { Transform transform2 = null; if (realSlot != string.Empty) { transform2 = XUtility.RecursiveFindTransform(this.ActorTarget.get_transform(), realSlot + "2"); if (transform2 == null) { return; } } GameObject gameObject2 = this.m_goWeapons.get_Item(1); if (gameObject2 != null) { Vector3 localScale2 = gameObject2.get_transform().get_localScale(); Vector3 position2 = gameObject2.get_transform().get_position(); gameObject2.get_transform().set_parent(transform2); gameObject2.get_transform().set_position(position2); if (resetlocal) { gameObject2.get_transform().set_localPosition(Vector3.get_zero()); gameObject2.get_transform().set_localEulerAngles(Vector3.get_zero()); gameObject2.get_transform().set_localScale(localScale2); } } } }
protected void CheckFixStand() { float num = XUtility.DistanceNoY(this.transform.get_position(), this.npcPosition); if (num > TaskNPCBehavior.NavToPointStopDistance) { this.transform.set_position(MySceneManager.GetTerrainPoint(this.npcPosition.x, this.npcPosition.z, this.npcPosition.y)); this.navMeshAgent.Warp(this.transform.get_position()); } if (this.transform.get_forward() != this.npcDirection) { this.transform.set_forward(this.npcDirection); } if (this.IsFollowingSelf) { this.IsFollowingSelf = false; } if (this.IsNavToPoint) { this.IsNavToPoint = false; } this.StopNavAgent(); base.CastAction(base.DefaultIdleActionStatus); this.UpdateState(new TaskNPCBehavior.TaskNPCState { state = TaskNPCBehavior.TaskNPCState.TaskNPCStateType.None, Position = this.transform.get_position(), Direction = this.transform.get_forward() }); }
public override bool ClientCastSkillByID(int skillID) { if (this.owner.IsClientDominate) { Skill skill = DataReader <Skill> .Get(skillID); if (skill.rush > 0) { this.owner.GetSkillManager().SetTargetBySkillID(skillID, TargetRangeType.SkillRange, (float)skill.rush); } else { this.owner.GetSkillManager().SetTargetBySkillID(skillID, TargetRangeType.SkillRange, 0f); } if (skill.rush > 0 && this.owner.AITarget != null && this.owner.AITarget.Actor) { float num = XUtility.DistanceNoY(this.ownerActor.FixTransform.get_position(), this.owner.AITarget.Actor.FixTransform.get_position()) - (float)skill.reach.get_Item(0) * 0.01f - XUtility.GetHitRadius(this.owner.AITarget.Actor.FixTransform); if (!this.owner.IsStatic && !this.owner.IsDizzy && !this.owner.IsWeak && !this.owner.IsFixed && !this.owner.IsAssault && !this.owner.IsHitMoving && num <= (float)skill.rush * 0.01f && num > 0f && this.CheckClientHandleSkillByID(skillID)) { this.ClientBeginAssault(skillID, this.owner.AITarget); return(false); } } return(base.ClientCastSkillByID(skillID)); } return(base.ClientCastSkillByID(skillID)); }
public bool CheckTargetDistanceBySkillIndex(int skillIndex) { int key; if (!this.GetSkillIDBySkillIndex(skillIndex, out key)) { return(false); } Skill skill = DataReader <Skill> .Get(key); if (skill == null) { return(false); } if (this.owner.AITarget == null) { return(false); } if (this.owner.AITarget.Actor == null || this.owner.AITarget.Actor.FixTransform == null) { return(false); } if (XUtility.DistanceNoY(this.ownerActor.FixTransform.get_position(), this.owner.AITarget.Actor.FixTransform.get_position()) <= (float)skill.reach.get_Item(0) * 0.01f + XUtility.GetHitRadius(this.owner.AITarget.Actor.FixTransform) && XUtility.DistanceNoY(this.ownerActor.FixTransform.get_position(), this.owner.AITarget.Actor.FixTransform.get_position()) >= skill.reachLimit * 0.01f - XUtility.GetHitRadius(this.owner.AITarget.Actor.FixTransform)) { float num = Vector3.Angle(this.ownerActor.FixTransform.get_forward(), new Vector3(this.owner.AITarget.Actor.FixTransform.get_position().x, this.ownerActor.FixTransform.get_position().y, this.owner.AITarget.Actor.FixTransform.get_position().z) - this.ownerActor.FixTransform.get_position()); if (num <= (float)skill.reach.get_Item(1) || this.ownerActor.FixTransform.get_position() == this.owner.AITarget.Actor.FixTransform.get_position()) { return(true); } } return(false); }
private void ClickNav(PointerEventData eventData) { RadarManager.Instance.StopNav(); Vector2 anchoredPosition = new Vector2(eventData.get_position().x - this.mScreenPositionZero.x, eventData.get_position().y - this.mScreenPositionZero.y); anchoredPosition = new Vector2(anchoredPosition.x * UIConst.ScreenToUISizeScaleWidth, anchoredPosition.y * UIConst.ScreenToUISizeScaleHeight); this.mFlagPoint.set_anchoredPosition(anchoredPosition); Vector3 vector = RadarManager.Instance.MapPosToWorldPosWithRotation(anchoredPosition.x, anchoredPosition.y, RadarManager.size_mapImage_minmap); if (XUtility.GetRoughPathPoint(vector.x, vector.y, RadarManager.Instance.DISTANCE_3D_INSERT, out this.m_rough_paths)) { this.m_spFlagPoint.set_enabled(true); this.SetPathPoints(this.m_rough_paths); RadarManager.Instance.BeginNav(vector.x, vector.y, delegate { RadarManager.Instance.StopNav(); }); this.Show(false); UIStackManager.Instance.PopUIPrevious(base.uiType); } else { UIManagerControl.Instance.ShowToastText("该区域无法到达"); } }
public override bool MoveToSkillTarget(float skillReach) { if (this.GetEntity().AITarget == null) { return(false); } if (!this.GetEntity().AITarget.Actor) { return(false); } float num = XUtility.DistanceNoY(base.FixTransform.get_position(), this.GetEntity().AITarget.Actor.FixTransform.get_position()) - (skillReach + XUtility.GetHitRadius(this.GetEntity().AITarget.Actor.FixTransform)); if (num <= -0.05f) { base.StopMoveToPoint(); return(false); } if (this.CurActionStatus != "run" && !this.CanChangeActionTo("run", true, 0, false) && ActionStatusName.IsSkillAction(this.CurActionStatus) && !this.GetEntity().IsMoveCast&& !base.IsUnderTermination) { return(false); } Vector3 vector = new Vector3(this.GetEntity().AITarget.Actor.FixTransform.get_position().x - base.FixTransform.get_position().x, 0f, this.GetEntity().AITarget.Actor.FixTransform.get_position().z - base.FixTransform.get_position().z); Vector3 normalized = vector.get_normalized(); Vector3 aIMoveFixPoint = base.GetAIMoveFixPoint(base.FixTransform.get_position(), this.GetEntity().AITarget.Actor.FixTransform.get_position(), normalized, num, XUtility.GetHitRadius(base.FixTransform)); this.MoveToPoint(aIMoveFixPoint, 0f, null); this.GetEntity().AIToPoint = new XPoint { position = aIMoveFixPoint }; return(true); }
public static void Init() { if (PreloadUIBaseSystem.mResourcePaths == null) { PreloadUIBaseSystem.preload_uibase_map.Clear(); PreloadUIBaseSystem.mResourcePaths = Utils.ReadFromMemory(XUtility.GetConfigTxt("preload_uibase2json", ".txt")); Debug.Log("===>preloaduibse2json count = " + PreloadUIBaseSystem.mResourcePaths.get_Count()); IEnumerator enumerator = PreloadUIBaseSystem.mResourcePaths.get_Keys().GetEnumerator(); try { while (enumerator.MoveNext()) { object current = enumerator.get_Current(); PreloadUIBaseSystem.preload_uibase_map.set_Item(current.ToString(), PreloadUIBaseSystem.mResourcePaths.get_Item(current).ToString().Split(new char[] { ';' })); } } finally { IDisposable disposable = enumerator as IDisposable; if (disposable != null) { disposable.Dispose(); } } PreloadUIBaseSystem.mResourcePaths.Clear(); } }
protected void MarkWarningMessageByEffect(EntityParent caster, int effectID, XPoint basePoint) { if (basePoint == null) { return; } Effect effect = DataReader <Effect> .Get(effectID); if (effect == null) { return; } if (effect.aiEffectMove != 1) { return; } if (effect.range == null) { return; } if (effect.range.get_Count() < 3) { return; } float casterRadius = 0f; if (caster.Actor) { casterRadius = XUtility.GetHitRadius(caster.Actor.FixTransform); } this.MarkWarningMessage(basePoint.ApplyOffset(effect.offset), effect.range, casterRadius); this.MarkWarningMessage(basePoint.ApplyOffset(effect.offset), effect.range2, casterRadius); }
private string[] GetClientVersion() { return(XUtility.GetConfigTxt("client_version", ".txt").Trim().Split(new char[] { '.' })); }
public static Transform FindWidgetOnUI(int widgetId, bool activeSelf = true) { Transform result = null; string text = WidgetSystem.FindNameOfUIByWidget(widgetId); string[] array = WidgetSystem.FindNameOfWidgetById(widgetId); if (!string.IsNullOrEmpty(text) && array != null && array.Length >= 1) { UIBase uIIfExist = UIManagerControl.Instance.GetUIIfExist(text); if (uIIfExist != null) { if (activeSelf && !uIIfExist.get_gameObject().get_activeSelf()) { return(null); } if (array.Length == 1) { result = WidgetSystem.FindTransformOfuibase(uIIfExist, GameDataUtils.SplitString4Dot0(array[0])); } else if (array.Length == 2) { Transform transform = WidgetSystem.FindTransformOfuibase(uIIfExist, GameDataUtils.SplitString4Dot0(array[0])); if (transform != null) { result = XUtility.RecursiveFindTransform(transform, GameDataUtils.SplitString4Dot0(array[1])); } } } } return(result); }
private void SortDamageCalModelLv3(List <DamageCalModel> list) { for (int i = 0; i < list.get_Count(); i++) { DamageCalModel damageCalModel = list.get_Item(i); for (int j = 0; j < damageCalModel.listChildren.get_Count() - 1; j++) { DamageCalModel damageCalModel2 = damageCalModel.listChildren.get_Item(j); for (int k = 0; k < damageCalModel2.listChildren.get_Count(); k++) { int num = k; for (int l = k + 1; l < damageCalModel2.listChildren.get_Count(); l++) { DamageCalModel damageCalModel3 = damageCalModel2.listChildren.get_Item(num); DamageCalModel damageCalModel4 = damageCalModel2.listChildren.get_Item(l); if (damageCalModel3.total < damageCalModel4.total) { num = l; } } if (num != k) { XUtility.ListExchange <DamageCalModel>(damageCalModel2.listChildren, num, k); } } } } }
protected void Follow() { if (!this.FixNavAgent) { return; } if (!this.IsFollowing) { this.IsFollowing = this.FixNavAgent.Warp(this.FixTransform.get_position()); this.FixNavAgent.set_enabled(true); this.FixNavAgent.set_speed(this.RealMoveSpeed); this.FixNavAgent.set_updatePosition(true); this.FixNavAgent.set_updateRotation(true); this.FixNavAgent.set_angularSpeed(1080f); if (this.IsFollowing && !XUtility.StartsWith(this.CurActionStatus, "run")) { this.CastAction("run"); } } if (this.IsFollowing) { this.FixNavAgent.SetDestination(this.Entity.Owner.Actor.FixTransform.get_position()); this.FixNavAgent.Resume(); } }
private Vector2 RotationAngle(Vector2 position, bool negative) { if (negative) { return(XUtility.RotationAngle(position, -RadarManager.map3d_angle)); } return(XUtility.RotationAngle(position, RadarManager.map3d_angle)); }
public static List <GameObject> RecursiveFindGameObjects(GameObject root, string[] names) { if (root == null) { return(null); } return(XUtility.RecursiveFindGameObjects(root.get_transform(), names)); }
public static GameObject RecursiveFindGameObject(GameObject root, string name) { if (root == null) { return(null); } return(XUtility.RecursiveFindGameObject(root.get_transform(), name)); }
public override void OnActionStatusExit(ActionStatusExitCmd cmd) { if (XUtility.StartsWith(cmd.actName, string.Empty)) { return; } this.UpdateActionSpeed(); }
public static void Init() { if (FileSystem.mResourcePaths == null) { FileSystem.mResourcePaths = Utils.ReadFromMemory(XUtility.GetConfigTxt("resources2json", ".txt")); } Debug.Log("===>resources2json count = " + FileSystem.mResourcePaths.get_Count()); }
public virtual bool CheckAttackRange() { if (AttackTarget != null && CurSkill != null && XUtility.DistanceNoY(AttackTarget.transform.position - transform.position) <= CurSkill.Attr.AttackDist) { return(true); } return(false); }
public static bool GetTerrainPoint(float x, float z, float curHeight, out Vector3 result) { if (!MySceneManager.Instance.IsSceneExist) { result = new Vector3(x, curHeight, z); return(false); } return(XUtility.GetTerrainPoint(x, z, curHeight, out result)); }
/// <summary> /// Loads the script. /// </summary> /// <returns>The script.</returns> /// <param name="fn">Fn.</param> public static byte[] LoadScript(string fn, ref string str) { fn = fn.Replace(".", "/"); #if UNITY_STANDALONE || UNITY_EDITOR XBufferAsset asset = ScriptableObject.CreateInstance <XBufferAsset>(); // find config source code string filePath = System.IO.Path.Combine(Application.dataPath, string.Format("Config/{0}.lua", fn)); if (!System.IO.File.Exists(filePath)) { // find logic script filePath = System.IO.Path.Combine(Application.dataPath, string.Format("Code/Script/{0}.lua", fn)); if (!System.IO.File.Exists(filePath)) { string bytefn = fn.Replace("/", "@").ToLower(); // find lua byte code filePath = System.IO.Path.Combine(Application.dataPath, string.Format("Bytecode/{0}/{1}.bytes", platformPath, bytefn)); } } #if !RELEASE GLog.Log(string.Format("{0}", filePath)); #endif if (System.IO.File.Exists(filePath)) { System.IO.FileStream fs = System.IO.File.OpenRead(filePath); asset.init((int)fs.Length); fs.Read(asset.bytes, 0, (int)fs.Length); fs.Close(); return(asset.bytes); } else { Debug.LogError("can't find file : " + filePath); } #else string bytefn = fn.Replace("/", "@").ToLower(); string hashfn = XUtility.Md5Sum(string.Format("{0}/{1}", platformPath, bytefn)); XBufferAsset asset = XBytecodeFilePicker.LoadBytecodeAsset(string.Format("bytecode/{0}", hashfn)); if (asset != null) { return(asset.bytes); } else { Debug.LogError("Can't load bytecode " + platformPath + " " + bytefn); } #endif return(null); }
public void ClientAssault(long targetID, int skillID, Vector3 endPosition) { this.assaultTargetID = targetID; this.assaultEndSkillID = skillID; this.assaultEndSkillDistance = ((DataReader <Skill> .Get(this.assaultEndSkillID).reach == null || DataReader <Skill> .Get(this.assaultEndSkillID).reach.get_Count() <= 1) ? 0.05f : ((float)DataReader <Skill> .Get(this.assaultEndSkillID).reach.get_Item(0) * 0.01f)); this.assaultEndPos = endPosition; this.assaultSpeed = base.OriginAssaultSpeed * base.LogicMoveSpeed / base.ModelOriginSpeed; this.assaultTime = XUtility.DistanceNoY(base.FixTransform.get_position(), endPosition) / this.assaultSpeed; this.ChangeAction("rush", false, true, 1f, 0, 0, string.Empty); }
public static GameObject RecursiveFindGameObject(Transform root, string name) { Transform transform = XUtility.RecursiveFindTransform(root.get_transform(), name); if (transform != null) { return(transform.get_gameObject()); } return(null); }
public static Transform FindTransformOfuibase(UIBase uiBase, string widgetName) { Transform transform = uiBase.FindTransform(widgetName); if (transform != null) { return(transform); } return(XUtility.RecursiveFindTransform(uiBase.get_transform(), widgetName)); }
private bool DealKeyPathPoint(Vector3 pre_point, Vector3 current_point) { float num = XUtility.DistanceNoY(pre_point, current_point); if (num < RadarManager.Instance.DISTANCE_3D_MIN) { return(false); } this.InstantiatePathPoint(current_point); return(true); }