コード例 #1
0
    private FollowingState()
    {
        if (_instance != null)
        {
            return;
        }

        _instance = this;
    }
コード例 #2
0
        public Profile GetProfile(int userId, int activeId)
        {
            FollowingState followingState = new FollowingState();

            if (userId == activeId)
            {
                followingState = FollowingState.ActiveProfile;
            }
            else if (_profileDA.FollowState(activeId, userId) != null)
            {
                followingState = FollowingState.Following;
            }
            else
            {
                followingState = FollowingState.NotFollowing;
            }

            User activeUser  = _profileDA.GetUserByID(activeId);
            User profileUser = _profileDA.GetUserByID(userId);

            Profile data = new Profile
            {
                User = new ActiveUser
                {
                    Id              = activeUser.ID,
                    Username        = activeUser.Username,
                    AccountPhotoURL = activeUser.AccountPhotoURL,
                    AccountURL      = @"/Profile/Index/" + activeUser.ID
                },
                Cards = profileUser.Photos.OrderByDescending(d => d.CreatedDate).Select(p => new Card
                {
                    LogoId          = p.ID,
                    LogoUrl         = p.URL,
                    Username        = p.User.Username,
                    AccountPhotoURL = p.User.AccountPhotoURL,
                    AccountURL      = @"/Profile/Index/" + p.User.ID,
                    LikesNum        = p.Likes.Count,
                    CommentsNum     = p.Comments.Count,
                    Title           = p.Title,
                    Description     = p.Description,
                    UploadDate      = p.CreatedDate.ToShortDateString(),
                    Liked           = p.Likes.Where(l => l.UserID == activeUser.ID).Count() > 0,
                }).ToList(),
                UserProfileId   = profileUser.ID,
                AccountPhotoURL = profileUser.AccountPhotoURL,
                Username        = profileUser.Username,
                Follow          = followingState,
                LogosNum        = profileUser.Photos.Count,
                FollowersNum    = profileUser.Followeds.Count,
                FollowingNum    = profileUser.Followings.Count,
            };

            return(data);
        }
コード例 #3
0
ファイル: FSMZombieBrain.cs プロジェクト: kripergvg/Tanks
        public void Start()
        {
            var idleState      = new IdleState();
            var enterDoorState = new EnterDoorState(_doors, _mover);
            var followingState = new FollowingState(_targetChaser);
            var attackState    = new AttackState(_timeProvider, _attackInterval, _attacker);

            var brainStateMachineBuilder = _stateMachineFactory.CreateBuilder <ZombieBrainContextFactory, ZombieBrainContext, ZombieContextUpdater, IEntity>();

            brainStateMachineBuilder.ConfigureState(idleState, b =>
            {
                b.If(c => !c.IsInsideScene)
                .ThenSetState(enterDoorState);
            });

            brainStateMachineBuilder.ConfigureState(enterDoorState, b =>
            {
                b.If(c => c.Target == null)
                .ThenSetState(idleState);
                b.If(c => c.IsInsideScene && c.Target != null)
                .ThenSetState(followingState);
            });

            brainStateMachineBuilder.ConfigureState(followingState, b =>
            {
                b.If(c => c.Target == null)
                .ThenSetState(idleState);
                b.If(c => c.Target != null && c.TargetReached)
                .ThenSetState(attackState);
            });

            brainStateMachineBuilder.ConfigureState(attackState, b =>
            {
                b.If(c => c.Target == null)
                .ThenSetState(idleState);
                b.If(c => c.Target != null && !c.TargetReached)
                .ThenSetState(followingState);
            });

            var contextFactory = new ZombieBrainContextFactory();
            var contextUpdater = new ZombieContextUpdater(_targetChaser, _targetLocator, _positionDetector);

            _stateMachine = brainStateMachineBuilder.BuildRoot(contextFactory, contextUpdater);
            _stateMachine.Start(idleState);
        }
コード例 #4
0
 private void SetFollowingState(FollowingState followingState)
 {
     this.followingState = followingState;
 }