示例#1
0
    public override void Use(Square[] _targets, HeroPiece _user)
    {
        Square desti = _targets[0];

        if (desti == null)
        {
            return;
        }

        if (Effect == e_positionEffects.Teleport)
        {
            HeroPiece piece = desti.Piece;

            piece.NotifyMovement(board[_user.Position.x, _user.Position.y], false);
            _user.NotifyMovement(desti, false);
        }

        else
        {
            Vector2Int direction = desti.Position - _user.Position;
            int        x         = direction.x != 0 ? (int)Mathf.Sign(direction.x) : 0;
            int        y         = direction.y != 0 ? (int)Mathf.Sign(direction.y) : 0;
            direction = new Vector2Int(x, y);


            if (Effect == e_positionEffects.Push)
            {
                Square square = utility.GetFinalSquareInDirection(desti, direction, Distance + 1);
                desti.Piece.NotifyMovement(square, false);
            }
            else if (Effect == e_positionEffects.Pull)
            {
                Square square = utility.GetFinalSquareInDirection(desti, -direction, Distance + 1);
                desti.Piece.NotifyMovement(square, false);
            }
        }
    }
示例#2
0
    //InGame
    public void ClickOnHero(HeroPiece _piece)
    {
        if (step == e_step.Placement)
        {
            PlacementHero(_piece);
            return;
        }

        if (selectedActive != null)
        {
            if (_piece == selectedActive.Piece)
            {
                Unselection();
            }
            else
            {
                Square square = board[_piece.Position.x, _piece.Position.y];
                if (activeList.Contains(square))
                {
                    Square[] targets = new Square[] { square };
                    selectedActive.Piece.ActivePower(targets);

                    Unselection();
                }
            }
        }
        else if (selectedPiece != null)
        {
            if (_piece == selectedPiece)
            {
                canUnselect = true;
            }
            else if (_piece.Team != gameplayManager.Team)
            {
                Square square = board[_piece.Position.x, _piece.Position.y];
                if (attackList.Contains(square))
                {
                    if (selectedPiece.CanMove > 0)
                    {
                        selectedPiece.NotifyMovement(AttackPath(square), true);
                    }

                    Square[] targets = new Square[] { square };
                    selectedPiece.Attack(targets);
                    selectedPiece.HighLight(false);
                    selectedPiece = null;
                }
                Unselection();
            }
            else if (_piece != selectedPiece)
            {
                Unselection();
            }
        }
        else if (_piece.Team == gameplayManager.Team)
        {
            if (_piece.CanMove > 0 || _piece.CanAct > 0)
            {
                Unselection();
                selectedPiece = _piece;
                selectedPiece.HighLight(true);
                canUnselect = false;
                ClickDrag(_piece.transform);

                Ability    atck = selectedPiece.Hero.Attack;
                EffectStat ef   = (EffectStat)atck.Effects[0];

                ef.Value         = -selectedPiece.Stats[e_stats.Damage].CurrentValue;
                atck.Range       = selectedPiece.Stats[e_stats.Range].CurrentValue;
                atck.GetOccupied = true;

                Ability             mov    = selectedPiece.Hero.Move;
                List <e_squareType> exceps = new List <e_squareType>();
                if (selectedPiece.Hero.Fly == false)
                {
                    exceps.Add(e_squareType.Obstacle);
                }

                mov.Range       = selectedPiece.Stats[e_stats.Speed].CurrentValue;
                mov.GetOccupied = false;
                mov.Exceptions  = exceps;

                HighlightHeroRanges();
            }
        }
    }