コード例 #1
0
        //void OnDrawGizmosSelected()
        //{
        //    Gizmos.DrawSphere(transform.position, circleRangeForDetection);

        //}
        //update the block pos here
        public override void UpdateMovementState(bool isPrimaryMoveActive, bool isSecondaryMoveActive)
        {
            if (isPhysicsControlled)
            {
                return;
            }
            if (isPushed)
            {
                return;
            }
            if (isPetrified)
            {
                return;
            }
            if (isMovementFreezed)
            {
                return;
            }
            if (!isPrimaryMoveActive && !isSecondaryMoveActive)
            {
                if (waitingForNextActionToCheckForPath.isWaitingForNextActionCheck)
                {
                    waitingForNextActionToCheckForPath.Perform();
                    return;
                }
                if (completedMotionToMovePoint)
                {
                    if (IsActorOnArrows())
                    {
                        if (GridManager.instance.IsCellContainingUpArrowAtPos(GridManager.instance.grid.WorldToCell(actorTransform.position)))
                        {
                            currentMapper = new OneDNonCheckingMapper(FaceDirection.Up);
                        }
                        else if (GridManager.instance.IsCellContainingDownArrowAtPos(GridManager.instance.grid.WorldToCell(actorTransform.position)))
                        {
                            currentMapper = new OneDNonCheckingMapper(FaceDirection.Down);
                        }
                        else if (GridManager.instance.IsCellContainingLeftArrowAtPos(GridManager.instance.grid.WorldToCell(actorTransform.position)))
                        {
                            currentMapper = new OneDNonCheckingMapper(FaceDirection.Left);
                        }
                        else if (GridManager.instance.IsCellContainingRightArrowAtPos(GridManager.instance.grid.WorldToCell(actorTransform.position)))
                        {
                            currentMapper = new OneDNonCheckingMapper(FaceDirection.Right);
                        }
                    }
                    else if (IsActorOnMirror())
                    {
                        if (GridManager.instance.IsCellBlockedForUnitMotionAtPos(GridManager.instance.grid.WorldToCell(actorTransform.position + GridManager.instance.GetFacingDirectionOffsetVector3(Facing))) || (GridManager.instance.HasPetrifiedObject(GridManager.instance.grid.WorldToCell(actorTransform.position + GridManager.instance.GetFacingDirectionOffsetVector3(Facing))) && GridManager.instance.IsCellContainingPushedMonsterOnCell(GridManager.instance.grid.WorldToCell(actorTransform.position + GridManager.instance.GetFacingDirectionOffsetVector3(Facing)), this)))
                        {
                            currentMapper = wandererMapper;
                            CheckSwitchCellIndex();
                            currentMapper = new OneDNonCheckingMapper(Facing);
                            return;
                        }
                        else
                        {
                            currentMapper = new OneDNonCheckingMapper(Facing);
                        }
                    }
                    else
                    {
                        currentMapper = wandererMapper;
                    }
                    CheckSwitchCellIndex();
                }
            }
        }
コード例 #2
0
        //update the block pos here
        public override void UpdateMovementState(bool isPrimaryMoveActive, bool isSecondaryMoveActive)
        {
            if (isPhysicsControlled)
            {
                return;
            }
            if (isPushed)
            {
                return;
            }
            if (isPetrified)
            {
                return;
            }
            if (isMovementFreezed)
            {
                return;
            }
            if (!isPrimaryMoveActive && !isSecondaryMoveActive)
            {
                inLineRange = senseInLineAction.Perform();
                heroToChase = senseInLineAction.heroInLineOfAction;
                if (!followingTarget)
                {
                    if (followingTarget != inLineRange)
                    {
                        //Triggered ai motion
                        if (ie != null)
                        {
                            StopCoroutine(ie);
                        }
                        ie = PrepareToDashCor();
                        StartCoroutine(ie);
                    }
                    //normal aimless wanderer
                }
                else
                {
                    if ((IsActorOnArrows() || IsActorOnMirror()))
                    {
                        FinishDash();
                    }
                }
                if (waitingForNextActionToCheckForPath.isWaitingForNextActionCheck)
                {
                    waitingForNextActionToCheckForPath.Perform();
                    return;
                }

                if (currentMapper is DashMapper dashMap)
                {
                    if (dashMap.IsDashComplete())
                    {
                        FinishDash();
                        currentMovePointCellPosition = previousMovePointCellPosition;
                        return;
                    }

                    if (completedMotionToMovePoint && !inLineRange)
                    {
                        FinishDash();
                        currentMovePointCellPosition = previousMovePointCellPosition;
                        return;
                    }
                }
                if (completedMotionToMovePoint && !isPreparingToDash)
                {
                    if (IsActorOnArrows())
                    {
                        if (GridManager.instance.IsCellContainingUpArrowAtPos(GridManager.instance.grid.WorldToCell(actorTransform.position)))
                        {
                            currentMapper = new OneDNonCheckingMapper(FaceDirection.Up);
                        }
                        else if (GridManager.instance.IsCellContainingDownArrowAtPos(GridManager.instance.grid.WorldToCell(actorTransform.position)))
                        {
                            currentMapper = new OneDNonCheckingMapper(FaceDirection.Down);
                        }
                        else if (GridManager.instance.IsCellContainingLeftArrowAtPos(GridManager.instance.grid.WorldToCell(actorTransform.position)))
                        {
                            currentMapper = new OneDNonCheckingMapper(FaceDirection.Left);
                        }
                        else if (GridManager.instance.IsCellContainingRightArrowAtPos(GridManager.instance.grid.WorldToCell(actorTransform.position)))
                        {
                            currentMapper = new OneDNonCheckingMapper(FaceDirection.Right);
                        }
                    }
                    else if (IsActorOnMirror())
                    {
                        if (GridManager.instance.IsCellBlockedForUnitMotionAtPos(GridManager.instance.grid.WorldToCell(actorTransform.position + GridManager.instance.GetFacingDirectionOffsetVector3(Facing))) || (GridManager.instance.HasPetrifiedObject(GridManager.instance.grid.WorldToCell(actorTransform.position + GridManager.instance.GetFacingDirectionOffsetVector3(Facing))) && GridManager.instance.IsCellContainingPushedMonsterOnCell(GridManager.instance.grid.WorldToCell(actorTransform.position + GridManager.instance.GetFacingDirectionOffsetVector3(Facing)), this)))
                        {
                            currentMapper = wandererMapper;
                            CheckSwitchCellIndex();
                            currentMapper = new OneDNonCheckingMapper(Facing);
                            return;
                        }
                        else
                        {
                            currentMapper = new OneDNonCheckingMapper(Facing);
                        }
                    }
                    else
                    {
                        if (currentMapper is OneDNonCheckingMapper)
                        {
                            FinishDash();
                        }
                    }
                    CheckSwitchCellIndex();
                }
            }
        }
