/// <summary> /// 当前容器内只展示哪一类物品列表 by吴江 /// </summary> /// <param name="_type"></param> protected void FliterItems(FilterType _type) { switch (_type) { case FilterType.ALL: GridMgr.gridFilter = FilterAll; break; case FilterType.Equip: GridMgr.gridFilter = FilterEquip; break; case FilterType.Consumables: GridMgr.gridFilter = FilterConsumables; break; case FilterType.Others: GridMgr.gridFilter = FilterOthers; break; default: break; } GridMgr.Reposition(); if (lastFilterType != _type) { lastFilterType = _type; ToTop(); } }
public void TakeDamage(int damage) { currHealth = Mathf.Clamp(currHealth - damage, 0, maxHealth); UpdateHealthBar(); if (currHealth <= 0) { // 죽는 로직 status = STATUS.DEAD; animState.ChangeAnimState(3); GetComponent <Collider2D>().enabled = false; // grid blinking cancel List <Grid> gridsToCancelBlinking = new List <Grid>(); switch (code) { case "P0": GridMgr.PawnMoveOnGrid(GetComponent <FriendlyPieceMover>().currGrid, out gridsToCancelBlinking); break; case "K0": GridMgr.KnightMoveOnGrid(GetComponent <FriendlyPieceMover>().currGrid, out gridsToCancelBlinking); break; case "R0": GridMgr.RookMoveOnGrid(GetComponent <FriendlyPieceMover>().currGrid, out gridsToCancelBlinking); break; default: break; } if (gridsToCancelBlinking.Count > 0) { foreach (var grid in gridsToCancelBlinking) { grid.isBlinking = false; } } } else if (currHealth / (float)maxHealth <= 0.3f) { // 30% 이하일 경우 기물의 모습이 변함. status = STATUS.BAD; if (doesHealthStateChangeSprite) { SetColor(true); } // Pawn Exception if (code == "P0") { FeatherDisplayHandle(); } } }
private void Update() { if (isMovingModeOfThisPiece_next != isMovingModeOfThisPiece) { if (isMovingModeOfThisPiece_next && !isMovingModeOfThisPiece) // {???}Mode -> MovingMode { isMovingModeOfThisPiece = isMovingModeOfThisPiece_next; // 이동 가능한 grid들을 구하고 switch (GetComponent <Health>().code) { case "P0": GridMgr.PawnMoveOnGrid(currGrid, out blinkingGrid); break; case "K0": GridMgr.KnightMoveOnGrid(currGrid, out blinkingGrid); break; case "R0": GridMgr.RookMoveOnGrid(currGrid, out blinkingGrid); break; default: break; } // 갈수 있는 grid가 없을경우 if (blinkingGrid.Count == 0) { pointerMgr.selectedMovingPiece = null; isMovingModeOfThisPiece_next = false; pointerMgr.PointerMode = PointerMgr.Mode.None; } // grid들을 blinking foreach (var grid in blinkingGrid) { grid.isBlinking = true; } } else if (!isMovingModeOfThisPiece_next && isMovingModeOfThisPiece) // MovingMode -> {???}Mode { isMovingModeOfThisPiece = isMovingModeOfThisPiece_next; foreach (var grid in blinkingGrid) { grid.isBlinking = false; } blinkingGrid.Clear(); } myAnim.SetBool("MovingBlinking", isMovingModeOfThisPiece); } }
private void Start() { row = GetComponentInParent <Row>(); rowIdx = row.rowIdx; myCollider = GetComponent <Collider2D>(); myAnim = GetComponent <Animator>(); gridMgr = FindObjectOfType <GridMgr>(); GridMgr.grids[rowIdx, colIdx] = this; }
private void Start() { Vector2 myPosition = transform.position; Vector2 targetPos = myPosition; float minSqDist = float.MaxValue; // Find the closest square that the target is on Vector2[] objectPositions = GridMgr.GetPositionsFromObject(Target); if (objectPositions != null) { for (int i = 0; i < objectPositions.Length; ++i) { float sqDist = (objectPositions[i] - myPosition).sqrMagnitude; if (sqDist < minSqDist) { minSqDist = sqDist; targetPos = objectPositions[i]; } } } _agent.SetEndTarget(targetPos); }
private void init() { m_GridMgr = null; }