コード例 #1
0
ファイル: HexGrid.cs プロジェクト: KirylShakh/cosmictactics
    public void ClearHighlighting()
    {
        foreach (HexCell pathCell in highlightedPath)
        {
            pathCell.ClearHighlighting(false);
        }
        if (highlightedPath.Count > 0 && highlightedPath[0].Equals(selectedCell))
        {
            selectedCell.Select();
        }

        if (highlightedCell)
        {
            highlightedCell.ClearHighlighting(highlightedCell.Equals(selectedCell));
        }
    }
コード例 #2
0
    public HexDirection GetDirectionNeighbor(HexCell otherCell)
    {
        HexDirection d = HexDirection.NE;

        for (; d <= HexDirection.NW; d++)
        {
            HexCell neighbor = GetNeighbor(d);
            if (neighbor == null)
            {
                continue;
            }
            else if (neighbor.Equals(otherCell))
            {
                return(d);
            }
        }
        return(d);
    }
コード例 #3
0
    public override void HandleMovement()
    {
        if (targetCell == null || targetCell.Equals(currentCell))
        {
            return;
        }

        float speed       = 50f;
        float distCovered = (Time.time - startMoveTime) * speed;
        float fracJourney = distCovered / (HexMetrics.innerRadius * 2);


        Vector3 start = transform.position;
        Vector3 end   = targetCell.transform.position + raiseVector;

        if (PlayerController.GetCurrentCell().Equals(targetCell))
        {
            end = new Vector3(end.x + HexMetrics.innerRadius / 2, end.y, end.z);
            anim.SetTrigger("die");
        }
        transform.position = Vector3.Lerp(start, end, fracJourney);


        if (Vector3.Distance(transform.position, end) < Vector3.Distance(start, end) * 0.05)
        {
            currentCell = targetCell;

            if ((grid as LevelGrid).GetCellType(currentCell) == "fire")
            {
                targetCell    = grid.GetAdjacentCell(currentCell, ReverseDirection(lastMove));
                startMoveTime = Time.time;
            }
            transform.position = end;
            isMoving           = false;
        }


        Quaternion newRot = Quaternion.LookRotation(end - transform.position);

        transform.rotation = Quaternion.Lerp(transform.rotation, newRot, 5f * Time.deltaTime);
    }