Пример #1
0
    public void Hook(GamePawn user, GamePawn target, Direction dir)
    {
        Tile     hookTile = target.GetTile().GetNeighbours(dir);
        Sequence s        = DOTween.Sequence();

        GameObject.Instantiate(anchor, user.transform.position + Vector3.up, Quaternion.identity);

        s.Append(anchor.transform.DOMove(target.transform.position + Vector3.up, .3f))
        .SetEase(Ease.Linear);

        //Play vertical Anim
        s.Append(target.transform.DOMove(hookTile.transform.position + new Vector3(0, hookTile.transform.localScale.y, 0), 0.3f)
                 .SetEase(Ease.Linear)
                 .OnComplete(() =>
        {
            target.GetTile().SetPawnOnTile(null);
            target.SetTile(hookTile);
        }));


        s.OnComplete(() =>
        {
            user.EndAction();
        });
    }
Пример #2
0
    public override Direction GetDirection(GamePawn user, GamePawn selectedPawn)
    {
        //UP
        Tile currentTile = user.GetTile().neighbours.up;

        if (IsAvailableTile(currentTile, selectedPawn))
        {
            return(Direction.Up);
        }

        //RIGHT
        currentTile = user.GetTile().neighbours.right;
        if (IsAvailableTile(currentTile, selectedPawn))
        {
            return(Direction.Right);
        }

        //DOWN
        currentTile = user.GetTile().neighbours.down;
        if (IsAvailableTile(currentTile, selectedPawn))
        {
            return(Direction.Down);
        }

        //LEFT
        currentTile = user.GetTile().neighbours.left;
        if (IsAvailableTile(currentTile, selectedPawn))
        {
            return(Direction.Left);
        }
        return(Direction.Up);
    }
Пример #3
0
    public void PreviewPawnPath(GamePawn user, GamePawn selectedPawn)
    {
        Direction dir = GetDirection(user, selectedPawn);

        List <Tile> tilesToHighlight = new List <Tile>();

        if (selectedPawn is Barrel)
        {
            tilesToHighlight = GridManager.instance.GetLineUntilObstacle(dir, selectedPawn.GetTile());
        }
        else if (selectedPawn is EnemieBehaviour || selectedPawn is Box)
        {
            Tile tileToCheck;
            switch (dir)
            {
            case Direction.Up:
                tileToCheck = selectedPawn.GetTile().neighbours.up;
                if (tileToCheck != null && !(tileToCheck is Wall) && !(tileToCheck is Water))
                {
                    tilesToHighlight.Add(tileToCheck);
                }
                break;

            case Direction.Right:
                tileToCheck = selectedPawn.GetTile().neighbours.right;
                if (tileToCheck != null && !(tileToCheck is Wall) && !(tileToCheck is Water))
                {
                    tilesToHighlight.Add(tileToCheck);
                }
                break;

            case Direction.Down:
                tileToCheck = selectedPawn.GetTile().neighbours.down;
                if (tileToCheck != null && !(tileToCheck is Wall) && !(tileToCheck is Water))
                {
                    tilesToHighlight.Add(tileToCheck);
                }
                break;

            case Direction.Left:
                tileToCheck = selectedPawn.GetTile().neighbours.left;
                if (tileToCheck != null && !(tileToCheck is Wall) && !(tileToCheck is Water))
                {
                    tilesToHighlight.Add(tileToCheck);
                }
                break;
            }
        }
        PlayerManager.instance.SetHighlightID(Highlight_Manager.instance.ShowHighlight(tilesToHighlight, HighlightMode.ActionPreview));
        if (tilesToHighlight.Count > 0)
        {
            tilesToHighlight[tilesToHighlight.Count - 1].ActivateHighlight(HighlightMode.ActionHighlight);
        }
    }
