Beispiel #1
0
    private void KickTankard(SpaceBehavior space)
    {
        WaitToArriveTask waitTask = new WaitToArriveTask(transform, new TwoDLoc(GridLoc.x, GridLoc.z));

        Transform localTankard = Services.Board.GetTankardInSpace(GridLoc);

        Debug.Assert(localTankard != null, "Didn't find local tankard.");

        MoveObjectTask moveTask = new MoveObjectTask(localTankard,
                                                     new TwoDLoc(GridLoc.x, GridLoc.z),
                                                     new TwoDLoc(space.GridLocation.x, space.GridLocation.z));
        DamageRemotelyTask damageTask = new DamageRemotelyTask(new TwoDLoc(space.GridLocation.x, space.GridLocation.z),
                                                               drinkDamage,
                                                               this);

        waitTask.Then(moveTask);
        moveTask.Then(damageTask);
        space.Tankard = true;
        Services.Board.GetSpace(GridLoc.x, GridLoc.z).Tankard = false;
        localTankard.GetComponent <TankardBehavior>().GridLoc = new TwoDLoc(space.GridLocation.x, space.GridLocation.z);
        Services.Tasks.AddTask(waitTask);
        Services.UI.OpponentStatement(KICK_MSG);
        Services.Events.Unregister <InputEvent>(ChooseTankardKick);
        Services.Board.HighlightAllAroundSpace(GridLoc.x, GridLoc.z, BoardBehavior.OnOrOff.Off);
    }
    /// <summary>
    /// Used as an InputEvent handler to enable the Guardian to choose a column to block.
    /// </summary>
    /// <param name="e">The input event.</param>
    private void ChooseColumn(Event e)
    {
        InputEvent inputEvent = e as InputEvent;

        if (inputEvent.selected.tag == BOARD_TAG)
        {
            SpaceBehavior space = inputEvent.selected.GetComponent <SpaceBehavior>();

            if (space.GridLocation.x - 1 == GridLoc.x || space.GridLocation.x + 1 == GridLoc.x)
            {
                blockedColumn = space.GridLocation.x;
                Services.Events.Fire(new BlockColumnEvent(blockedColumn));
                Services.Events.Fire(new NeedWaitEvent(false));                 //tell TurnManager there's no need to wait anymore

                if (currentHold != HoldTrack.Hold_the_Line)
                {
                    MakeColumnLure(blockedColumn, true);                                                         //attackers move into blocked columns at higher Hold the Line levels
                }
                Services.Events.Unregister <InputEvent>(ChooseColumn);
                Services.UI.PlayerPhaseStatement(COLUMN_CHOSEN);

                RemoveBlockFeedbackTask pickUpTask = new RemoveBlockFeedbackTask(LINE_MARKER_OBJ);
                pickUpTask.Then(new BlockFeedbackTask(blockedColumn, LINE_MARKER_OBJ));
                Services.Tasks.AddTask(pickUpTask);
                Services.Board.HighlightColumn(GridLoc.x - 1, BoardBehavior.OnOrOff.Off);
                Services.Board.HighlightColumn(GridLoc.x + 1, BoardBehavior.OnOrOff.Off);
                return;
            }
            else
            {
                Services.UI.OpponentStatement(INVALID_COLUMN);
            }
        }
    }
Beispiel #3
0
    private void ChooseTankardKick(Event e)
    {
        Debug.Assert(e.GetType() == typeof(InputEvent), "Non-InputEvent in ChooseTankardKick.");

        InputEvent inputEvent = e as InputEvent;

        if (inputEvent.selected.tag == BOARD_TAG)
        {
            SpaceBehavior space = inputEvent.selected.GetComponent <SpaceBehavior>();

            if (CheckAllAdjacent(GridLoc, space.GridLocation))
            {
                KickTankard(space);
            }
        }
        else if (inputEvent.selected.tag == ATTACKER_TAG || inputEvent.selected.tag == LEADER_TAG || inputEvent.selected.tag == MINION_TAG)
        {
            AttackerSandbox attacker = inputEvent.selected.GetComponent <AttackerSandbox>();

            SpaceBehavior space = Services.Board.GetSpace(attacker.XPos, attacker.ZPos);

            if (CheckAllAdjacent(GridLoc, space.GridLocation))
            {
                KickTankard(space);
            }
        }
    }
