Example #1
0
 //地面跳
 public void _JumpOnGround(float speed)
 {
     //在地面或贴近地面
     if (IsOnGround())
     {
         bool isCanJump = false;
         //在冰面(此条件属于特殊情况)
         if (isOnIceGround())
         {
             isCanJump = true;
         }
         else if (slope < maxFrictionSlope)
         {
             //角色斜度超过定值,禁止跳
             isCanJump = true;
         }
         //执行跳
         if (isCanJump)
         {
             readyJump        = false;
             state            = RoleState.Raising;
             jumpInstantSpeed = speed * 1f;
         }
     }
 }
Example #2
0
 public void statueInit(RoleState state)
 {
     this.statueState = state;
     statueInfo       = GameObject.Find("_Init").GetComponent <GS_GameInit>().statueInfosDic[statueState];
     this.transform.Find("statueSprite").GetComponent <SpriteRenderer>().sprite = statueInfo.statueTex;
     this.GetComponent <BoxCollider>().size = new Vector3(statueInfo.statueSize.x, statueInfo.statueSize.y, 3f);
 }
Example #3
0
        public async Task RoleClaimsActorRename_ExpectsNewValue()
        {
            var stateManager = new Mock <IActorStateManager>();
            var oldState     = new RoleState("old role", "OLDROLE", Guid.NewGuid().ToString());
            var newState     = new RoleState("new role", "NEWROLE", null);

            stateManager.Setup(manager => manager.GetStateAsync <RoleState>(_stateName, It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(oldState))
            .Verifiable();
            stateManager.Setup(manager => manager
                               .SetStateAsync(
                                   _stateName,
                                   It.Is <RoleState>(o =>
                                                     o.Name == newState.Name &&
                                                     o.NormalizedName == newState.NormalizedName &&
                                                     string.IsNullOrWhiteSpace(o.ConcurrencyStamp) &&
                                                     o.ConcurrencyStamp != oldState.ConcurrencyStamp),
                                   It.IsAny <CancellationToken>()))
            .Verifiable();
            string          id            = Guid.NewGuid().ToString();
            RoleClaimsActor testDemoActor = await CreateActor(stateManager.Object, id);

            await testDemoActor.Tell(new RenameRole(id, newState.Name, newState.NormalizedName, oldState.ConcurrencyStamp, "user"));

            stateManager.VerifyAll();
        }
Example #4
0
 private void Init()
 {
     if (_initialized)
     {
         return;
     }
     lock (Locker)
     {
         if (_initialized)
         {
             return;
         }
         _acDomain.MessageDispatcher.DispatchMessage(new MemorySetInitingEvent(this));
         _roleDic.Clear();
         _descendantRoles.Clear();
         var roles = _acDomain.RetrieveRequiredService <IOriginalHostStateReader>().GetAllRoles();
         foreach (var role in roles)
         {
             var roleState = RoleState.Create(role);
             if (!_roleDic.ContainsKey(role.Id))
             {
                 _roleDic.Add(role.Id, roleState);
             }
         }
         foreach (var role in _roleDic)
         {
             var children = new List <RoleState>();
             RecDescendantRoles(this, role.Value, children);
             _descendantRoles.Add(role.Value, children);
         }
         _initialized = true;
         _acDomain.MessageDispatcher.DispatchMessage(new MemorySetInitializedEvent(this));
     }
 }
Example #5
0
 void Update()
 {
     if (m_roleState == RoleState.Init)
     {
         if (!AnimComponet.IsPlaying(m_curRoleData._InitAnim))
         {
             //if (m_curRoleData._VocationID == 1)
             //    Debug.Log(m_roleState + " To RoleState.Init " + m_curRoleData._InitAnim);
             AnimComponet.CrossFade(m_curRoleData._InitAnim);
         }
     }
     else if (m_roleState == RoleState.Show)
     {
         if (!AnimComponet.IsPlaying(m_curRoleData._StopAnim))
         {
             //if (m_curRoleData._VocationID == 1)
             //    Debug.Log(m_roleState + " To RoleState.Show " + m_curRoleData._StopAnim);
             AnimComponet.CrossFade(m_curRoleData._StopAnim);
         }
     }
     else
     {
         animTime += Time.deltaTime;
         if (m_index < m_curAnimList.Count)
         {
             //AnimComponet[m_curAnimList[m_index]].weight = 0.3f;
             if (AnimComponet.animation[m_curAnimList[m_index]].length > animTime)
             {
                 if (!AnimComponet.IsPlaying(m_curAnimList[m_index]))
                 {
                     //Debug.Log(m_roleState + " " + m_curAnimList[m_index]);
                     AnimComponet.CrossFade(m_curAnimList[m_index]);
                 }
             }
             else
             {
                 animTime = 0;
                 m_index++;
             }
         }
         else
         {
             m_curAnimList.Clear();
             m_index = 0;
             if (m_roleState == RoleState.Click)
             {
                 m_roleState = RoleState.Show;
             }
             else if (m_roleState == RoleState.Back)
             {
                 m_roleState = RoleState.Init;
             }
             //else
             //{
             //if (m_curRoleData._VocationID == 1)
             //Debug.Log("状态2:" + m_curRoleData._VocationID + "  " + m_roleState);
             //}
         }
     }
 }
Example #6
0
        /// <summary>
        /// 获取角色状态
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public RoleState GetRoleState(string id)
        {
            RoleState state = RoleState.Normal;

            rolesState.TryGetValue(id, out state);
            return(state);
        }
Example #7
0
        public RoleState GetAccesslist(string machucnang)
        {
            var       _unitCode = _service.GetCurrentUnitCode();
            RoleState roleState = _service.GetRoleStateByMaChucNang(_unitCode, RequestContext.Principal.Identity.Name, machucnang);

            return(roleState);
        }
Example #8
0
    /// <summary>切换状态</summary>
    /// <param name="newState">新状态</param>
    public void ChangeState(RoleState newState)
    {
        if (CurrRoleCtrl.CurrRoleType == RoleType.Monster)
        {
            //Debug.Log(newState.ToString());
        }
        //因为休闲 战斗 都有多种状态 所以此处需要排除 休闲 攻击状态(因为可能需要从普通休闲切换到战斗休闲及技能切换)
        if (CurrRoleStateEnum == newState && CurrRoleStateEnum != RoleState.Idle && CurrRoleStateEnum != RoleState.Attack)
        {
            return;
        }
        //调用以前状态的离开方法
        if (m_CurrRoleState != null)
        {
            m_CurrRoleState.OnLeave();
        }

        //更改当前状态枚举
        CurrRoleStateEnum = newState;

        //更改当前状态
        m_CurrRoleState = m_RoleStateDic[newState];

        if (CurrRoleStateEnum == RoleState.Idle)
        {
            //给当前待机状态赋值
            CurrIdleState = ToIdleState;
        }

        //调用新状态的进入方法
        m_CurrRoleState.OnEnter();
    }
Example #9
0
 public void ChangeStatus(RoleState state)
 {
     if (m_fsm.GetCurrentState() == state)
     {
         return;
     }
     m_fsm.ChangeState(state);
 }
Example #10
0
 /// <summary> 返回状态机中的状态 </summary>
 /// <param name="state"></param>
 /// <returns></returns>
 public RoleStateAbstract GetRoleState(RoleState state)
 {
     if (!m_RoleStateDic.ContainsKey(state))
     {
         return(null);
     }
     return(m_RoleStateDic[state]);
 }
Example #11
0
 public RoleStateAbstract GetState(RoleState stateType)
 {
     if (states.ContainsKey(stateType))
     {
         return(states[stateType]);
     }
     return(null);
 }
Example #12
0
 public PathData(tga.pathroad s)
 {
     this.Road      = MapGrid.GetMG(s.road.layer, s.road.unit);
     this.state     = (RoleState)s.state;
     this.deltaTime = s.deltaTime * 0.001f;
     this.dir       = (WalkDir)s.dir;
     this.gs        = (GridSpace)s.gs;
 }
Example #13
0
 public PathData(PathData s)
 {
     this.Road      = s.Road;
     this.state     = s.state;
     this.deltaTime = s.deltaTime;
     this.dir       = s.dir;
     this.gs        = s.gs;
 }
Example #14
0
 public RoleStateChanged(Guid actorId, int term, DateTime dateRecordedUtc, RoleState newState, RoleState oldState)
 {
     ActorId         = actorId;
     NewState        = newState;
     OldState        = oldState;
     DateRecordedUtc = dateRecordedUtc;
     Term            = term;
 }
Example #15
0
 public static RoleStateDto Map(RoleState roleState)
 {
     return(new RoleStateDto
     {
         RoleId = roleState.RoleId,
         StateId = roleState.StateId
     });
 }
Example #16
0
    public void ChangeState(RoleState state)
    {
        if (state != mRoleState)
        {
            mRoleState = state;

            refreshAnimation();
        }
    }
Example #17
0
        public bool TryGetRole(Guid roleId, out RoleState role)
        {
            if (!_initialized)
            {
                Init();
            }
            Debug.Assert(roleId != Guid.Empty);

            return(_roleDic.TryGetValue(roleId, out role));
        }
Example #18
0
        public async Task <IEnumerable <Role> > ListRoles(RoleState states = 0, bool?showInherited = null, ulong?accountId = null)
        {
            var response = await RawListRoles(accountId?.ToString() ?? "self",
                                              states.GetFlags().Select(f => f.GetApiRepresentation()),
                                              showInherited);

            var models = await AccumulateDeserializePages <RoleModel>(response);

            return(from model in models
                   select new Role(this, model));
        }
Example #19
0
 /// <summary>
 /// 设置角色状态
 /// </summary>
 /// <param name="id">角色id</param>
 /// <param name="state"></param>
 public void SetRoleState(string id, RoleState state)
 {
     if (rolesState.ContainsKey(id))
     {
         rolesState[id] = state;
     }
     else
     {
         rolesState.Add(id, state);
     }
 }
Example #20
0
            private void Handle(IAcSession acSession, IRoleCreateIo input, bool isCommand)
            {
                var acDomain       = _set._acDomain;
                var roleDic        = _set._roleDic;
                var roleRepository = acDomain.RetrieveRequiredService <IRepository <Role> >();

                if (!input.Id.HasValue)
                {
                    throw new ValidationException("标识是必须的");
                }
                Role entity;

                lock (Locker)
                {
                    RoleState role;
                    if (acDomain.RoleSet.TryGetRole(input.Id.Value, out role))
                    {
                        throw new ValidationException("已经存在");
                    }
                    if (acDomain.RoleSet.Any(a => string.Equals(a.Name, input.Name, StringComparison.OrdinalIgnoreCase)))
                    {
                        throw new ValidationException("同名的角色已经存在");
                    }

                    entity = Role.Create(input);

                    if (!roleDic.ContainsKey(entity.Id))
                    {
                        var state = RoleState.Create(entity);
                        roleDic.Add(entity.Id, state);
                    }
                    if (isCommand)
                    {
                        try
                        {
                            roleRepository.Add(entity);
                            roleRepository.Context.Commit();
                        }
                        catch
                        {
                            if (roleDic.ContainsKey(entity.Id))
                            {
                                roleDic.Remove(entity.Id);
                            }
                            roleRepository.Context.Rollback();
                            throw;
                        }
                    }
                }
                if (isCommand)
                {
                    acDomain.MessageDispatcher.DispatchMessage(new RoleAddedEvent(acSession, entity, input, isPrivate: true));
                }
            }
Example #21
0
        /// <summary>
        /// 更改角色的状态
        /// </summary>
        /// <returns></returns>
        public static int UpdateState(string roleName, RoleState us)
        {
            //OracleDatabase db = new OracleDatabase(UserSecurity.ConnectionString);
            OracleDatabase db  = new OracleDatabase(DataAccess.OIDSConnStr);
            string         sql = "UPDATE PLM.ROLE_TAB SET STATE=:state WHERE LOWER(ROLENAME)=:rolename";
            DbCommand      cmd = db.GetSqlStringCommand(sql);

            db.AddInParameter(cmd, "state", DbType.String, us.ToString());
            db.AddInParameter(cmd, "rolename", DbType.String, roleName.ToLower());
            return(db.ExecuteNonQuery(cmd));
        }
        public IRoleState Get(string id)
        {
            IRoleState state = CurrentSession.Get <RoleState> (id);

            if (state == null)
            {
                state = new RoleState();
                (state as RoleState).RoleId = id;
            }
            return(state);
        }
Example #23
0
 public static void SetState(MemoryData stateItem, RoleState state)
 {
     if (state == RoleState.has)
     {
         stateItem.HexVal = "0x0b";
     }
     else
     {
         stateItem.HexVal = "0x00";
     }
 }
Example #24
0
        internal static void SetRoleState(object value, IPropertyBag propertyBag)
        {
            RoleState roleState = (RoleState)value;
            int       num       = (int)propertyBag[ExchangeRoleSchema.RoleFlags];

            num |= 1;
            if (roleState == RoleState.Usable)
            {
                num &= -2;
            }
            propertyBag[ExchangeRoleSchema.RoleFlags] = num;
        }
Example #25
0
        public IReadOnlyCollection <RoleState> GetDescendantRoles(RoleState role)
        {
            if (!_initialized)
            {
                Init();
            }
            if (role == null)
            {
                throw new ArgumentNullException("role");
            }

            return(!_descendantRoles.ContainsKey(role) ? new List <RoleState>() : _descendantRoles[role]);
        }
Example #26
0
    //void OnGUI()
    //{
    //    if (GUILayout.Button("Init"))
    //    {
    //        AnimComponet.CrossFade("LoginPoses01");
    //    }
    //    if (GUILayout.Button("GotoFront"))
    //    {
    //        AnimComponet.CrossFade("LoginPoses02");
    //    }
    //    if (GUILayout.Button("Back"))
    //    {
    //        AnimComponet.CrossFade("LoginPoses04");
    //    }
    //    if (GUILayout.Button("Show"))
    //    {
    //        AnimComponet.CrossFade("LoginPoses03");
    //    }
    //}
    void PlayAnim(RoleState state, int vocation)
    {
        if (m_curRoleData._VocationID != vocation)
        {
            if (m_roleState == RoleState.Show)
            {
                m_roleState = RoleState.Back;
            }
            else if (m_roleState == RoleState.Click)
            {
                StartCoroutine(LockRoleClick());
                m_roleState = RoleState.Init;
            }
            else
            {
                //if(m_curRoleData._VocationID==1)
                //Debug.Log("状态1:" + m_curRoleData._VocationID + "  " + m_roleState);
                return;
            }
        }
        else
        {
            m_roleState = state;
        }

        m_curAnimList.Clear();
        m_index  = 0;
        animTime = 0;

        switch (m_roleState)
        {
        case RoleState.Init:
            m_curAnimList.Add(m_curRoleData._InitAnim);
            break;

        case RoleState.Click:
            for (int i = 0; i < m_curRoleData._AnimList.Length; i++)
            {
                m_curAnimList.Add(m_curRoleData._AnimList[i]);
            }
            break;

        case RoleState.Show:
            m_curAnimList.Add(m_curRoleData._StopAnim);
            break;

        case RoleState.Back:
            m_curAnimList.Add(m_curRoleData._BackAnim);
            break;
        }
    }
Example #27
0
        public void CalculateHpPercent(Image image)
        {
            List <Color> colors = new List <Color>();
            int          num    = int.Parse(this._config.HpRect.Left);
            int          num1   = int.Parse(this._config.HpRect.Right);
            int          num2   = int.Parse(this._config.HpRect.Top);
            int          num3   = int.Parse(this._config.HpRect.Down);
            int          num4   = 0;

            using (Bitmap bitmap = new Bitmap(image))
            {
                for (int i = num; i < num1; i++)
                {
                    int r = 0;
                    int g = 0;
                    int b = 0;
                    for (int j = num2; j < num3; j++)
                    {
                        Color pixel = bitmap.GetPixel(i, j);
                        g += pixel.G;
                        b += pixel.B;
                        r += pixel.R;
                    }
                    r = r / (num3 - num2);
                    g = g / (num3 - num2);
                    b = b / (num3 - num2);
                    if (r > 100 && g < 50 && b < 50)
                    {
                        this.State = RoleState.Detoxification;
                        colors.Add(Color.FromArgb(r, g, b));
                        num4--;
                    }
                    else if (r < 20 && g > 50 && b < 20)
                    {
                        colors.Add(Color.FromArgb(r, g, b));
                        num4++;
                    }
                }
            }
            if (num4 >= 0)
            {
                this.State = RoleState.Detoxification;
            }
            else
            {
                this.State = RoleState.Normal;
            }
            int count = colors.Count * 100 / (num1 - num);

            this.Hp = count;
        }
Example #28
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKey(KeyCode.W))
     {
         if (_roleState != RoleState.Run)
         {
             _animator.SetTrigger("ToRun");
             _roleState = RoleState.Run;
         }
         transform.localEulerAngles = new Vector3(0, 0, 0);
         transform.position        += transform.forward * 0.1f;
     }
     else if (Input.GetKey(KeyCode.S))
     {
         if (_roleState != RoleState.Run)
         {
             _animator.SetTrigger("ToRun");
             _roleState = RoleState.Run;
         }
         transform.localEulerAngles = new Vector3(0, 180, 0);
         transform.position        += transform.forward * 0.1f;
     }
     else if (Input.GetKey(KeyCode.A))
     {
         if (_roleState != RoleState.Run)
         {
             _animator.SetTrigger("ToRun");
             _roleState = RoleState.Run;
         }
         transform.localEulerAngles = new Vector3(0, 270, 0);
         transform.position        += transform.forward * 0.1f;
     }
     else if (Input.GetKey(KeyCode.D))
     {
         if (_roleState != RoleState.Run)
         {
             _animator.SetTrigger("ToRun");
             _roleState = RoleState.Run;
         }
         transform.localEulerAngles = new Vector3(0, 90, 0);
         transform.position        += transform.forward * 0.1f;
     }
     else
     {
         if (_roleState != RoleState.Idle)
         {
             _animator.SetTrigger("ToIdle");
             _roleState = RoleState.Idle;
         }
     }
 }