Пример #4
0
    public void ThrowPreview(GamePawn user, GamePawn liftedPawn)
    {
        GridManager.instance.AllTilesBecameNotClickable();
        List <Tile> tilesToHighlight = new List <Tile>();
        Tile        playerTile       = user.GetTile();

        if (liftedPawn is EnemieBehaviour)
        {
            Debug.Log("Lift Enemy");
            //UP
            if (IsAvailableTile(playerTile.neighbours.up))
            {
                tilesToHighlight.Add(playerTile.neighbours.up);
            }
            //RIGHT
            if (IsAvailableTile(playerTile.neighbours.right))
            {
                tilesToHighlight.Add(playerTile.neighbours.right);
            }
            //DOWN
            if (IsAvailableTile(playerTile.neighbours.down))
            {
                tilesToHighlight.Add(playerTile.neighbours.down);
            }
            //LEFT
            if (IsAvailableTile(playerTile.neighbours.left))
            {
                tilesToHighlight.Add(playerTile.neighbours.left);
            }
        }
        else if (liftedPawn is Barrel || liftedPawn is Box)
        {
            Debug.Log("Lift Barrel");
            RaycastHit[] hits = Physics.BoxCastAll(user.GetTile().transform.position + 2 * Vector3.up, ((range + 1) * Vector3.forward + (range + 1) * Vector3.right), Vector3.down, Quaternion.Euler(Quaternion.identity.eulerAngles + new Vector3(0f, 45f, 0f)), 2f, LayerMask.GetMask("FreeTile"));
            foreach (RaycastHit hit in hits)
            {
                Tile tile = hit.transform.GetComponent <Tile>();
                if (IsAvailableTile(tile) || tile.GetPawnOnTile() == liftedPawn)
                {
                    tilesToHighlight.Add(tile);
                }
            }
        }
        Debug.Log("THROW PREVIEW : " + tilesToHighlight.Count);

        Highlight_Manager.instance.HideHighlight(user.GetSkillPreviewID());
        user.SetPreviewID(Highlight_Manager.instance.ShowHighlight(tilesToHighlight, HighlightMode.ActionPreview, true));
        PlayerManager.instance.hoverMode = HoverMode.ThrowHover;
    }
Пример #5
0
    public override void Activate(GamePawn user, Tile target)
    {
        base.Activate(user, target);
        List <Tile> explodedTiles = GetRange(user, false);

        foreach (Tile t in explodedTiles)
        {
            if (t == user.GetTile())
            {
                continue;
            }

            Free f = (Free)t;
            f.PlayExplosion();

            if (t.hasAlcohol)
            {
                f.SetFire();
            }

            if (t.GetPawnOnTile() != null)
            {
                t.GetPawnOnTile().ReceiveDamage(1);
            }
        }
    }
Пример #6
0
    public override List <Tile> HasAvailableTarget(GamePawn user)
    {
        List <Tile> tilesToHighlight = new List <Tile>();
        Tile        currentTile      = user.GetTile().neighbours.up;

        if (currentTile != null)
        {
            if (currentTile.GetPawnOnTile() != null && currentTile.GetPawnOnTile() != PlayerManager.instance.playerCharacter)
            {
                tilesToHighlight.Add(currentTile);
            }
        }

        currentTile = user.GetTile().neighbours.right;
        if (currentTile != null)
        {
            if (currentTile.GetPawnOnTile() != null && currentTile.GetPawnOnTile() != PlayerManager.instance.playerCharacter)
            {
                tilesToHighlight.Add(currentTile);
            }
        }

        currentTile = user.GetTile().neighbours.down;
        if (currentTile != null)
        {
            if (currentTile.GetPawnOnTile() != null && currentTile.GetPawnOnTile() != PlayerManager.instance.playerCharacter)
            {
                tilesToHighlight.Add(currentTile);
            }
        }

        currentTile = user.GetTile().neighbours.left;
        if (currentTile != null)
        {
            if (currentTile.GetPawnOnTile() != null && currentTile.GetPawnOnTile() != PlayerManager.instance.playerCharacter)
            {
                tilesToHighlight.Add(currentTile);
            }
        }

        return(tilesToHighlight);
    }