Beispiel #4
0
    private void PutDownBlock(global::Event e)
    {
        Debug.Assert(e.GetType() == typeof(InputEvent), "Non-InputEvent in PutDownBlock");

        InputEvent inputEvent = e as InputEvent;

        if (inputEvent.selected.tag == BOARD_TAG)
        {
            SpaceBehavior space = inputEvent.selected.GetComponent <SpaceBehavior>();

            //if the space isn't blockable for any reason, stop
            if (!CheckBlockable(space.GridLocation))
            {
                return;
            }


            //the space is blockable; put down the rockfall and provide appropriate feedback
            space.Block = true;
            Services.Tasks.AddTask(new BlockSpaceFeedbackTask(space.GridLocation.x, space.GridLocation.z, BLOCK_MARKER_OBJ));


            //tell the Ranger where the rockfall is
            if (ranger.GetCurrentTrapTrack() == RangerBehavior.TrapTrack.Rockfall)
            {
                ranger.RockfallLoc = new TwoDLoc(space.GridLocation.x, space.GridLocation.z);
            }


            Services.Board.HighlightAllAroundSpace(ranger.ReportGridLoc().x, ranger.ReportGridLoc().z, BoardBehavior.OnOrOff.Off, true);

            SetStatus(TaskStatus.Success);
        }
    }
    /// <summary>
    /// Drop a tankard in a chosen empty space. Also set the space's state accordingly, and provide feedback.
    /// </summary>
    /// <param name="e">An InputEvent with the relevant space.</param>
    private void DropTankard(global::Event e)
    {
        Debug.Assert(e.GetType() == typeof(InputEvent), "Non-InputEvent in DropTankard.");

        InputEvent inputEvent = e as InputEvent;

        if (inputEvent.selected.tag == BOARD_TAG &&
            Services.UI.GetCharSheetStatus() == CharacterSheetBehavior.SheetStatus.Hidden)
        {
            SpaceBehavior space = inputEvent.selected.GetComponent <SpaceBehavior>();

            if (Services.Board.GeneralSpaceQuery(space.GridLocation.x, space.GridLocation.z) != SpaceBehavior.ContentType.None)
            {
                return;
            }

            Services.Tasks.AddTask(new BlockSpaceFeedbackTask(space.GridLocation.x, space.GridLocation.z, GetTankard()));
            space.Tankard = true;
            GameObject.Find(GetTankard()).GetComponent <TankardBehavior>().GridLoc = new TwoDLoc(space.GridLocation.x, space.GridLocation.z);

            drops--;
        }

        if (drops <= 0)
        {
            SetStatus(TaskStatus.Success);
        }
    }
Beispiel #6
0
 private void VisitedSpace(SpaceBehavior spaceBehavior)
 {
     spaceBehavior.visited = true;
     if (spaceBehavior.previousSpace != null)
     {
         this.VisitedSpace(spaceBehavior.previousSpace.GetComponent <SpaceBehavior>());
     }
 }
Beispiel #7
0
    /// <summary>
    /// Handle player attempts to choose a space to teleport to:
    ///
    /// 1. Confirm that the player chose a space.
    /// 2. Confirm that the space is empty.
    /// 3. If the player is only allowed to move to adjacent spaces, confirm that the space is adjacent.
    /// 4. Start a task that moves the defender to the chosen space.
    /// </summary>
    /// <param name="e"></param>
    private void SelectDestination(global::Event e)
    {
        Debug.Assert(e.GetType() == typeof(InputEvent), "Non-InputEvent in SelectDestination");

        InputEvent inputEvent = e as InputEvent;

        if (inputEvent.selected.tag == BOARD_TAG &&
            Services.UI.GetCharSheetStatus() == CharacterSheetBehavior.SheetStatus.Hidden)
        {
            SpaceBehavior space = inputEvent.selected.GetComponent <SpaceBehavior>();

            //stop if the player chose a space that has something in it
            if (Services.Board.GeneralSpaceQuery(space.GridLocation.x, space.GridLocation.z) != SpaceBehavior.ContentType.None)
            {
                return;
            }

            //stop if the defender needs to teleport to an adjacent space and the selected space is not adjacent
            if (destination == PossibleDestinations.Adjacent)
            {
                if (!Services.Board.CheckAdjacentSpace(defender.ReportGridLoc().x,
                                                       defender.ReportGridLoc().z,
                                                       space.GridLocation.x,
                                                       space.GridLocation.z))
                {
                    return;
                }
            }

            //physically move the defender model
            Services.Tasks.AddTask(new MoveDefenderTask(defender.gameObject.GetComponent <Rigidbody>(),
                                                        defender.GetScreenMoveSpeed(),
                                                        new List <TwoDLoc>()
            {
                defender.ReportGridLoc(), space.GridLocation
            }));


            //update the board
            Services.Board.TakeThingFromSpace(defender.ReportGridLoc().x, defender.ReportGridLoc().z);
            Services.Board.PutThingInSpace(defender.gameObject,
                                           space.GridLocation.x,
                                           space.GridLocation.z,
                                           SpaceBehavior.ContentType.Defender);
            defender.NewLoc(space.GridLocation.x, space.GridLocation.z);

            SetStatus(TaskStatus.Success);
        }
    }
