Exemple #1
0
 public void Reset()
 {
     ActiveSpace = Enums.ActiveSpace.Inactive;
     GridStart   = null;
     AttackSpace?.Disable();
     MoveSpace?.Disable();
     MoveDistance      = -1;
     MinAttackDistance = -1;
     MaxAttackDistance = -1;
 }
 public void ClearSuggestedMoves()
 {
     for (int i = 0; i < levelTransform.childCount; i++)
     {
         Transform tf = levelTransform.GetChild(i);
         if (tf != null)
         {
             MoveSpace space = tf.GetComponent <MoveSpace>();
             if (space != null)
             {
                 space.hasSuggestedMove = false;
             }
         }
     }
 }
    public bool Blocked(int x0, int y0, int x1, int y1)
    {
        MoveSpace space0 = getGrid(x0, y0);
        MoveSpace space1 = getGrid(x1, y1);
        int       dirx   = x1 - x0;
        int       diry   = y1 - y0;

        Debug.Log("here0" + space0);
        Debug.Log("here1" + space1);

        if (space0 == null || space1 == null)
        {
            return(true);
        }
        if (dirx > 0)
        {
            // right
            Debug.Log("right");
            return(space0.moveSpaceType == SpaceType.WallRight || space1.moveSpaceType == SpaceType.WallLeft || space1.moveSpaceType == SpaceType.WallTopLeft);
        }
        if (dirx < 0)
        {
            // left
            Debug.Log("left");
            return(space0.moveSpaceType == SpaceType.WallLeft || space1.moveSpaceType == SpaceType.WallRight || space0.moveSpaceType == SpaceType.WallTopLeft);
        }
        if (diry > 0)
        {
            //2019-04-28 3:08 PM - if I flip down/up it fixes one bug and surfaces a different one.

            // down
            Debug.Log("down");
            return(space0.moveSpaceType == SpaceType.WallTop || space1.moveSpaceType == SpaceType.WallBottom || space0.moveSpaceType == SpaceType.WallTopLeft);
        }
        if (diry < 0)
        {
            // up
            Debug.Log("up");
            return(space0.moveSpaceType == SpaceType.WallBottom || space1.moveSpaceType == SpaceType.WallTop || space1.moveSpaceType == SpaceType.WallTopLeft);
        }
        return(false);
    }
    void HighlightClickables(AbilityType at)
    {
        Debug.Log(at);

        // clear suggested moves
        //GameObject.FindObjectOfType<LevelViewController>().ClearSuggestedMoves();

        // highlight by type
        //if (at == AbilityType.Basic)
        if (false)
        {
            int[,] offsets = new int[, ] {
                { -1, 0 }, { 0, -1 }, { 1, 0 }, { 0, 1 }
            };
            Debug.Log(player.posX + "," + player.posY);
            for (int i = 0; i < 4; i++)
            {
                MoveSpace space = getGrid(offsets[i, 0] + player.posX, offsets[i, 1] + player.posY);
                int       nx    = player.posX;
                int       ny    = player.posY;
                if (space != null && !Blocked(nx, ny, nx + offsets[i, 0], ny + offsets[i, 1]))
                {
                    space.hasSuggestedMove = true;
                    space.wineLoss         = 1;
                }
            }
        }
        if (at == AbilityType.Dash)
        {
            int[,] offsets = new int[, ] {
                { -1, 0 }, { 0, -1 }, { 1, 0 }, { 0, 1 }
            };
            Debug.Log(player.posX + "," + player.posY);
            for (int i = 0; i < 4; i++)
            {
                int       nx  = player.posX;
                int       ny  = player.posY;
                MoveSpace ans = null;
                while (!Blocked(nx, ny, nx + offsets[i, 0], ny + offsets[i, 1]))
                {
                    nx += offsets[i, 0];
                    ny += offsets[i, 1];
                    ans = getGrid(nx, ny);
                }
                if (ans != null)
                {
                    ans.hasSuggestedMove = true;
                    ans.wineLoss         = dashLoss;
                }
            }
        }
        else if (at == AbilityType.Diagonal)
        {
            int[,] offsets = new int[, ] {
                { -1, -1 }, { 1, -1 }, { 1, 1 }, { -1, 1 }
            };
            Debug.Log(player.posX + "," + player.posY);
            for (int i = 0; i < 4; i++)
            {
                int       nx0   = player.posX;
                int       ny0   = player.posY;
                int       nx1   = offsets[i, 0] + player.posX;
                int       ny1   = offsets[i, 1] + player.posY;
                MoveSpace space = getGrid(nx1, ny1);
                if (space != null && ((!Blocked(nx0, ny0, nx1, ny0) && !Blocked(nx1, ny0, nx1, ny1)) || (!Blocked(nx0, ny0, nx0, ny1) && !Blocked(nx0, ny1, nx1, ny1))))
                {
                    space.hasSuggestedMove = true;
                    space.wineLoss         = diagLoss;
                }
            }
        }
    }