protected override void Sprint(Vector2 Destination) { base.Sprint(Destination); if (photonView.IsMine && TrackAvailable) { float SprintAngle = ZDGameRule.QuadAngle(SprintDestination - (Vector2)transform.position); if (TrackAngles[0].Equals(SprintAngle)) { TrackFullFilled(); } } }
private void SpawnNewTrackMission() { if (GetSoul() < GetMaxSoul()) { TrackAvailable = true; TrackDurationTime = (GetMaxSoul() - GetSoul()) * ZDGameRule.CrossTrack.TrackDurationConst; TrackRemainTime = TrackDurationTime; TrackAngles.Clear(); for (int i = 0, _i = (int)Mathf.Pow(ZDGameRule.CrossTrack.TrackCountsConst, GetSoul() + 1); i < _i; ++i) { TrackAngles.Add(ZDGameRule.QuadAngle(Random.Range(0, 359))); } TrackInfoChanged?.Invoke(this, new TrackInfoChangeArgs(TrackAvailable, TrackAngles[0])); } }
void Update() { if (ZDGameManager.GetGameState() == ZDGameState.Play) { if (IsPhoneTest) { #region Touch Input for Single Touch if (Input.touchCount == 1 && !EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId)) { if (BagClass.GetFrameBlock()) { BagClass.SetBlockFrame(false); return; } Touch TouchTemp = Input.GetTouch(0); // TouchPos is world Position Vector2 TouchPos = Camera.main.ScreenToWorldPoint(TouchTemp.position); // UnitTouchPos is Unit Position Vector2 UnitTouchPos = ZDGameRule.WorldToUnit(TouchPos); Vector2 CharactorPos = new Vector2(TargetCharacter.transform.position.x, TargetCharacter.transform.position.y); List <ZDObject> HitObjects; if (IsMovingCharacter) { Vector2 Direction = TouchPos - CharactorPos; float Degree = ZDGameRule.QuadAngle(Direction); Vector3 Distance = ZDGameRule.WorldToUnit(TouchPos) - ZDGameRule.WorldToUnit(CharactorPos); ZDUIClass.SetMoveIndicator(TargetCharacter.transform.position, Degree, Distance.magnitude); } if (TouchTemp.phase == TouchPhase.Began) { if ((TouchPos - (Vector2)TargetCharacter.transform.position).magnitude < ZDGameRule.UNIT_IN_WORLD * ClickOnFix) { IsMovingCharacter = true; return; } else if ((HitObjects = ZDMap.HitAtUnit(UnitTouchPos, EObjectType.ACollect)) != null) { List <ZDObject> HitCharacter = ZDMap.HitAtUnit(UnitTouchPos, EObjectType.Character); if (HitCharacter != null) { return; } foreach (var obj in HitObjects) { if (obj is IACollectObject) { if (TargetCharacter.GetInventory().Count < TargetCharacter.GetInventoryMax()) { ((IACollectObject)obj).Collect(TargetCharacter); IsCollectItem = true; } else { break; } } } return; } else { // Activate Attack System IsMovingCharacter = false; if ((HitObjects = ZDMap.HitAtUnit(UnitTouchPos, EObjectType.ACollect)) == null && !BagClass.GetHover()) { IsSelectingAttack = true; TouchPosRecord = TouchPos; } } } else if (TouchTemp.phase == TouchPhase.Moved || TouchTemp.phase == TouchPhase.Stationary) { IsDidMovePhase = true; } else if (TouchTemp.phase == TouchPhase.Ended) { ZDUIClass.CancelMoveIndicator(); if (IsCollectItem) { IsCollectItem = false; return; } // DoMove if ((TouchTemp.deltaPosition.magnitude >= TouchMoveFix) && IsDidMovePhase) { IsTouchMove = true; } else { IsTouchMove = false; } if (IsMovingCharacter && IsTouchMove) { TargetCharacter.InputSprint(TouchPos); IsTouchMove = false; IsMovingCharacter = false; IsDidMovePhase = false; return; } else if (IsSelectingAttack) { IsSelectingAttack = false; Vector2 TouchDelta = TouchPos - TouchPosRecord; // Tap Normal Attack or Slide Skill Attack if (TouchDelta.magnitude < TapOrSlide) // This Distance is to judge how is "Tap" { TargetCharacter.InputAttack(TouchPos - (Vector2)TargetCharacter.transform.position, EAttackType.N); } else { TargetCharacter.InputAttack(TouchDelta, EAttackType.Skill); } } } } #endregion } } }