Beispiel #8
0
        private void HandleFightInputs(Event e)
        {
            InputEvent inputEvent = e as InputEvent;

            if (inputEvent.selected.tag == DEFENDER_TAG)
            {
                Services.Defenders.SelectDefenderForFight(inputEvent.selected.GetComponent <DefenderSandbox>());
            }
            else if ((inputEvent.selected.tag == ATTACKER_TAG || inputEvent.selected.tag == MINION_TAG || inputEvent.selected.tag == LEADER_TAG) &&
                     Services.Defenders.IsAnyoneSelected() &&
                     Services.Defenders.GetSelectedDefender().GetChosenCardValue() != DefenderSandbox.NO_CARD_SELECTED)
            {
                Services.Defenders.GetSelectedDefender().TryFight(inputEvent.selected.GetComponent <AttackerSandbox>());
            }
            else if (inputEvent.selected.tag == ATTACKER_TAG || inputEvent.selected.tag == MINION_TAG || inputEvent.selected.tag == LEADER_TAG)
            {
                Services.UI.OpponentStatement(inputEvent.selected.GetComponent <AttackerSandbox>().GetUIInfo());
            }
            else if (inputEvent.selected.tag == BOARD_TAG)
            {
                SpaceBehavior space = inputEvent.selected.GetComponent <SpaceBehavior>();

                //if the player clicked the board when it seems like they must be trying to fight an enemy there, let them do so
                if (Services.Board.GeneralSpaceQuery(space.GridLocation.x, space.GridLocation.z) == SpaceBehavior.ContentType.Attacker)
                {
                    if (Services.Defenders.IsAnyoneSelected() &&
                        Services.Defenders.GetSelectedDefender().GetChosenCardValue() != DefenderSandbox.NO_CARD_SELECTED)
                    {
                        Services.Defenders.GetSelectedDefender().TryFight(Services.Board.GetThingInSpace(space.GridLocation.x,
                                                                                                         space.GridLocation.z).GetComponent <AttackerSandbox>());
                    }
                }
                else
                {
                    Services.Events.Fire(new BoardClickedEvent(space.GridLocation));
                }
            }

            if (Services.Defenders.IsEveryoneDone())
            {
                TransitionTo <BesiegeWalls>();
            }
            ;
        }
Beispiel #9
0
    /// <summary>
    /// Puts down the board tiles
    /// </summary>
    /// <returns>A 2D array containing all of the board spaces.</returns>
    private SpaceBehavior[,] MakeBoard()
    {
        SpaceBehavior[,] temp = new SpaceBehavior[BOARD_WIDTH, BOARD_HEIGHT];
        GameObject objToCreate = Resources.Load <GameObject>(SPACE_OBJ);

        for (int x = 0; x < BOARD_WIDTH; x++)
        {
            for (int z = 0; z < BOARD_HEIGHT; z++)
            {
                temp[x, z] = MonoBehaviour.Instantiate <GameObject>(objToCreate,
                                                                    AssignWorldLocation(x, z),
                                                                    objToCreate.transform.rotation,
                                                                    BoardOrganizer).GetComponent <SpaceBehavior>();
                temp[x, z].contentType   = SpaceBehavior.ContentType.None;
                temp[x, z].Lure          = false;
                temp[x, z].WorldLocation = AssignWorldLocation(x, z);
                temp[x, z].GridLocation  = new TwoDLoc(x, z);
            }
        }

        return(temp);
    }
Beispiel #10
0
    private void PutDownBlock(Event e)
    {
        Debug.Assert(e.GetType() == typeof(InputEvent), "Non-InputEvent in PutDownBlock");

        //don't put down a block while the player is trying to hide the character sheet
        if (Services.UI.GetCharSheetStatus() == CharacterSheetBehavior.SheetStatus.Displayed)
        {
            return;
        }

        InputEvent inputEvent = e as InputEvent;

        if (inputEvent.selected.tag == BOARD_TAG)
        {
            SpaceBehavior space = inputEvent.selected.GetComponent <SpaceBehavior>();


            //is this a block that can destroy an attacker?
            bool destroyingBlock = false;

            //try to put down the block
            if (CheckBlockable(space.GridLocation.x, space.GridLocation.z, destroyingBlock))
            {
                space.Block = true;
                Services.Tasks.AddTask(new BlockSpaceFeedbackTask(space.GridLocation.x, space.GridLocation.z, BLOCK_MARKER_OBJ));
                Services.UI.OpponentStatement(BLOCKED_MSG);

                if (ranger.GetCurrentTrapTrack() == RangerBehavior.TrapTrack.Rockfall)
                {
                    ranger.RockfallLoc = new TwoDLoc(space.GridLocation.x, space.GridLocation.z);
                }

                Services.Events.Unregister <InputEvent>(PutDownBlock);
                Services.Board.HighlightAllAroundSpace(rangerX, rangerZ, BoardBehavior.OnOrOff.Off, true);
                SetStatus(TaskStatus.Success);
            }
        }
    }