/// <summary> /// 효과받는 타일을 구해서 effectedAreas에 Add /// </summary> /// <param name="mainTarget">효과범위의 중심이 되는 Actor</param> protected void GetArea(ICombatant mainTarget) { TileLayer tileLayer = GameManager.Instance.GetTileLayer(0); TileForMove mainTargetPos = mainTarget.GetCurTileForMove(); effectedAreas.Clear(); CentralAxis centralAxis = GetCentralAxis(owner.GetCurTileForMove(), mainTarget.GetCurTileForMove()); switch (centralAxis) { case CentralAxis.Y: foreach (Coverage item in coverages) { effectedAreas.Add(tileLayer.GetTileForMove(mainTargetPos.GetX() + item.x, mainTargetPos.GetY() + item.y)); } break; case CentralAxis.InverseY: foreach (Coverage item in coverages) { effectedAreas.Add(tileLayer.GetTileForMove(mainTargetPos.GetX() - item.x, mainTargetPos.GetY() - item.y)); } break; case CentralAxis.X: foreach (Coverage item in coverages) { effectedAreas.Add(tileLayer.GetTileForMove(mainTargetPos.GetX() + item.y, mainTargetPos.GetY() + item.x)); } break; case CentralAxis.InverseX: foreach (Coverage item in coverages) { effectedAreas.Add(tileLayer.GetTileForMove(mainTargetPos.GetX() - item.y, mainTargetPos.GetY() - item.x)); } break; } }
protected virtual IEnumerator Charge(List <TileForMove> tileForMoveWay) { Direction dir = Direction.DownLeft; Vector3 dirVector; float distance, sum = 0.0f; int walkCnt = 0; const int posCheckRate = 4; #if DEBUG_CHARGE Debug.Log("적: " + enemy + ", 목적지: " + destinationTile); #endif // 적이 이미 누웠거나, 사냥터에서 나갔다면 if (!ValidatingEnemy(enemy)) { curState = State.AfterBattle; yield break; } // 레인지 검사. 적이 공격 범위 안으로 들어왔을 때. if (CheckInRange()) { curState = State.Battle; yield break; } // PathFinder에서 받은 경로대로 이동 for (int i = 0; i < tileForMoveWay.Count - 1; i++) { // 방향에 따른 애니메이션 설정. SetAnimDirection(tileForMoveWay[i].GetDirectionFromOtherTileForMove(tileForMoveWay[i + 1])); // 이동 dirVector = tileForMoveWay[i + 1].GetPosition() - tileForMoveWay[i].GetPosition(); distance = Vector3.Distance(tileForMoveWay[i].GetPosition(), tileForMoveWay[i + 1].GetPosition()); while (Vector3.Distance(transform.position, tileForMoveWay[i].GetPosition()) < distance / 2) { yield return(null); transform.Translate(dirVector * Time.deltaTime); } // 절반 넘어가면 다음 타일로 위치지정해줌. SetCurTile(tileForMoveWay[i + 1].GetParent()); SetCurTileForMove(tileForMoveWay[i + 1]); while (Vector3.Distance(transform.position, tileForMoveWay[i].GetPosition()) < distance) { yield return(null); transform.Translate(dirVector * Time.deltaTime); } sum = 0.0f; transform.position = tileForMoveWay[i + 1].GetPosition(); // 적이 이미 누웠거나, 사냥터에서 나갔다면 if (!ValidatingEnemy(enemy)) { curState = State.AfterBattle; yield break; } // 레인지 검사. 적이 공격 범위 안으로 들어왔을 때. if (CheckInRange()) { curState = State.Battle; yield break; } walkCnt++; if (walkCnt % posCheckRate == 0 && destinationTileForMove != enemy.GetCurTileForMove()) { break; } } SetDestinationTowardEnemy(); curState = State.PathFinding; }