コード例 #1
0
ファイル: NPCCharacterInput.cs プロジェクト: apsgk9/Marianne
 private void Awake()
 {
     agent = GetComponent <NavMeshAgent>();
     _walkruntransitionHandler = GetComponent <TransitionHandler>();
     _verticalHistory          = new MovementHistory(historyMaxLength);
     _horizontalHistory        = new MovementHistory(historyMaxLength);
 }
コード例 #2
0
    private MovementHistory.Data GetMovementData(MovementHistory movementHistory, float tick)
    {
        var history = movementHistory.movementHistory;
        var before  = history.Where(m => m.tick <= tick).Last();

        if (before != null)
        {
            movementHistory.ClearBeforeTick(before.tick);
        }

        var after = history.Where(m => m.tick >= tick).First();
        var delta = after.tick - before.tick;

        if (delta == 0)
        {
            return(before);
        }

        var numerator = tick - before.tick;
        var t         = numerator / delta;
        var data      = new MovementHistory.Data();

        data.position        = Vector3.Lerp(before.position, after.position, t);
        data.rotation        = Quaternion.Lerp(before.rotation, after.rotation, t);
        data.scale           = Vector3.Lerp(before.scale, after.scale, t);
        data.velocity        = Vector3.Lerp(before.velocity, after.velocity, t);
        data.angularVelocity = Vector3.Lerp(before.angularVelocity, after.angularVelocity, t);
        return(data);
    }
コード例 #3
0
        public IChessGame Create()
        {
            var piecesFactory   = new PiecesFactory();
            var movementHistory = new MovementHistory();
            var piecePromoter   = new PiecePromoter(movementHistory);
            var castlingMover   = new CastlingMover(movementHistory);
            var enPassantMover  = new EnPassantMover(movementHistory);
            var pieceMover      = new PieceMover(movementHistory, piecePromoter,
                                                 castlingMover, enPassantMover);
            var chessBoard = new ChessBoard(piecesFactory, pieceMover);

            List <IMovement> movements = new();
            var pawnMovement           = new PawnMovement(chessBoard);
            var enPassantMovement      = new EnPassantMovement(chessBoard);
            var kingMovement           = new KingMovement(chessBoard);
            var horizontalMovement     = new HorizontalMovement(chessBoard);
            var verticalMovement       = new VerticalMovement(chessBoard);
            var pdiagonalMovement      = new PositiveDiagonalMovement(chessBoard);
            var ndiagonalMovement      = new NegativeDiagonalMovement(chessBoard);
            var knightMovement         = new KnightMovement(chessBoard);

            movements.Add(pawnMovement);
            movements.Add(enPassantMovement);
            movements.Add(kingMovement);
            movements.Add(horizontalMovement);
            movements.Add(verticalMovement);
            movements.Add(pdiagonalMovement);
            movements.Add(ndiagonalMovement);
            movements.Add(knightMovement);
            var movementComposite = new MovementComposite(movements);

            List <IMovement> movementsWithCastling = new();
            var queensideCastlingMovement          =
                new QueensideCastlingMovement(chessBoard, movementComposite);
            var kingsideCastlingMovement =
                new KingsideCastlingMovement(chessBoard, movementComposite);

            movementsWithCastling.Add(movementComposite);
            movementsWithCastling.Add(queensideCastlingMovement);
            movementsWithCastling.Add(kingsideCastlingMovement);
            var movementCompositeWithCastling = new MovementComposite(movementsWithCastling);

            var promotionDetector = new PromotionDetector(chessBoard);

            var checkDetector = new CheckDetector(chessBoard, movementCompositeWithCastling);

            var legalMovement = new LegalMovement(chessBoard,
                                                  movementCompositeWithCastling, checkDetector);

            var moveValidator = new MoveValidator(chessBoard,
                                                  legalMovement, promotionDetector);

            var gameFinishedDetector = new GameFinishedDetector(checkDetector,
                                                                legalMovement);

            return(new ChessGame(chessBoard, moveValidator,
                                 promotionDetector, gameFinishedDetector, legalMovement));
        }
コード例 #4
0
        public async Task <IActionResult> GetHistory([FromRoute] Guid deviceId, [FromQuery] DateTime?since = null, [FromQuery] int page = 0, [FromQuery] int limit = 0)
        {
            if (Guid.Empty.Equals(deviceId))
            {
                return(BadRequest());
            }

            MovementHistory history = await _movementsService.GetHistoryForDeviceAsync(deviceId, since, page, limit);

            return(Ok(history));
        }
コード例 #5
0
        protected SummonedFighter(int id, FightTeam team, IEnumerable <Spell> spells, FightActor summoner, Cell cell, int identifier)
            : base(team, spells, identifier)
        {
            Id       = id;
            Position = summoner.Position.Clone();
            Cell     = cell;
            Summoner = summoner;

            FightStartPosition = Position.Clone();
            MovementHistory.RegisterEntry(FightStartPosition.Cell);
        }
コード例 #6
0
    //---------------------------
    private void Awake()
    {
        //For when settings are not found
        _tempSettings = ScriptableObject.CreateInstance <InputSettings>();

        //Instance = this;
        MouseIdleTimer      = new Timer(IdleThreshold);
        LastDirectionVector = DirectionVector;

        PlayerInputActions = new PlayerInputActions();
        _deviceUsing       = "Keyboard"; //default to keyboard

        //MovementAxisHistory
        _verticalHistory   = new MovementHistory(historyMaxLength);
        _horizontalHistory = new MovementHistory(historyMaxLength);
    }
コード例 #7
0
        public override GameFightFighterInformations GetGameFightFighterInformations(WorldClient client = null)
        {
            var casterInfos = Caster.GetGameFightFighterInformations();

            if (casterInfos is GameFightCharacterInformations)
            {
                var characterInfos = casterInfos as GameFightCharacterInformations;

                return(new GameFightCharacterInformations(Id, casterInfos.look, GetEntityDispositionInformations(), casterInfos.teamId,
                                                          0, IsAlive(), GetGameFightMinimalStats(), MovementHistory.GetEntries(2).Select(x => x.Cell.Id).ToArray(),
                                                          characterInfos.name, characterInfos.status, characterInfos.level, characterInfos.alignmentInfos, characterInfos.breed, characterInfos.sex));
            }

            return(new GameFightFighterInformations(Id, casterInfos.look, GetEntityDispositionInformations(), casterInfos.teamId,
                                                    0, IsAlive(), GetGameFightMinimalStats(), MovementHistory.GetEntries(2).Select(x => x.Cell.Id).ToArray()));
        }