Пример #7
0
    public override List <Tile> HasAvailableTarget(GamePawn user)
    {
        List <Tile> tilesToHighlight = new List <Tile>();
        Tile        currentTile      = user.GetTile().neighbours.up;

        if (currentTile != null)
        {
            if (IsAvailableTileToJump(currentTile) && IsAvailableTileToStand(currentTile.neighbours.up))
            {
                tilesToHighlight.Add(currentTile);
            }
        }

        currentTile = user.GetTile().neighbours.right;
        if (currentTile != null)
        {
            if (IsAvailableTileToJump(currentTile) && IsAvailableTileToStand(currentTile.neighbours.right))
            {
                tilesToHighlight.Add(currentTile);
            }
        }

        currentTile = user.GetTile().neighbours.down;
        if (currentTile != null)
        {
            if (IsAvailableTileToJump(currentTile) && IsAvailableTileToStand(currentTile.neighbours.down))
            {
                tilesToHighlight.Add(currentTile);
            }
        }

        currentTile = user.GetTile().neighbours.left;
        if (currentTile != null)
        {
            if (IsAvailableTileToJump(currentTile) && IsAvailableTileToStand(currentTile.neighbours.left))
            {
                tilesToHighlight.Add(currentTile);
            }
        }

        return(tilesToHighlight);
    }
Пример #8
0
    public List <Tile> GetRoundRange(GamePawn user, int range, bool usingCombo = false)
    {
        List <Tile> res = new List <Tile>();

        /*Tile startingTile = user.GetTile();
         * res.Add(startingTile);
         *
         * //UP
         * Tile currentTile = startingTile.neighbours.up;
         * if (usingCombo)
         *  CheckForCombo(res, currentTile);
         * currentTile = currentTile.neighbours.right;
         * if (usingCombo)
         *  CheckForCombo(res, currentTile);
         *
         * //RIGHT
         * currentTile = startingTile.neighbours.right;
         * if (usingCombo)
         *  CheckForCombo(res, currentTile);
         * currentTile = currentTile.neighbours.down;
         * if (usingCombo)
         *  CheckForCombo(res, currentTile);
         *
         * //DOWN
         * currentTile = startingTile.neighbours.down;
         * if (usingCombo)
         *  CheckForCombo(res, currentTile);
         * currentTile = currentTile.neighbours.left;
         * if (usingCombo)
         *  CheckForCombo(res, currentTile);
         *
         * //LEFT
         * currentTile = startingTile.neighbours.left;
         * if (usingCombo)
         *  CheckForCombo(res, currentTile);
         * currentTile = currentTile.neighbours.up;
         * if (usingCombo)
         *  CheckForCombo(res, currentTile);*/

        //BOXCAST
        RaycastHit[] hits = Physics.BoxCastAll(user.GetTile().transform.position + (2 * Vector3.up), (Vector3.forward + Vector3.right) * 2 * range, Vector3.down, Quaternion.identity, 2f, LayerMask.GetMask("FreeTile"));

        foreach (RaycastHit hit in hits)
        {
            Tile tile = hit.transform.GetComponent <Free>();
            if (tile != null && !IsWater(tile))
            {
                CheckForCombo(res, tile, usingCombo);
            }
        }

        return(res);
    }
Пример #9
0
    public void LiftPawn(PlayerCharacter user, GamePawn target)
    {
        target.GetTile().SetPawnOnTile(null);
        target.SetTile(null);
        user.liftedPawn = target;

        user.BeginAction();

        Sequence s = DOTween.Sequence();

        s.Append(target.transform.DOMove(user.LiftPawnSocket.position, 0.3f))
        .SetEase(Ease.OutCubic);
        user.throwElementSkill.ThrowPreview(user, target);
    }