Example #29
0
 //空中跳
 void _JumpInTheSky(float speed, bool isMultijump)
 {
     //空中跳板动画
     if (isMultijump)
     {
         _animator.DoubleJumpEffect(transform.position);
     }
     //print("空中跳");
     remainJumpTimes--;
     readyJump = false;
     //执行跳
     state            = RoleState.Raising;
     jumpInstantSpeed = speed * 1f;
 }
Example #30
0
 private void RecAncestorRoles(RoleState childRole, List <RoleState> ancestors)
 {
     foreach (var item in _acDomain.PrivilegeSet.Where(a => a.SubjectType == AcElementType.Role && a.ObjectType == AcElementType.Role))
     {
         if (item.ObjectInstanceId == childRole.Id)
         {
             RoleState role;
             if (_acDomain.RoleSet.TryGetRole(item.SubjectInstanceId, out role))
             {
                 RecAncestorRoles(role, ancestors);
                 ancestors.Add(role);
             }
         }
     }
 }
Example #31
0
 /// <summary>
 /// ���Ľ�ɫ��״̬
 /// </summary>
 /// <returns></returns>
 public static int UpdateState(string roleName, RoleState us)
 {
     //OracleDatabase db = new OracleDatabase(UserSecurity.ConnectionString);
     OracleDatabase db = new OracleDatabase(DataAccess.OIDSConnStr);
     string sql = "UPDATE PLM.ROLE_TAB SET STATE=:state WHERE LOWER(ROLENAME)=:rolename";
     DbCommand cmd = db.GetSqlStringCommand(sql);
     db.AddInParameter(cmd, "state", DbType.String, us.ToString());
     db.AddInParameter(cmd, "rolename", DbType.String, roleName.ToLower());
     return db.ExecuteNonQuery(cmd);
 }
Example #32
0
 /// <summary>
 /// 删除激活角色。
 /// </summary>
 /// <param name="role"></param>
 public void DropActiveRole(RoleState role)
 {
     if (!_initialized)
     {
         Init();
     }
     if (this.Roles != null)
     {
         this.Roles.Remove(role);
     }
     if (this._authorizedRoles == null) return;
     this.AuthorizedRoleIds.Remove(role.Id);
     this._authorizedRoles.Remove(role);
 }