public override void AttackEventA(int Phase) { List <List <ZDObject> > AllHitObject = new List <List <ZDObject> >(); // Really do attack switch (Phase) { case 0: AllHitObject.Add(ZDMap.HitAt(ZDGameRule.RotateVector2(new Vector2(1, 1), AttackRad), this, EObjectType.ADamage)); AllHitObject.Add(ZDMap.HitAt(ZDGameRule.RotateVector2(new Vector2(1, -1), AttackRad), this, EObjectType.ADamage)); AllHitObject.Add(ZDMap.HitAt(ZDGameRule.RotateVector2(new Vector2(-1, 1), AttackRad), this, EObjectType.ADamage)); AllHitObject.Add(ZDMap.HitAt(ZDGameRule.RotateVector2(new Vector2(-1, -1), AttackRad), this, EObjectType.ADamage)); break; case 1: AllHitObject.Add(ZDMap.HitAt(ZDGameRule.RotateVector2(new Vector2(1, 1), AttackRad), this, EObjectType.ADamage)); AllHitObject.Add(ZDMap.HitAt(ZDGameRule.RotateVector2(new Vector2(1, -1), AttackRad), this, EObjectType.ADamage)); AllHitObject.Add(ZDMap.HitAt(ZDGameRule.RotateVector2(new Vector2(-1, 1), AttackRad), this, EObjectType.ADamage)); AllHitObject.Add(ZDMap.HitAt(ZDGameRule.RotateVector2(new Vector2(-1, -1), AttackRad), this, EObjectType.ADamage)); AllHitObject.Add(ZDMap.HitAt(ZDGameRule.RotateVector2(new Vector2(2, 2), AttackRad), this, EObjectType.ADamage)); AllHitObject.Add(ZDMap.HitAt(ZDGameRule.RotateVector2(new Vector2(2, -2), AttackRad), this, EObjectType.ADamage)); AllHitObject.Add(ZDMap.HitAt(ZDGameRule.RotateVector2(new Vector2(-2, 2), AttackRad), this, EObjectType.ADamage)); AllHitObject.Add(ZDMap.HitAt(ZDGameRule.RotateVector2(new Vector2(-2, -2), AttackRad), this, EObjectType.ADamage)); break; } ApplyDamage(AllHitObject, EAttackType.A); }
public override void AttackEventB(int Phase) { List <List <ZDObject> > AllHitObject = new List <List <ZDObject> >(); // Really do attack switch (Phase) { case 0: AllHitObject.Add(ZDMap.HitAt(new Vector2(1, 0), this, EObjectType.ADamage)); AllHitObject.Add(ZDMap.HitAt(new Vector2(2, 0), this, EObjectType.ADamage)); AllHitObject.Add(ZDMap.HitAt(new Vector2(-1, 0), this, EObjectType.ADamage)); AllHitObject.Add(ZDMap.HitAt(new Vector2(-2, 0), this, EObjectType.ADamage)); AllHitObject.Add(ZDMap.HitAt(new Vector2(0, 1), this, EObjectType.ADamage)); AllHitObject.Add(ZDMap.HitAt(new Vector2(0, -1), this, EObjectType.ADamage)); break; case 1: AllHitObject.Add(ZDMap.HitAt(new Vector2(0, 2), this, EObjectType.ADamage)); AllHitObject.Add(ZDMap.HitAt(new Vector2(0, -2), this, EObjectType.ADamage)); AllHitObject.Add(ZDMap.HitAt(new Vector2(3, 0), this, EObjectType.ADamage)); AllHitObject.Add(ZDMap.HitAt(new Vector2(3, 1), this, EObjectType.ADamage)); AllHitObject.Add(ZDMap.HitAt(new Vector2(3, -1), this, EObjectType.ADamage)); AllHitObject.Add(ZDMap.HitAt(new Vector2(-3, 0), this, EObjectType.ADamage)); AllHitObject.Add(ZDMap.HitAt(new Vector2(-3, 1), this, EObjectType.ADamage)); AllHitObject.Add(ZDMap.HitAt(new Vector2(-3, -1), this, EObjectType.ADamage)); break; } ApplyDamage(AllHitObject, EAttackType.B); }
Vector2 GetValidDest(Vector2 Destination) { Vector2 PosInUnit = ZDGameRule.WorldToUnit(transform.position); Vector2 DesInUnit = ZDGameRule.WorldToUnit(ZDGameRule.QuadrifyDirection(Destination, transform.position)); for (int i = 0; i < 2; ++i) { if (!PosInUnit[i].Equals(DesInUnit[i])) { int Delta = (PosInUnit[i] < DesInUnit[i] ? 1 : -1); Vector2 CurPos = PosInUnit; while (true) { //Move To Currently Checking Position. CurPos[i] += Delta; if (!ZDMap.IsUnitInMap(CurPos) || ZDMap.HitAtUnit(CurPos, EObjectType.Obstacle) != null) { //Return To Last Position. CurPos[i] -= Delta; return(ZDGameRule.UnitToWorld(CurPos)); } if (CurPos[i].Equals(DesInUnit[i])) { break; } } return(ZDGameRule.UnitToWorld(DesInUnit)); } } return(transform.position); }
IEnumerator AttackingR() { if (!Ulting) { Ulting = true; while (Ulting && (animator.GetCurrentAnimatorStateInfo(0).IsName("AttackR_Loop") || animator.GetCurrentAnimatorStateInfo(0).IsName("AttackR_Start"))) { yield return(new WaitForSeconds(0.33f)); List <List <ZDObject> > AllHitObject = new List <List <ZDObject> >(); AllHitObject.Add(ZDMap.HitAt(new Vector2(0, 1), this, EObjectType.ADamage)); AllHitObject.Add(ZDMap.HitAt(new Vector2(0, -1), this, EObjectType.ADamage)); AllHitObject.Add(ZDMap.HitAt(new Vector2(1, 0), this, EObjectType.ADamage)); AllHitObject.Add(ZDMap.HitAt(new Vector2(-1, 0), this, EObjectType.ADamage)); AllHitObject.Add(ZDMap.HitAt(new Vector2(1, 1), this, EObjectType.ADamage)); AllHitObject.Add(ZDMap.HitAt(new Vector2(1, -1), this, EObjectType.ADamage)); AllHitObject.Add(ZDMap.HitAt(new Vector2(-1, 1), this, EObjectType.ADamage)); AllHitObject.Add(ZDMap.HitAt(new Vector2(-1, -1), this, EObjectType.ADamage)); ApplyDamage(AllHitObject, EAttackType.R); } Ulting = false; } }
void OnDestroy() { if (Instance == this) { Instance = null; ZDMap.ResetMap(); } }
void AttackInPosition(float Damage) { Vector3 UnitPos = ZDGameRule.WorldToUnit(transform.position); List <ZDObject> HitList = ZDMap.HitAtUnit(UnitPos, EObjectType.ADamage); if (HitList != null) { foreach (var obj in HitList) { ((IADamageObject)obj).Hurt(Damage); } } }
protected void Start() { InitializeTerrain(); ZDMap.Register(this); if (!IsRegistered()) { Debug.LogError("Error! Cannot Register ZDObject, Object Out of Bound!"); } //Cache ActorTypeDepth ActorTypeDepth = ZDGameRule.ActorDepth(ActorType) + ActorCustomDepthShift; //Forced Update to set object depth with type depth; SetActorDepth(); }
protected void FixedUpdate() { uint NewCount = 0; List <ZDObject> FetchList = ZDMap.HitAtObject(this, EObjectType.Character); if (FetchList != null) { NewCount = (uint)FetchList.Count; } else { NewCount = 0; } if (NewCount != InGrassCount) { GrassChangeEffect(); InGrassCount = NewCount; } }
protected void Update() { if (transform.hasChanged) { if (ZDMap.UpdateLocation(this)) { //Update Z axis to correct the in block layers. SetActorDepth(); Vector3 NewUnitLocation = ZDGameRule.WorldToUnit(transform.position); LocationChanged?.Invoke(this, new LocationChangeArgs(new Vector2Int((int)NewUnitLocation.x, (int)NewUnitLocation.y))); if (InShelter != (ZDMap.HitAtObject(this, EObjectType.Shelter) != null)) { InShelter = !InShelter; ShelterStateChanged?.Invoke(this, new ShelterStateChangeArgs(InShelter)); } } transform.hasChanged = false; } }
void AttackEvent(int eventNum) { //Initial Values Vector2Int[] HitOffsets = { new Vector2Int(0, 0) }; float HitDamage = 0; Vector2 HitOrigin = ZDGameRule.WorldToUnit(transform.position); if (eventNum < AttackDamages.Length) { HitDamage = AttackDamages[eventNum]; } if (HitOffsetsConfig != null && eventNum < HitOffsetsConfig.Length) { HitOffsets = HitOffsetsConfig[eventNum]; } List <ZDObject> HitList = new List <ZDObject>(); //Get Hitten Objects foreach (var offset in HitOffsets) { Vector2 HitPos = offset + HitOrigin; List <ZDObject> HitResult = ZDMap.HitAtUnit(HitPos, EObjectType.ADamage); if (HitResult != null) { HitList.AddRange(HitResult); } } //Apply Damages if (!HitDamage.Equals(0)) { foreach (var obj in HitList) { ((IADamageObject)obj).Hurt(HitDamage); } } }
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 } } }
public virtual void Broken() { ZDMap.UnRegister(this); }
public bool IsRegistered() { return(ZDMap.IsRegistered(this)); }
protected void OnDestroy() { ZDMap.UnRegister(this); }