コード例 #1
0
    protected virtual bool HandleExtendedActions(PlayerActionStateContext contextData, out bool timeWillPass, out int nextPlayContext)
    {
        nextPlayContext = GameController.PlayStates.Action;
        timeWillPass    = false;
        bool willForceExit = false;

        return(willForceExit);
    }
コード例 #2
0
    protected override bool HandleAdditionalMoveInteractions(PlayerActionStateContext contextData, Vector2Int newPlayerCoords, ref int nextPlayState, ref bool canMove)
    {
        // TODO: Automatic absorption attempt
        IEntityController entities = contextData.EntityController;
        KrbPlayer         player   = (KrbPlayer)entities.Player;

        if (!player.AbsorberTrait.Data.AutoAbsorb)
        {
            return(false);
        }

        var targetCandidates = entities.GetEntitiesAt(newPlayerCoords);

        foreach (var c in targetCandidates)
        {
            if (c is IAbsorbableEntity test && player.AbsorberTrait.TryAbsorb(test))
            {
                canMove = true;
                return(true);
            }
        }
        return(false);
    }
コード例 #3
0
    protected override bool HandleExtendedActions(PlayerActionStateContext contextData, out bool timeWillPass, out int nextPlayContext)
    {
        if (((KrbInputController)contextData.Input).AbsorbCancel)
        {
            if (typeof(IAbsorbingEntity).IsAssignableFrom(contextData.EntityController.Player.GetType()))
            {
                var absorbing = (IAbsorbingEntity)contextData.EntityController.Player;
                absorbing.AbsorberTrait.ResetAbsorption(true);
            }
        }

        //// REMOVE
        //if (Input.GetKeyDown(KeyCode.P))
        //{
        //    foreach (Monster m in contextData.EntityController.Monsters)
        //    {
        //        m.ToggleDebug();
        //    }
        //}

        timeWillPass    = false;
        nextPlayContext = GameController.PlayStates.Action;
        return(false);
    }
コード例 #4
0
    public int Update(PlayStateContext contextData, out bool timeWillPass)
    {
        if (Input.GetKeyDown(KeyCode.F4))
        {
            SceneManager.LoadScene(0);
        }
        PlayerActionStateContext actionData       = contextData as PlayerActionStateContext;
        BaseInputController      input            = actionData.Input;
        IMapController           map              = actionData.Map;
        IEntityController        entityController = actionData.EntityController;
        Player player = entityController.Player;

        int nextPlayState = GameController.PlayStates.Action;

        timeWillPass = false;

        if (input.IdleTurn)
        {
            timeWillPass = true;
            actionData.Events.Player.SendIdleTurn();
            return(GameController.PlayStates.Action);
        }

        if (input.RangeStart && player.BattleTrait.RangedAttack)
        {
            timeWillPass = false;
            return(GameController.PlayStates.RangePrepare);
        }

        Vector2Int playerCoords = map.CoordsFromWorld(player.transform.position);


        // GAME SPECIFIC
        if (HandleExtendedActions(actionData, out timeWillPass, out nextPlayState))
        {
            return(nextPlayState);
        }

        Vector2Int offset = map.CalculateMoveOffset(input.MoveDir, playerCoords);

        if (offset != Vector2Int.zero)
        {
            var newPlayerCoords = playerCoords + offset;

            if (!player.ValidMapCoords(newPlayerCoords))
            {
                timeWillPass = actionData.BumpingWallsWillSpendTurn;
            }
            else
            {
                timeWillPass = true;

                // Check interactions
                bool canMove = true;

                // Blockers:
                var blocker = FindBlockingEntityAt(entityController, newPlayerCoords);
                if (blocker != null)
                {
                    if (blocker.BlockingTrait.TryUnlock(player))
                    {
                        player.Coords = newPlayerCoords;
                    }
                    return(nextPlayState);
                }

                bool exit = HandleAdditionalMoveInteractions(actionData, newPlayerCoords, ref nextPlayState, ref canMove);
                if (exit)
                {
                    if (canMove)
                    {
                        player.Coords = newPlayerCoords;
                    }
                    return(nextPlayState);
                }

                if (player.SeesHostilesAtCoords(newPlayerCoords))
                {
                    bool allDefeated = player.AttackCoords(newPlayerCoords);
                    canMove = allDefeated;
                }

                if (canMove)
                {
                    player.Coords = newPlayerCoords;
                }
            }
        }

        // Quick Inventory actions:
        int inventoryIdx = System.Array.FindIndex(input.NumbersPressed, x => x);

        if (inventoryIdx != -1)
        {
            bool dropModifier = input.ShiftPressed;
        }

        return(GameController.PlayStates.Action);
    }
コード例 #5
0
    protected virtual bool HandleAdditionalMoveInteractions(PlayerActionStateContext contextData, Vector2Int newPlayerCoords, ref int nextPlayState, ref bool canMove)
    {
        bool immediateExit = false;

        return(immediateExit);
    }