public ResponseModel Login(string accout, string password) { // arge check if (string.IsNullOrEmpty(accout)) { return new ResponseModel { code = 0, result = "Accout is null" } } ; if (string.IsNullOrEmpty(password)) { return new ResponseModel { code = 0, result = "Password is null" } } ; // 用户 判断 var loginUser = _dbContext.user.FirstOrDefault(c => c.LoginAccount == accout); if (loginUser == null) { return new ResponseModel { code = 0, result = "Account isn't exit " } } ; if (loginUser.IsEnabled == 0) { return new ResponseModel { code = 0, result = "Account isn't enabled" } } ; string pw = PassHelper.SingleTon().EncryptByMd5(loginUser.LoginKey + password); if (loginUser.LoginPassword == pw) { return(new ResponseModel { code = 200, data = new Response_User { Id = loginUser.Id, RoleId = loginUser.RoleId, Name = loginUser.Name, LoginAccount = loginUser.LoginAccount, IsEnabled = loginUser.IsEnabled }, result = "Account isn't enabled" }); } return(new ResponseModel { code = 0, result = "Login Fail" }); } } }
public static bool Create(string email, string password) { DataEntity data = new DataEntity() { User = new UserEntity() }; data.User.Email = email; data.User.Passcode = PassHelper.EnPasscode(email, password); return(DataFileHelper.Create(data)); }
public static bool Write(DataEntity data) { if (data != null && data.User != null && Str.Ok(data.User.Email, data.User.Passcode)) { string s = PassHelper.EnData(data); string file = R.Files.GetUserDataFile(data.User.Email); string cache = R.Files.GetUserDataCacheFile(data.User.Email); bool f1 = TxtTool.Create(cache, s); if (f1) { bool f2 = FileTool.Copy(cache, file, true); return(f2); } } return(false); }
private void BtnConfirm_Click(object sender, EventArgs e) { string email = TbxEmail.Text; string password = TbxPassword.Text; if (Str.Ok(email, password)) { string passcode = PassHelper.EnPasscode(email, password); if (UserHelper.Login(email, passcode)) { R.Data.User.Email = email; R.Data.User.Passcode = passcode; R.Toast.Show("登录", "登陆成功"); Close(); } else { R.Toast.Show("登录", "登陆失败", 'e'); } } }
public static DataEntity Read(string email, string passcode) { DataEntity result = null; if (Str.Ok(email, passcode)) { string file = R.Files.GetUserDataFile(email); string cache = R.Files.GetUserDataCacheFile(email); string s = TxtTool.Read(file); string s_c = TxtTool.Read(cache); DataEntity d = PassHelper.DeData(s, email, passcode); DataEntity d_s = PassHelper.DeData(s, email, passcode); if (d != null && d_s == null) { result = d; } if (d == null && d_s != null) { result = d_s; } if (d != null && d_s != null) { if (d.UpdateTime > d_s.UpdateTime) { result = d; } else { result = d_s; } } if (result != null) { R.Data = result; } } return(result); }
override public void OnEnter(PlayerState lastState) { base.OnEnter(lastState); m_failReason = FailReason.None; Player attacker = m_ball.m_actor; if (attacker == null) { attacker = m_ball.m_owner; } //main player bool bBlockable = false, bBlockInRange = false; IM.Number fBlockRate = IM.Number.zero, fBlockValue = IM.Number.zero; IM.Vector3 attackerPos = IM.Vector3.zero; bool bValid = false; m_success = false; IM.Vector3 vBallVel = IM.Vector3.zero; IM.Vector3 vBallPos = IM.Vector3.zero; if (attacker != null) { m_player.FaceTo(attacker.position); //shooter is blocked.. set a ball solution to him m_failedShootSolution = GameSystem.Instance.shootSolutionManager.GetShootSolution(m_basket.m_vShootTarget, attacker.position, false); if (m_failedShootSolution == null) { Debug.LogError("No shoot solution can be set to block."); } m_bMoveForward = false; m_speed = IM.Vector3.zero; m_bFailDown = false; if (!m_ball.m_bBlockSuccess && m_ball.m_picker == null) { m_heightScale = IM.Number.one; if (m_ball != null && !m_ball.m_bReachMaxHeight && (m_ball.m_ballState == BallState.eUseBall_Shoot || m_ball.m_ballState == BallState.eUseBall)) { if (attacker.m_StateMachine.m_curState.m_eState == State.eShoot) { m_success = _CalcBlockShoot(attacker, out bBlockable, out bBlockInRange, out fBlockRate, out fBlockValue, out attackerPos, out vBallVel, out bValid); if (m_success) { _BeginBlockShoot(m_failedShootSolution, attacker, out vBallPos); } } else if (attacker.m_StateMachine.m_curState.m_eState == State.eLayup) { m_success = _CalcBlockLayup(attacker, out bBlockable, out bBlockInRange, out fBlockRate, out fBlockValue, out attackerPos, out vBallVel, out bValid); if (m_success) { _BeginBlockLayup(m_failedShootSolution, attacker, out vBallPos); } } else if (attacker.m_StateMachine.m_curState.m_eState == State.eDunk) { m_success = _CalcBlockDunk(attacker, out bBlockable, out bBlockInRange, out fBlockRate, out fBlockValue, out attackerPos, out vBallVel, out bValid); if (m_success) { _BeginBlockDunk(attacker, out vBallPos); } } else { Debug.Log("Block failed, cur attacker state: " + attacker.m_StateMachine.m_curState.m_eState); m_success = false; } string rateLog = "Block rate: " + fBlockRate + " value: " + fBlockValue; Debugger.Instance.m_steamer.message = rateLog; Debug.Log(rateLog); Debug.Log("block success: " + m_success); Debug.Log("block ball pos: " + vBallPos + ", vel: " + vBallVel); if (!m_success) { Debug.Log("Block fail reason: " + m_failReason); } m_player.mStatistics.SkillUsageSuccess(m_curExecSkill.skill.id, m_success); } else { m_success = false; Debug.Log("496 failed."); m_failReason = FailReason.TooLate; } }//if( !m_ball.m_bBlockSuccess ) } if (m_curExecSkill.skill.id == idBlockPassBall || m_curExecSkill.skill.id == idBlockGrabBall) { if (m_ball.m_picker != null || m_ball.m_bGoal) { m_success = false; } else { m_ball.m_picker = m_player; } } if (!m_success) { m_speed = m_player.forward; m_bMoveForward = false; if (attacker != null && attacker.m_StateMachine.m_curState.m_eState == State.eDunk && GameUtils.HorizonalDistance(m_player.position, attacker.position) < IM.Number.one) { m_bFailDown = IM.Random.value > IM.Number.half; } } if (!m_success) { List <SkillInstance> basicBlockSkills = m_player.m_skillSystem.GetBasicSkillsByCommand(Command.Block); m_curExecSkill = basicBlockSkills[0]; } else { //m_curExecSkill = _DecideBlockSkill(); bool bBlockPass = false; if (m_curExecSkill.skill.id == idBlockPassBall) { int value = IM.Random.Range(0, 2); bBlockPass = true; if (value == 0) { Player catcher = PassHelper.ChoosePassTarget(m_player); if (catcher != null) { m_player.m_passTarget = catcher; } } } m_loseBallContext.vInitPos = vBallPos; m_loseBallContext.vInitVel = vBallVel; } m_player.animMgr.Play(m_curAction, false); ++m_player.mStatistics.data.block_times; if (bValid) { ++m_player.mStatistics.data.valid_block_times; } }
public void CommandToAction(Command cmd) { if (!m_enable) { return; } //特殊处理:自动盯防生效时,加速键显示,但无效 if (m_player.m_team.m_role == GameMatch.MatchRole.eDefense && _autoDefTakeOver.InTakeOver && cmd == Command.Rush) { return; } curCommand = cmd; //if( !(GameSystem.Instance.mClient.mCurMatch is GameMatch_PVP) ) { if (m_player.m_StateMachine.assistAI != null) { m_player.m_StateMachine.assistAI.curCommand = cmd; } } //buffer command PlayerState curState = m_player.m_StateMachine.m_curState; if (curState is PlayerState_Skill) { Command curCmd = Command.None; if (curState.m_curExecSkill != null) { curCmd = (Command)curState.m_curExecSkill.skill.action_type; } //Debug.Log("Cur skill type:" + curCmd); if (cmd != curCmd) { if (cmd != bufferedCommand) { //Debug.Log("Buffer command:" + cmd); bufferedCommand = cmd; bufferedTime = COMMAND_BUFFER_TIME; } } else { if (cmd == bufferedCommand) { //Debug.Log("Clear buffer command for casted."); bufferedCommand = Command.None; } } } /* * if (cmd == Command.Boxout) * { * m_player.m_StateMachine.SetState(PlayerState.State.eBoxout); * return; * } */ if (cmd == Command.Switch) { GameMatch_MultiPlayer match = m_match as GameMatch_MultiPlayer; if (match != null) { match.OnSwitch(m_player.m_team.m_side); } } //for prepare shoot if (cmd == Command.Shoot && curState.m_eState == PlayerState.State.ePrepareToShoot) { //m_player.m_bToShoot = true; PlayerState_PrepareToShoot prepareShoot = m_player.m_StateMachine.GetState(PlayerState.State.ePrepareToShoot) as PlayerState_PrepareToShoot; m_player.m_toSkillInstance = prepareShoot.mCachedShootSkill; return; } if (cmd == Command.Pass) { if (m_player.m_passTarget == null) { m_player.m_passTarget = PassHelper.ChoosePassTarget(m_player); } } SkillInstance skill = m_player.m_skillSystem.GetValidSkillInMatch(cmd); //Debug.Log( Time.frameCount + "skill: " + (skill != null ? skill.skill.name : "NULL" )); if (skill == null) { //Debug.LogError("Can not get valid skill, check config."); return; } //failed to dunk /* * if( (Command)skill.skill.action_type == Command.Dunk || (Command)skill.skill.action_type == Command.Layup ) * { * if( m_player.m_defenseTarget != null ) * { * Player nearestValidDefender = null; * float fNearestDist = float.MaxValue; * foreach(Player pl in m_player.m_defenseTarget.m_team) * { * if( m_player.m_AOD.GetStateByPos(pl.position) != AOD.Zone.eInvalid ) * { * float fDist = GameUtils.HorizonalDistance(m_player.position, pl.position); * if( fDist > fNearestDist ) * continue; * fNearestDist = fDist; * nearestValidDefender = pl; * } * } * if( nearestValidDefender != null ) * { * float fDist = GameUtils.HorizonalDistance(m_player.position, nearestValidDefender.position); * if( fDist < skill.skill.attrange ) * { * //if( !m_player.m_bSimulator ) * // m_player.m_StateMachine.SetState(PlayerState.State.eLayupFailed); * if( !m_player.m_bSimulator ) * ShootHelper.ShootByArea(m_player, GameSystem.Instance.mClient.mCurMatch); * return; * } * } * } * } */ skill.curInput.inputType = InputDirType.eBasket; skill.curInput.cmd = cmd; skill.curInput.moveDir = m_player.m_inputDispatcher.GetMoveDirection(InputDirType.eBasket); /* * SkillInput input = skill.curAction.inputs[0]; * if( (Command)skill.skill.action_type == Command.CrossOver && input.moveDir == EDirection.eNone ) * { * Player defender = m_player.m_defenseTarget; * if (defender != null) * { * Vector3 dirPlayerToDefenser = (defender.position - m_player.position).normalized; * float angle = Quaternion.FromToRotation(dirPlayerToDefenser, m_player.right).eulerAngles.y; * bool horiCross = (45f < angle && angle < 135f); * bool left = angle < 90f || angle > 270f; * List<SkillInstance> crossSkills = m_player.m_skillSystem.GetSkillList(SkillType.ACTIVE, Command.CrossOver); * SkillInstance inst = AIUtils.ChooseCrossSkill(crossSkills, horiCross, left); * if (m_player.m_stamina.m_curStamina.ToUnity() >= (float)inst.skill.levels[inst.level].stama ) * skill = inst; * } * } */ m_player.m_toSkillInstance = skill; Debug.Log("skill id: " + m_player.m_toSkillInstance.skill.id); }
protected void _UpdatePassiveStateTransaction(SkillInstance newSkill) { if (newSkill == null) { return; } //Debug.Log(m_player.m_id + " Execute skill " + newSkill.skill.id + " " + newSkill.skill.name); Command cmd = (Command)newSkill.skill.action_type; if (!IsCommandValid(cmd)) { Debug.Log("Command " + cmd + " invalid. State: " + m_eState); return; } switch (cmd) { case Command.Shoot: ShootHelper.ShootByInput(m_player); break; case Command.Block: m_stateMachine.SetState(PlayerState.State.eBlock, true); break; case Command.CrossOver: m_stateMachine.SetState(PlayerState.State.eCrossOver, true); break; case Command.Dunk: m_stateMachine.SetState(PlayerState.State.eDunk, true); break; case Command.Layup: m_stateMachine.SetState(PlayerState.State.eLayup, true); break; case Command.MoveStep: m_stateMachine.SetState(PlayerState.State.eMoveStep, true); break; case Command.Boxout: m_stateMachine.SetState(PlayerState.State.eStand); break; case Command.Steal: m_stateMachine.SetState(PlayerState.State.eSteal, true); break; case Command.Pass: { if (m_player.m_passTarget == null) { m_player.m_passTarget = PassHelper.ChoosePassTarget(m_player); } if (m_player.m_passTarget != null) { m_stateMachine.SetState(PlayerState.State.ePass, true); } } break; case Command.Rebound: m_stateMachine.SetState(PlayerState.State.eRebound, true); break; case Command.RequireBall: m_stateMachine.SetState(PlayerState.State.eRequireBall); break; case Command.CutIn: m_stateMachine.SetState(PlayerState.State.eCutIn); break; case Command.BodyThrowCatch: m_stateMachine.SetState(PlayerState.State.eBodyThrowCatch); break; case Command.BackToBack: m_stateMachine.SetState(PlayerState.State.eBackToBack); break; case Command.PickAndRoll: m_stateMachine.SetState(PlayerState.State.ePickAndRoll); break; case Command.Defense: m_stateMachine.SetState(PlayerState.State.eDefense); break; case Command.Interception: m_stateMachine.SetState(PlayerState.State.eInterception); break; default: m_stateMachine.SetState(PlayerState.State.eStand); break; } }