Пример #10
0
    public void Jump(GamePawn user, GamePawn target, Direction dir)
    {
        currentActiveSkill = null;
        Tile jumpTile = target.GetTile().GetNeighbours(dir);

        Highlight_Manager.instance.HideHighlight(user.GetSkillPreviewID());

        Sequence s = DOTween.Sequence();

        PlayerManager.instance.playerCharacter.anim.SetTrigger("Jump");
        s.Append(user.transform.DOMove(jumpTile.transform.position + new Vector3(0, jumpTile.transform.localScale.y, 0), 0.3f)
                 .SetEase(Ease.Linear)
                 .OnComplete(() =>
        {
            user.GetTile().SetPawnOnTile(null);
            user.SetTile(jumpTile);
        }));


        s.OnComplete(() =>
        {
            user.EndAction();
        });
    }
Пример #11
0
    public List <Tile> GetCrossRange(GamePawn user, int range, bool usingCombo = false)
    {
        Tile        startingTile = user.GetTile();
        List <Tile> res          = new List <Tile>();

        res.Add(startingTile);
        Tile currentUp;
        Tile currentRight;
        Tile currentDown;
        Tile currentLeft;

        //UP-RIGHT
        currentUp    = startingTile.neighbours.up;
        currentRight = startingTile.neighbours.right;
        for (int i = 0; i < range; i++)
        {
            if (currentUp != null || currentRight != null)
            {
                if (!IsWall(currentUp) || !IsWall(currentRight))
                {
                    Tile checkTile = null;
                    if (currentUp == null || IsWall(currentUp))
                    {
                        checkTile = currentRight.neighbours.up;
                    }
                    else if (currentRight == null || IsWall(currentRight))
                    {
                        checkTile = currentUp.neighbours.right;
                    }
                    else
                    {
                        checkTile = currentUp.neighbours.right;
                    }
                    CheckForCombo(res, checkTile, usingCombo);
                    if (checkTile != null && !IsWall(checkTile))
                    {
                        currentUp    = checkTile.neighbours.up;
                        currentRight = checkTile.neighbours.right;
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    break;
                }
            }
            else
            {
                break;
            }
        }

        //RIGHT-DOWN
        currentRight = startingTile.neighbours.right;
        currentDown  = startingTile.neighbours.down;
        for (int i = 0; i < range; i++)
        {
            if (currentRight != null || currentDown != null)
            {
                if (!IsWall(currentRight) || !IsWall(currentDown))
                {
                    Tile checkTile = null;
                    if (currentRight == null || IsWall(currentRight))
                    {
                        checkTile = currentDown.neighbours.right;
                    }
                    else if (currentDown == null || IsWall(currentDown))
                    {
                        checkTile = currentRight.neighbours.down;
                    }
                    else
                    {
                        checkTile = currentRight.neighbours.down;
                    }
                    CheckForCombo(res, checkTile, usingCombo);
                    if (checkTile != null && !IsWall(checkTile))
                    {
                        currentRight = checkTile.neighbours.right;
                        currentDown  = checkTile.neighbours.down;
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    break;
                }
            }
            else
            {
                break;
            }
        }

        //DOWN-LEFT
        currentDown = startingTile.neighbours.down;
        currentLeft = startingTile.neighbours.left;
        for (int i = 0; i < range; i++)
        {
            if (currentDown != null || currentLeft != null)
            {
                if (!IsWall(currentDown) || !IsWall(currentLeft))
                {
                    Tile checkTile = null;
                    if (currentDown == null || IsWall(currentDown))
                    {
                        checkTile = currentLeft.neighbours.down;
                    }
                    else if (currentLeft == null || IsWall(currentLeft))
                    {
                        checkTile = currentDown.neighbours.left;
                    }
                    else
                    {
                        checkTile = currentDown.neighbours.left;
                    }
                    CheckForCombo(res, checkTile, usingCombo);
                    if (checkTile != null && !IsWall(checkTile))
                    {
                        currentDown = checkTile.neighbours.down;
                        currentLeft = checkTile.neighbours.left;
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    break;
                }
            }
            else
            {
                break;
            }
        }

        //LEFT-UP
        currentLeft = startingTile.neighbours.left;
        currentUp   = startingTile.neighbours.up;
        for (int i = 0; i < range; i++)
        {
            if (currentLeft != null || currentUp != null)
            {
                if (!IsWall(currentLeft) || !IsWall(currentUp))
                {
                    Tile checkTile = null;
                    if (currentLeft == null || IsWall(currentLeft))
                    {
                        checkTile = currentUp.neighbours.left;
                    }
                    else if (currentUp == null || IsWall(currentUp))
                    {
                        checkTile = currentLeft.neighbours.up;
                    }
                    else
                    {
                        checkTile = currentLeft.neighbours.up;
                    }
                    CheckForCombo(res, checkTile, usingCombo);
                    if (checkTile != null && !IsWall(checkTile))
                    {
                        currentLeft = checkTile.neighbours.left;
                        currentUp   = checkTile.neighbours.up;
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    break;
                }
            }
            else
            {
                break;
            }
        }
        //print("Cross Range : " + res.Count);
        return(res);
    }
Пример #12
0
    public List <Tile> GetPlusRange(GamePawn user, int range, bool usingCombo = false)
    {
        Tile        startingTile = user.GetTile();
        List <Tile> res          = new List <Tile>();

        res.Add(startingTile);
        Tile currentTile;

        //UP
        currentTile = startingTile.neighbours.up;
        for (int i = 0; i < range; i++)
        {
            if (currentTile != null && !IsWall(currentTile))
            {
                if (!IsWater(currentTile))
                {
                    res.Add(currentTile);
                }
                if (currentTile.GetPawnOnTile() is Barrel)
                {
                    Barrel barrel = currentTile.GetPawnOnTile() as Barrel;
                    if (!ComboManager.instance.BarrelAlreadyInCombo(barrel))
                    {
                        res.AddRange(ComboManager.instance.AddBarrelToComboPreview(barrel, usingCombo));
                    }
                }
            }
            else
            {
                break;
            }
            currentTile = currentTile.neighbours.up;
        }

        //RIGHT
        currentTile = startingTile.neighbours.right;
        for (int i = 0; i < range; i++)
        {
            if (currentTile != null && !IsWall(currentTile))
            {
                if (!IsWater(currentTile))
                {
                    res.Add(currentTile);
                }
                if (currentTile.GetPawnOnTile() is Barrel)
                {
                    Barrel barrel = currentTile.GetPawnOnTile() as Barrel;
                    if (!ComboManager.instance.BarrelAlreadyInCombo(barrel))
                    {
                        res.AddRange(ComboManager.instance.AddBarrelToComboPreview(barrel, usingCombo));
                    }
                }
            }
            else
            {
                break;
            }
            currentTile = currentTile.neighbours.right;
        }

        //DOWN
        currentTile = startingTile.neighbours.down;
        for (int i = 0; i < range; i++)
        {
            if (currentTile != null && !IsWall(currentTile))
            {
                if (!IsWater(currentTile))
                {
                    res.Add(currentTile);
                }
                if (currentTile.GetPawnOnTile() is Barrel)
                {
                    Barrel barrel = currentTile.GetPawnOnTile() as Barrel;
                    if (!ComboManager.instance.BarrelAlreadyInCombo(barrel))
                    {
                        res.AddRange(ComboManager.instance.AddBarrelToComboPreview(barrel, usingCombo));
                    }
                }
            }
            else
            {
                break;
            }
            currentTile = currentTile.neighbours.down;
        }

        //LEFT
        currentTile = startingTile.neighbours.left;
        for (int i = 0; i < range; i++)
        {
            if (currentTile != null && !IsWall(currentTile))
            {
                if (!IsWater(currentTile))
                {
                    res.Add(currentTile);
                }
                if (currentTile.GetPawnOnTile() is Barrel)
                {
                    Barrel barrel = currentTile.GetPawnOnTile() as Barrel;
                    if (!ComboManager.instance.BarrelAlreadyInCombo(barrel))
                    {
                        res.AddRange(ComboManager.instance.AddBarrelToComboPreview(barrel, usingCombo));
                    }
                }
            }
            else
            {
                break;
            }
            currentTile = currentTile.neighbours.left;
        }

        return(res);
    }