コード例 #3
0
        //void OnDrawGizmosSelected()
        //{
        //    Gizmos.DrawSphere(transform.position, circleRangeForDetection);

        //}
        //update the block pos here
        public override void UpdateMovementState(bool isPrimaryMoveActive, bool isSecondaryMoveActive)
        {
            if (isPhysicsControlled)
            {
                return;
            }
            if (isPushed)
            {
                return;
            }
            if (isPetrified)
            {
                return;
            }
            if (isMovementFreezed)
            {
                return;
            }

            if (!isPrimaryMoveActive && !isSecondaryMoveActive)
            {
                if (!waitForPathFindingToWearOff.Perform())
                {
                    inLineRange = senseInLineAction.Perform();
                    heroToChase = senseInLineAction.heroInLineOfAction;
                    if (!followingTarget)
                    {
                        if (followingTarget != inLineRange)
                        {
                            //Triggered ai motion
                            currentMapper   = null;
                            currentMapper   = pathfindingMapper;
                            followingTarget = true;
                        }
                        //normal aimless wanderer
                    }
                    else
                    {
                        if (!senseInCircleAction.Perform() || (IsActorOnArrows() || IsActorOnMirror()))
                        {
                            FinishFollowing();
                        }
                    }

                    if (waitingForNextActionToCheckForPath.isWaitingForNextActionCheck)
                    {
                        waitingForNextActionToCheckForPath.Perform();
                        return;
                    }
                }
                else
                {
                    if (waitingForNextActionToCheckForPath.isWaitingForNextActionCheck)
                    {
                        waitingForNextActionToCheckForPath.CompleteTimer();
                    }
                }
                if (completedMotionToMovePoint)
                {
                    if (IsActorOnArrows())
                    {
                        if (GridManager.instance.IsCellContainingUpArrowAtPos(GridManager.instance.grid.WorldToCell(actorTransform.position)))
                        {
                            currentMapper = new OneDNonCheckingMapper(FaceDirection.Up);
                        }
                        else if (GridManager.instance.IsCellContainingDownArrowAtPos(GridManager.instance.grid.WorldToCell(actorTransform.position)))
                        {
                            currentMapper = new OneDNonCheckingMapper(FaceDirection.Down);
                        }
                        else if (GridManager.instance.IsCellContainingLeftArrowAtPos(GridManager.instance.grid.WorldToCell(actorTransform.position)))
                        {
                            currentMapper = new OneDNonCheckingMapper(FaceDirection.Left);
                        }
                        else if (GridManager.instance.IsCellContainingRightArrowAtPos(GridManager.instance.grid.WorldToCell(actorTransform.position)))
                        {
                            currentMapper = new OneDNonCheckingMapper(FaceDirection.Right);
                        }
                    }
                    else if (IsActorOnMirror())
                    {
                        if (GridManager.instance.IsCellBlockedForUnitMotionAtPos(GridManager.instance.grid.WorldToCell(actorTransform.position + GridManager.instance.GetFacingDirectionOffsetVector3(Facing))) || (GridManager.instance.HasPetrifiedObject(GridManager.instance.grid.WorldToCell(actorTransform.position + GridManager.instance.GetFacingDirectionOffsetVector3(Facing))) && GridManager.instance.IsCellContainingPushedMonsterOnCell(GridManager.instance.grid.WorldToCell(actorTransform.position + GridManager.instance.GetFacingDirectionOffsetVector3(Facing)), this)))
                        {
                            currentMapper = wandererMapper;
                            CheckSwitchCellIndex();
                            currentMapper = new OneDNonCheckingMapper(Facing);
                            return;
                        }
                        else
                        {
                            currentMapper = new OneDNonCheckingMapper(Facing);
                        }
                    }
                    else
                    {
                        currentMapper = wandererMapper;
                    }
                    CheckSwitchCellIndex();
                }
            }
        }