protected virtual HandModel BuildGraphicalHand(Chirality handedness) { //var primitive = GameObject.CreatePrimitive(PrimitiveType.Sphere); var handObj = UnityHelper.LoadFromAssetBundle <GameObject>( #if UNITY_4_5 VRGIN.U46.U46.Resource.hands, #else ResourceManager.Hands, #endif "LoPoly_Rigged_Hand_" + handedness ); var hand = SetUpRiggedHand(handObj, handedness); //hand._material = new Material(VR.Context.Materials.StandardShader); //hand._sphereMesh = primitive.GetComponent<MeshFilter>().sharedMesh; hand.gameObject.AddComponent <HandEnableDisable>(); //Destroy(primitive); return(hand); }
public void RegisterInstance_ContainerNull() { var helper = new UnityHelper(); ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => helper.RegisterInstance(null, typeof(ITestInterface), new TestClass1())); }
/// <summary> /// Copies the values of a in-game camera to the VR camera. /// </summary> /// <param name="blueprint">The camera to copy.</param> public void Copy(Camera blueprint) { VRLog.Info("Copying camera: {0}", blueprint ? blueprint.name : "NULL"); Blueprint = blueprint ?? GetComponent <Camera>(); int cullingMask = Blueprint.cullingMask; // If the camera is blind, set it to see everything instead if (cullingMask == 0) { cullingMask = int.MaxValue; } else { // Apply additional culling masks foreach (var subCamera in VR.Interpreter.FindSubCameras()) { if (!subCamera.name.Contains(SteamCam.baseName)) { cullingMask |= subCamera.cullingMask; } } } // Remove layers that are captured by other cameras (see VRGUI) cullingMask |= LayerMask.GetMask("Default"); cullingMask &= ~(LayerMask.GetMask(VR.Context.UILayer, VR.Context.InvisibleLayer)); cullingMask &= ~(VR.Context.IgnoreMask); VRLog.Info("The camera sees {0}", string.Join(", ", UnityHelper.GetLayerNames(cullingMask))); // Apply to both the head camera and the VR camera ApplyToCameras(targetCamera => { targetCamera.nearClipPlane = 0.01f; targetCamera.farClipPlane = Blueprint.farClipPlane; targetCamera.cullingMask = cullingMask; targetCamera.clearFlags = Blueprint.clearFlags == CameraClearFlags.Skybox ? CameraClearFlags.Skybox : CameraClearFlags.SolidColor; targetCamera.backgroundColor = Blueprint.backgroundColor; var skybox = Blueprint.GetComponent <Skybox>(); if (skybox != null) { var vrSkybox = targetCamera.gameObject.GetComponent <Skybox>(); if (vrSkybox == null) { vrSkybox = vrSkybox.gameObject.AddComponent <Skybox>(); } vrSkybox.material = skybox.material; } // Hook InitializeCamera(this, new InitializeCameraEventArgs(targetCamera, Blueprint)); }); // Only execute this code when the blueprint is a different camera HasValidBlueprint = Blueprint != GetComponent <Camera>(); if (HasValidBlueprint) { //StartCoroutine(ExecuteDelayed(delegate { CopyFX(Blueprint); })); //CopyFX(Blueprint); Blueprint.cullingMask = 0; Blueprint.nearClipPlane = Blueprint.farClipPlane = 0; //Blueprint.targetTexture = _MiniTexture; //Blueprint.gameObject.AddComponent<BlacklistThrottler>(); // Highlander principle var listener = Blueprint.GetComponent <AudioListener>(); if (listener) { Destroy(listener); } } }
private static void PersistenceChinookTransactionDemo(bool isCommit = true) { if (isCommit) { Console.WriteLine("\nPersistence Chinook Transaction Demo with Commit"); } else { Console.WriteLine("\nPersistence Chinook Transaction Demo with Rollback"); } var container = new UnityContainer(); UnityHelper.RegisterMappings(container); IUnitOfWork unitOfWork = (IUnitOfWork)container.Resolve <IChinookUnitOfWork>(); IGenericRepository <Artist> repository = unitOfWork.GetRepository <Artist>(); ZOperationResult operationResult = new ZOperationResult(); try { unitOfWork.BeginTransaction(operationResult); Artist artist; artist = new Artist(0, "Artist 1"); if (repository.Create(operationResult, artist) && unitOfWork.Save(operationResult)) { artist = new Artist(0, "Artist 2"); if (repository.Create(operationResult, artist) && unitOfWork.Save(operationResult)) { artist = new Artist(0, "Artist 3"); if (repository.Create(operationResult, artist)) { unitOfWork.Save(operationResult); } } } } catch (Exception exception) { operationResult.ParseExceptionEntityFramework(exception); unitOfWork.RollbackTransaction(operationResult); } finally { if (isCommit) { unitOfWork.CommitTransaction(operationResult); } else { unitOfWork.RollbackTransaction(operationResult); } } if (!operationResult.Ok) { Console.WriteLine("\n"); Console.WriteLine(operationResult.Text); } }
private void Update() { UnityHelper.FaceToGoal(cube1, cube2, 0.1f); UnityHelper.FaceToGoal(cube3, cube2, 0.1f); }
public static void start(string _ConfigFile) { IUnityContainer container = UnityHelper.GetUnityContainer(); container.RegisterType <MyCodeSqlSugarClient>(new PerThreadLifetimeManager()); //注册缓存对象 container.RegisterType <IMyCodeCacheService, RedisCache>(new InjectionConstructor(SystemConfig.RedisAddress, SystemConfig.CachePrefix)); container.AddNewExtension <QuartzUnityExtension>(); ConfigFile = _ConfigFile; List <jobinfo> list = new List <jobinfo>(); try { if (sched != null) { stop(); sched = null; } //sched = new StdSchedulerFactory().GetScheduler(); sched = container.Resolve <IScheduler>(); XmlDocument document = new XmlDocument(); document.Load(ConfigFile); XmlNode node = document.SelectSingleNode("Jobs"); if (node.ChildNodes.Count > 0) { foreach (XmlNode node2 in node.ChildNodes) { jobinfo item = new jobinfo { name = node2.Attributes["name"].Value, type = node2.Attributes["type"].Value, CronExpression = node2.Attributes["CronExpression"].Value, enabled = bool.Parse(node2.Attributes["enabled"].Value) }; if (item.enabled) { list.Add(item); IJobDetail jobDetail = JobBuilder.Create(Type.GetType(item.type)).WithIdentity(item.name, item.name + "Group").Build(); ITrigger trigger = TriggerBuilder.Create().WithIdentity(item.name, item.name + "Group").WithCronSchedule(item.CronExpression).Build(); sched.ScheduleJob(jobDetail, trigger); } } if (list.Count > 0) { sched.Start(); } else { Console.WriteLine("暂未有计划任务开启1"); } } else { Console.WriteLine("暂未有计划任务开启"); } } catch (Exception exception) { Console.WriteLine(JsonConvert.SerializeObject(list)); Console.WriteLine(exception); LogHelper.Error("出错", exception); } Console.ReadKey(); }
public async Task <T> GetById(int id) { ISampleData <T> data = UnityHelper.Retrieve <ISampleData <T> >(); return(await Task.Run(() => data.DbSet.First(x => x.Id == id))); }
protected void CatchCanvas() { _VRGUICamera.targetTexture = uGuiTexture; var canvasList = (_Registry.Keys as ICollection <Canvas>).Where(c => c).ToList(); //var canvasList = GameObject.FindObjectsOfType<Canvas>(); foreach (var canvas in canvasList.Where(IsUnprocessed)) { if (VR.Interpreter.IsIgnoredCanvas(canvas)) { continue; } VRLog.Debug("Add {0} [Layer: {1}, SortingLayer: {2}, SortingOrder: {3}, RenderMode: {4}, Camera: {5}, Position: {6} ]", canvas.name, LayerMask.LayerToName(canvas.gameObject.layer), canvas.sortingLayerName, canvas.sortingOrder, canvas.renderMode, canvas.worldCamera, canvas.transform.position); //if (canvas.name.Contains("TexFade")) continue; canvas.renderMode = RenderMode.ScreenSpaceCamera; canvas.worldCamera = _VRGUICamera; // Make sure that all Canvas are in the UI layer if (((1 << canvas.gameObject.layer) & VR.Context.UILayerMask) == 0) { var uiLayer = LayerMask.NameToLayer(VR.Context.UILayer); canvas.gameObject.layer = uiLayer; foreach (var child in canvas.gameObject.GetComponentsInChildren <Transform>()) { child.gameObject.layer = uiLayer; } } if (VR.Context.EnforceDefaultGUIMaterials) { foreach (var child in canvas.gameObject.GetComponentsInChildren <Graphic>()) { child.material = child.defaultMaterial; } } if (VR.Context.GUIAlternativeSortingMode) { var raycaster = canvas.GetComponent <GraphicRaycaster>(); if (raycaster) { GameObject.DestroyImmediate(raycaster); var newRaycaster = canvas.gameObject.AddComponent <SortingAwareGraphicRaycaster>(); // These fields turned into properties in Unity 4.7+ UnityHelper.SetPropertyOrField(newRaycaster, "ignoreReversedGraphics", UnityHelper.GetPropertyOrField(raycaster, "ignoreReversedGraphics")); UnityHelper.SetPropertyOrField(newRaycaster, "blockingObjects", UnityHelper.GetPropertyOrField(raycaster, "blockingObjects")); UnityHelper.SetPropertyOrField(newRaycaster, "m_BlockingMask", UnityHelper.GetPropertyOrField(raycaster, "m_BlockingMask")); } } } }
void OnExitClick() { UIManager um = UnityHelper.GetUIManager(); um.MessageBox("退出游戏?", true, this.MsgBoxCb); }
protected virtual IEnumerable <IShortcut> CreateShortcuts() { return(new List <IShortcut>() { new KeyboardShortcut(new KeyStroke("Alt + KeypadMinus"), delegate { VR.Settings.IPDScale += Time.deltaTime * 0.1f; }, KeyMode.Press), new KeyboardShortcut(new KeyStroke("Alt + KeypadPlus"), delegate { VR.Settings.IPDScale -= Time.deltaTime * 0.1f; }, KeyMode.Press), new VoiceShortcut(VoiceCommand.DecreaseScale, delegate { VR.Settings.IPDScale *= 1.2f; }), // Decrease / Increase scale of the *world* (inverse of camera scale!) new VoiceShortcut(VoiceCommand.IncreaseScale, delegate { VR.Settings.IPDScale *= 0.8f; }), new MultiKeyboardShortcut(new KeyStroke("Ctrl + C"), new KeyStroke("Ctrl + D"), delegate { UnityHelper.DumpScene("dump.json"); }), new MultiKeyboardShortcut(new KeyStroke("Ctrl + C"), new KeyStroke("Ctrl + I"), delegate { VRGIN.Helpers.Profiler.FindHotPaths(delegate {}); }), new MultiKeyboardShortcut(new KeyStroke("Ctrl + C"), new KeyStroke("Ctrl + V"), ToggleUserCamera), new KeyboardShortcut(new KeyStroke("Alt + S"), delegate { VR.Settings.Save(); }), new VoiceShortcut(VoiceCommand.SaveSettings, delegate { VR.Settings.Save(); }), new KeyboardShortcut(new KeyStroke("Alt + L"), delegate { VR.Settings.Reload(); }), new VoiceShortcut(VoiceCommand.LoadSettings, delegate { VR.Settings.Reload(); }), new KeyboardShortcut(new KeyStroke("Ctrl + Alt + L"), delegate { VR.Settings.Reset(); }), new VoiceShortcut(VoiceCommand.ResetSettings, delegate { VR.Settings.Reset(); }), new VoiceShortcut(VoiceCommand.Impersonate, delegate { Impersonate(VR.Interpreter.Actors.FirstOrDefault()); }), //new MultiKeyboardShortcut(new KeyStroke("Ctrl + C"), new KeyStroke("Ctrl+B"), delegate { // ProtectedBehaviour.DumpTable(); //}) new KeyboardShortcut(new KeyStroke("Ctrl + F5"), delegate { VR.Camera.CopyFX(VR.Camera.Blueprint); }, KeyMode.PressUp), }); }
/// <summary>Registers the type mappings with the Unity container.</summary> /// <param name="container">The unity container to configure.</param> /// <remarks>There is no need to register concrete types such as controllers or API controllers (unless you want to /// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.</remarks> public static void RegisterTypes(IUnityContainer container) { UnityBuilder.Build(container); UnityHelper.GetRegistrations(container); }
/// <summary> /// Called once per lifetime of the application before the application is unloaded. /// </summary> protected void Application_End(object sender, EventArgs e) { UnityHelper.CleanUp(); }
private void InitReportInfo(BattleRoomModel battleModel, BattleRoomModel.BattleReportModel CurrentBattleReport) { switch (CurrentBattleReport.ReportType) { case BattleRoomModel.ReportType.Attack: Debug.Log("攻击战报"); if (Content_Tra != null) { GameObject m_ReportGoParent = ResourcesMgr.GetInstance().LoadResource <GameObject>("Prefab/UI/Battle/AttackReport", false); GameObject m_ReportParent = Instantiate(m_ReportGoParent); Text m_Report = UnityHelper.GetTheChildNodeComponetScripts <Text>(m_ReportParent, "AttackReport_Txt"); string m_Info; if (!CurrentBattleReport.IsAOE) { switch (CurrentBattleReport.AttackHandleType) { case BattleRoomModel.AttackHandleType.Dodge: m_Report.text = string.Format(m_NormalAttackInfoTemplete, CurrentBattleReport.ReportNum, GetAttacker(battleModel, CurrentBattleReport), GetAnAttacker(battleModel, CurrentBattleReport)) + string.Format(m_DodgeInfoTemplete, GetAnAttacker(battleModel, CurrentBattleReport)); break; case BattleRoomModel.AttackHandleType.Deathblow: m_Info = string.Format(m_NormalAttackInfoTemplete, CurrentBattleReport.ReportNum, GetAttacker(battleModel, CurrentBattleReport), GetAnAttacker(battleModel, CurrentBattleReport)) + string.Format(m_DeathblowInfoTemplete) + string.Format(m_DamageInfoTemplete, CurrentBattleReport.Damage); m_Report.text = m_Info; if (CurrentBattleReport.IsDerateDamage) { m_Report.text = m_Info + string.Format(m_DerateDamageInfoTemplete, CurrentBattleReport.DerateDamage); } break; case BattleRoomModel.AttackHandleType.Attack: m_Info = string.Format(m_NormalAttackInfoTemplete, CurrentBattleReport.ReportNum, GetAttacker(battleModel, CurrentBattleReport), GetAnAttacker(battleModel, CurrentBattleReport)) + string.Format(m_DamageInfoTemplete, CurrentBattleReport.Damage); m_Report.text = m_Info; if (CurrentBattleReport.IsDerateDamage) { m_Report.text = m_Info + string.Format(m_DerateDamageInfoTemplete, CurrentBattleReport.DerateDamage); } break; default: break; } } else { StringBuilder sb = new StringBuilder(); switch (CurrentBattleReport.AttackHandleType) { case BattleRoomModel.AttackHandleType.Dodge: m_Report.text = string.Format(m_SkillInfoTemplete, CurrentBattleReport.ReportNum, GetAttacker(battleModel, CurrentBattleReport), CurrentBattleReport.AbilityName, GetAnAttacker(battleModel, CurrentBattleReport)) + string.Format(m_DodgeInfoTemplete, GetAnAttacker(battleModel, CurrentBattleReport)); break; case BattleRoomModel.AttackHandleType.Deathblow: sb.Append(string.Format(m_SkillInfoTemplete, CurrentBattleReport.ReportNum, GetAttacker(battleModel, CurrentBattleReport), CurrentBattleReport.AbilityName, GetAnAttacker(battleModel, CurrentBattleReport)) + string.Format(m_DeathblowInfoTemplete) + string.Format(m_DamageInfoTemplete, CurrentBattleReport.Damage)); m_Report.text = sb.ToString(); if (CurrentBattleReport.IsDerateDamage) { m_Report.text = sb.Append(string.Format(m_DerateDamageInfoTemplete, CurrentBattleReport.DerateDamage)).ToString(); } if (CurrentBattleReport.IsGroupAttack) { List <BattleRoomModel.BattleCharacterModel> CharacterModelList = GetTeam(battleModel, battleModel.characterList, CurrentBattleReport); List <BattleRoomModel.BattleEnemyModel> EnemyModelList = GetTeam(battleModel, battleModel.enemyList, CurrentBattleReport); if (CharacterModelList.Count > 0 && CharacterModelList != null) { for (int i = 0; i < CharacterModelList.Count; i++) { Debug.Log(CharacterModelList[i].Name); m_Report.text = sb.Append( string.Format(m_AOEInfoTemplete, CharacterModelList[i].Name, CurrentBattleReport.Damage)).ToString(); } } else if (EnemyModelList.Count > 0 && EnemyModelList != null) { for (int i = 0; i < EnemyModelList.Count; i++) { m_Report.text = sb.Append( string.Format(m_AOEInfoTemplete, EnemyModelList[i].Name, CurrentBattleReport.Damage)).ToString(); } } } break; case BattleRoomModel.AttackHandleType.Attack: switch (CurrentBattleReport.AOEType) { case BattleRoomModel.AOEType.Attack: sb.Append(string.Format(m_SkillInfoTemplete, CurrentBattleReport.ReportNum, GetAttacker(battleModel, CurrentBattleReport), CurrentBattleReport.AbilityName, GetAnAttacker(battleModel, CurrentBattleReport)) + string.Format(m_DamageInfoTemplete, CurrentBattleReport.Damage)); m_Report.text = sb.ToString(); if (CurrentBattleReport.IsDerateDamage) { m_Report.text = sb.Append(string.Format(m_DerateDamageInfoTemplete, CurrentBattleReport.DerateDamage)).ToString();; } if (CurrentBattleReport.IsGroupAttack) { List <BattleRoomModel.BattleCharacterModel> CharacterModelList = GetTeam(battleModel, battleModel.characterList, CurrentBattleReport); List <BattleRoomModel.BattleEnemyModel> EnemyModelList = GetTeam(battleModel, battleModel.enemyList, CurrentBattleReport); if (CharacterModelList.Count > 0 && CharacterModelList != null) { for (int i = 0; i < CharacterModelList.Count; i++) { Debug.Log(CharacterModelList[i].Name); m_Report.text = sb.Append( string.Format(m_AOEInfoTemplete, CharacterModelList[i].Name, CurrentBattleReport.Damage)).ToString(); } } else if (EnemyModelList.Count > 0 && EnemyModelList != null) { for (int i = 0; i < EnemyModelList.Count; i++) { m_Report.text = sb.Append( string.Format(m_AOEInfoTemplete, EnemyModelList[i].Name, CurrentBattleReport.Damage)).ToString(); } } } break; case BattleRoomModel.AOEType.Recovery: m_Report.text = string.Format(m_RecoveryInfoTemplete, CurrentBattleReport.ReportNum, GetAttacker(battleModel, CurrentBattleReport), CurrentBattleReport.AbilityName, CurrentBattleReport.Recovery, GetAnAttacker(battleModel, CurrentBattleReport)); break; default: break; } break; default: break; } } Text Data = UnityHelper.GetTheChildNodeComponetScripts <Text>(m_ReportParent, "Data_Txt"); Data.text = DateTime.Now.ToString(); //扣血 m_ReportParent.GetComponent <RectTransform>().sizeDelta = new Vector2(m_Report.rectTransform.rect.width, m_Report.preferredHeight + Data.preferredHeight); m_ReportParent.transform.parent = Content_Tra.transform; m_ReportParent.transform.localScale = Content_Tra.transform.localScale; m_ReportParent.transform.SetAsFirstSibling(); } break; case BattleRoomModel.ReportType.Result: Debug.Log("结束战报"); if (Content_Tra != null) { GameObject m_ReportGoParent = ResourcesMgr.GetInstance().LoadResource <GameObject>("Prefab/UI/Battle/ResultReport", false); GameObject m_ReportParent = Instantiate(m_ReportGoParent); Text m_Report = UnityHelper.GetTheChildNodeComponetScripts <Text>(m_ReportParent, "ResultReport_Txt"); if (CurrentBattleReport.IsSussces) { //扣血 StringBuilder sb = new StringBuilder(); if (CurrentBattleReport.EquipmentList.Count > 0) { for (int i = 0; i < CurrentBattleReport.EquipmentList.Count; i++) { sb.Append(string.Format(m_GetEquipmentInfoTemplete, CurrentBattleReport.EquipmentList[i].name)); } } if (CurrentBattleReport.Gold > 0) { sb.Append(string.Format(m_GetGoldInfoTemplete, CurrentBattleReport.Gold)); } if (battleModel.characterList != null) { for (int i = 0; i < battleModel.characterList.Count; i++) { sb.Append(string.Format(m_GetEXPInfoTemplete, battleModel.characterList[i].Name, CurrentBattleReport.EXP)); } } sb.Append(m_SuccessResultInfoTemplete); m_Report.text = sb.ToString(); } else { m_Report.text = string.Format(m_FailureResultInfoTemplete, CurrentBattleReport.TeamName); } Debug.Log("m_Report.rectTransform.rect.height = " + m_Report.preferredHeight); Debug.Log("m_ReportParent.GetComponent<RectTransform>().rect.height) = " + m_ReportParent.GetComponent <RectTransform>().rect.height); m_ReportParent.transform.parent = Content_Tra.transform; m_ReportParent.transform.localScale = m_ReportParent.transform.parent.transform.localScale; m_ReportParent.GetComponent <RectTransform>().sizeDelta = new Vector2(m_Report.rectTransform.rect.width, m_Report.preferredHeight); m_ReportParent.transform.SetAsFirstSibling(); Debug.Log("m_Report.rectTransform.rect.height = " + m_Report.rectTransform.rect.height + m_Report.name); Debug.Log("m_ReportParent.GetComponent<RectTransform>().rect.height) = " + m_ReportParent.GetComponent <RectTransform>().rect.height + m_ReportParent.name); } break; case BattleRoomModel.ReportType.Rest: Debug.Log("休息战报"); if (Content_Tra != null) { GameObject m_ReportGoParent = ResourcesMgr.GetInstance().LoadResource <GameObject>("Prefab/UI/Battle/RestReport", false); GameObject m_ReportParent = Instantiate(m_ReportGoParent); Text m_Report = UnityHelper.GetTheChildNodeComponetScripts <Text>(m_ReportParent, "RestReport_Txt"); m_Report.text = string.Format(m_RestInfoTemplete, CurrentBattleReport.RestCountdown); //扣血 m_ReportParent.GetComponent <RectTransform>().sizeDelta = new Vector2(m_Report.rectTransform.rect.width, m_Report.rectTransform.rect.height); m_ReportParent.transform.parent = Content_Tra.transform; m_ReportParent.transform.localScale = m_ReportParent.transform.parent.transform.localScale; m_ReportParent.transform.SetAsFirstSibling(); } break; default: Debug.LogError("战报类型错误:" + CurrentBattleReport.ReportType); break; } }
public void GetRegistrationInfo_ContainerNull() { var helper = new UnityHelper(); ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => helper.GetRegistrationInfo(null, typeof(ITestInterface))); }
public void ResolveType_ContainerNull() { var helper = new UnityHelper(); ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => helper.ResolveType(null, typeof(ITestInterface))); }
/// <summary> /// 面向主角 /// </summary> private void FaceToHero() { UnityHelper.GetInstance().FaceToGoal(_MyTransform, _GoHero.transform, FloRotatSpeed); }
private static IWebNoteRepository ResolveRepository(ActionExecutedContext filterContext) { IUnityContainer container = UnityHelper.ResolveContainerFromHttpContext(filterContext.RequestContext); return(container.Resolve <IWebNoteRepository>()); }
public AdminUsersForm() { _userService = UnityHelper.Resolve <IUserService>(); InitializeComponent(); }
public async Task <IEnumerable <T> > GetAll() { ISampleData <T> data = UnityHelper.Retrieve <ISampleData <T> >(); return(await Task.Run(() => data.DbSet.AsEnumerable())); }
public Player AddPlayer(ControllerType type, int id, string name) { if (playerDict.ContainsKey(id)) { return(null); } Player player = null; switch (type) { case ControllerType.Local: if (GlobalVariables.localPlayer == null) { player = Instantiate(playerPrefab).GetComponent <Player>(); Vector3 randomPos = new Vector3(Random.Range(-10f, 10f), 0, Random.Range(-10f, 10f)); player.transform.position = new Vector3(35, 0, 175) + randomPos; GlobalVariables.localPlayer = player; player.tag = StringAssets.localPlayerTag; player.playerType = PlayerType.Local; player.gameObject.AddComponent <LocalPlayerController>(); } else { Debug.LogError("LevelManager.AddPlayer >> local player already exist"); } break; case ControllerType.LocalAI: if (GlobalVariables.hostType == HostType.Server) { player = Instantiate(playerPrefab).GetComponent <Player>(); Vector3 randomPos = new Vector3(Random.Range(-10f, 10f), 0, Random.Range(-10f, 10f)); player.transform.position = new Vector3(35, 0, 175) + randomPos; player.tag = StringAssets.AIPlayerTag; player.playerType = PlayerType.LocalAI; player.gameObject.AddComponent <LocalPlayerController>(); } else { Debug.LogError("LevelManager.AddPlayer >> client try to add AI"); } break; case ControllerType.Remote: player = Instantiate(playerPrefab).GetComponent <Player>(); player.tag = StringAssets.remoteplayerTag; player.playerType = PlayerType.Remote; player.gameObject.AddComponent <RemotePlayerController>(); if (GlobalVariables.hostType == HostType.Server) { Vector3 randomPos = new Vector3(Random.Range(-10f, 10f), 0, Random.Range(-10f, 10f)); player.transform.position = new Vector3(35, 0, 175) + randomPos; } break; default: break; } if (player != null) { player.id = id; player.nameInGame = name; playerDict.Add(player.id, player); } if (type == ControllerType.Remote || type == ControllerType.LocalAI) { UIManager um = UnityHelper.GetUIManager(); um.AddPlayerInfoPanel(player); um.AddScrollMessage(string.Format("玩家{0}加入游戏", player.nameInGame)); } return(player); }
public void Execute() { lock (locker) { var client = UnityHelper.GetService <MyCodeSqlSugarClient>(); var list = SelectInitWorkProcess(10); //先将这10个任务改成运行中 if (list != null && list.Count > 0) { var updateList = list.Select(p => new WorkProcess { WorkProcessId = p.WorkProcessId, Status = 1 }); _workProcessRepository.Update(updateList.ToList(), it => new { it.Status }); } foreach (var process in list) { var hashcode = client.GetHashCode(); Console.WriteLine("仓储:" + hashcode); Console.WriteLine("0" + client.Ado.Connection.State); client.Ado.BeginTran(); #region 执行一个任务 try { ExecuteSingle(process); Console.WriteLine("2" + client.Ado.Connection.State); } catch (Exception ex) { while (ex.InnerException != null) { ex = ex.InnerException; } Console.WriteLine(ex); Console.WriteLine(ex.StackTrace); process.Status = (int)WorkProcessStatus.Stop; process.UpdateTime = DateTime.Now; if (ex is BaseException) { process.ExceptionInfo = ex.Message; } else { process.ExceptionInfo = ex.ToString(); } _workProcessRepository.Update(process); } #endregion //看下当前Connection状态 Console.WriteLine("3" + client.Ado.Connection.State); client.Ado.CommitTran(); } } }
private void GoToOrderDetail(object beverage) { MainViewModel mainVm = UnityHelper.Retrieve <MainViewModel>(); OrderViewModel orderVm = UnityHelper.Retrieve <OrderViewModel>(); orderVm.BeverageItem = (BeverageDTO)beverage; BeverageMakingStepRepository bmsRepository = (BeverageMakingStepRepository)UnityHelper .Retrieve <IBeverageMakingStepRepository>(); bmsRepository.GetByBeverageId(orderVm.BeverageItem.Id) .ContinueWith(x => { orderVm.BeverageSteps = new ObservableCollection <BeverageMakingStepDTO>(x.Result .Select(step => mapper.Map <BeverageMakingStepDTO>(step)) .OrderBy(stepDto => stepDto.StepIndex)); orderVm.StartMaking(UnityHelper.Retrieve <ProccessBuilder>()); }); mainVm.CurrentViewModel = orderVm; }
protected virtual IEnumerable <IShortcut> CreateShortcuts() { return(new List <IShortcut>() { new KeyboardShortcut(VR.Shortcuts.ShrinkWorld, delegate { VR.Settings.IPDScale += Time.deltaTime; }), new KeyboardShortcut(VR.Shortcuts.EnlargeWorld, delegate { VR.Settings.IPDScale -= Time.deltaTime; }), new VoiceShortcut(VoiceCommand.DecreaseScale, delegate { VR.Settings.IPDScale *= 1.2f; }), // Decrease / Increase scale of the *world* (inverse of camera scale!) new VoiceShortcut(VoiceCommand.IncreaseScale, delegate { VR.Settings.IPDScale *= 0.8f; }), new MultiKeyboardShortcut(new KeyStroke("Ctrl + C"), new KeyStroke("Ctrl + D"), delegate { UnityHelper.DumpScene("dump.json"); }), new MultiKeyboardShortcut(new KeyStroke("Ctrl + C"), new KeyStroke("Ctrl + I"), delegate { UnityHelper.DumpScene("dump.json", true); }), new MultiKeyboardShortcut(VR.Shortcuts.ToggleUserCamera, ToggleUserCamera), new MultiKeyboardShortcut(VR.Shortcuts.SaveSettings, delegate { VR.Settings.Save(); }), new VoiceShortcut(VoiceCommand.SaveSettings, delegate { VR.Settings.Save(); }), new KeyboardShortcut(VR.Shortcuts.LoadSettings, delegate { VR.Settings.Reload(); }), new VoiceShortcut(VoiceCommand.LoadSettings, delegate { VR.Settings.Reload(); }), new KeyboardShortcut(VR.Shortcuts.ResetSettings, delegate { VR.Settings.Reset(); }), new VoiceShortcut(VoiceCommand.ResetSettings, delegate { VR.Settings.Reset(); }), new VoiceShortcut(VoiceCommand.Impersonate, delegate { Impersonate(VR.Interpreter.Actors.FirstOrDefault()); }), //new MultiKeyboardShortcut(new KeyStroke("Ctrl + C"), new KeyStroke("Ctrl+B"), delegate { // ProtectedBehaviour.DumpTable(); //}) new KeyboardShortcut(VR.Shortcuts.ApplyEffects, delegate { VR.Camera.ToggleFX(); }), }); }
private static void LoadScene() { am = new AssetsManager(); am.LoadClassPackage("cldb.dat"); am.useTemplateFieldCache = true; am.updateAfterLoad = false; hkDir = Util.SteamHelper.GetHollowKnightDataPath(); var globalgamemanagers = am.LoadAssetsFile(Path.Combine(hkDir, "globalgamemanagers"), false); var buildSettings = globalgamemanagers.table.getAssetInfo(11); var baseField = am.GetATI(globalgamemanagers.file, buildSettings).GetBaseField(); var scenesArray = baseField.Get("scenes").Get("Array"); // TODO: Allow level to be selected const int level = 0; var levelName = scenesArray[level].GetValue().AsString().Substring(14); levelName = levelName.Substring(0, levelName.Length - 6); progressBarTitle = "Loading Scene #" + level + ": " + levelName; if (ShouldCancel("Checking workspace", 0.2f)) { return; } if (!baseField.Get("m_Version").GetValue().AsString().Equals(Application.unityVersion)) { EditorUtility.ClearProgressBar(); EditorUtility.DisplayDialog("Incorrect Unity version!", " You are using " + Application.unityVersion + " but the assets are compiled for version " + baseField.Get("m_Version").GetValue().AsString(), "Ok"); return; } unityVersion = Application.unityVersion; if (!Directory.Exists(scenesDir)) { Directory.CreateDirectory(scenesDir); } if (!Directory.Exists(dataDir)) { Directory.CreateDirectory(dataDir); } var metaFilePath = Path.Combine(scenesDir, "level" + level + ".unity.meta"); var sceneFilePath = Path.Combine(scenesDir, "level" + level + ".unity"); var assetsFilePath = Path.Combine(dataDir, "level" + level + ".assets"); if (File.Exists(sceneFilePath)) { if (EditorUtility.DisplayDialog("Overwrite scene?", "" + " You have already exported this scene. Would you like to overwrite it or open the existing scene? ", "Open Existing", "Overwrite")) { if (ShouldCancel("Opening Scene", 0.5f)) { return; } EditorSceneManager.OpenScene(sceneFilePath); EditorUtility.ClearProgressBar(); return; } else { File.Delete(sceneFilePath); } } if (File.Exists(metaFilePath)) { File.Delete(metaFilePath); } if (File.Exists(assetsFilePath)) { File.Delete(assetsFilePath); } curSceneId = 1; curAssetId = 1; pointers = new Dictionary <AssetID, AssetID>(); sceneReplacers = new List <AssetsReplacer>(); assetReplacers = new List <AssetsReplacer>(); monoReplacers = new List <AssetsReplacer>(); if (ShouldCancel("Reading level file", 0.5f)) { return; } var scenePath = Path.Combine(Util.SteamHelper.GetHollowKnightDataPath(), "level" + level); var scene = am.LoadAssetsFile(scenePath, true); if (ShouldCancel("Updating Dependencies", 0.8f)) { return; } am.UpdateDependencies(); for (var i = 0; i < am.files.Count; i++) { if (i % 100 == 0 && ShouldCancel("Generating QLTs", (float)i / am.files.Count)) { return; } am.files[i].table.GenerateQuickLookupTree(); } var table = scene.table; var gameObjects = table.GetAssetsOfType(0x01); var gameObjectBaseFields = new Dictionary <AssetFileInfoEx, AssetTypeValueField>(); var c = 0; for (c = 0; c < gameObjects.Count; c++) { if (c % 100 == 0 && ShouldCancel("Finding initial GameObjects", (float)c / gameObjects.Count)) { return; } var gameObjectInfo = gameObjects[c]; var gameObjectBaseField = am.GetATI(scene.file, gameObjectInfo).GetBaseField(); AddPointer(new AssetID(scene.path, (long)gameObjectInfo.index), false); gameObjectBaseFields.Add(gameObjectInfo, gameObjectBaseField); } c = 0; foreach (var pair in gameObjectBaseFields) { if (c % 100 == 0 && ShouldCancel("Recursing GameObject dependencies", (float)c / gameObjectBaseFields.Count)) { return; } FindNestedPointers(scene, pair.Value, pair.Key, false); c++; } var types = new List <Type_0D>(); var typeNames = new List <string>(); var fileToInst = am.files.ToDictionary(d => d.path); var j = 0; foreach (var pair in pointers) { if (j % 100 == 0 && ShouldCancel("Rewiring asset pointers", (float)j / pointers.Count)) { return; } var file = fileToInst[pair.Key.fileName]; var info = file.table.getAssetInfo((ulong)pair.Key.pathId); var assetClass = AssetHelper.FindAssetClassByID(am.classFile, info.curFileType); var assetName = assetClass.name.GetString(am.classFile); if (!typeNames.Contains(assetName)) { var type0d = C2T5.Cldb2TypeTree(am.classFile, assetName); type0d.classId = (int)info.curFileType; types.Add(type0d); typeNames.Add(assetName); } ReplacePointers(file, info, pair.Value.pathId); j++; } if (ShouldCancel("Saving scene", 1)) { return; } List <Type_0D> assetTypes = new List <Type_0D>() { C2T5.Cldb2TypeTree(am.classFile, 0x1c), // audioclip C2T5.Cldb2TypeTree(am.classFile, 0x30), // shader C2T5.Cldb2TypeTree(am.classFile, 0x53) // texture2d }; var sceneGuid = Util.UnityHelper.CreateMD5(levelName); UnityHelper.CreateMetaFile(sceneGuid, metaFilePath); var sceneFile = new AssetsFile(new AssetsFileReader(new MemoryStream(BundleCreator.CreateBlankAssets(unityVersion, types)))); var assetFile = new AssetsFile(new AssetsFileReader(new MemoryStream(BundleCreator.CreateBlankAssets(unityVersion, assetTypes)))); byte[] sceneFileData; using (MemoryStream ms = new MemoryStream()) using (AssetsFileWriter w = new AssetsFileWriter(ms)) { w.bigEndian = false; sceneFile.dependencies.pDependencies = new AssetsFileDependency[] { UnityHelper.CreateDependency(assetsFilePath), }; sceneFile.dependencies.dependencyCount = 1; sceneFile.preloadTable.items = new AssetPPtr[] {}; sceneFile.preloadTable.len = 0; sceneFile.Write(w, 0, sceneReplacers.Concat(monoReplacers).ToArray(), 0); sceneFileData = ms.ToArray(); } byte[] assetFileData; using (var ms = new MemoryStream()) using (var w = new AssetsFileWriter(ms)) { w.bigEndian = false; assetFile.Write(w, 0, assetReplacers.ToArray(), 0); assetFileData = ms.ToArray(); } File.WriteAllBytes(sceneFilePath, sceneFileData); File.WriteAllBytes(assetsFilePath, assetFileData); if (ShouldCancel("Refreshing Assets", 0.95f)) { return; } AssetDatabase.Refresh(); EditorUtility.ClearProgressBar(); }
public void PostInit() { UnityHelper.AddPersistantStartCallback(TryReloadToken); }
private Material CreateUnlitTransparent() { return(new Material(UnityHelper.GetShader("UnlitTransparent"))); }
public override void FixedUpdate() { if (!controller.grounded) { //不在地面 inAirTime += Time.fixedDeltaTime; if (inAirTime > 0.2f) { controller.IntoState(PlayerStateType.InAir); } } else { //在地面 inAirTime = 0; if (controller.input.jump) { if (controller.EnergyCost(Player.jumpEnergyCost) > 0) { controller.IntoState(PlayerStateType.Jump); } } else if (controller.input.roll) { if (controller.EnergyCost(Player.rollEnergyCost) > 0) { controller.IntoState(PlayerStateType.Roll); } } else if (controller.input.mainHand) { if (player.weaponType == WeaponType.Melee) { if (controller.EnergyCost(Player.attackEnergyCost) > 0) { if (controller.comboCount == 1) { controller.IntoState(PlayerStateType.Attack, "Attack1"); controller.comboCount = 0; } else if (controller.comboCount == 0) { TimeSpan span = DateTime.Now - controller.lastAttackDoneTime; if (span.TotalMilliseconds < 300) { controller.IntoState(PlayerStateType.Attack, "Attack2"); controller.comboCount = 1; } else { controller.IntoState(PlayerStateType.Attack, "Attack1"); } } } } } else if (controller.input.offHand && player.weaponType == WeaponType.Pistol) { controller.IntoState(PlayerStateType.Aim); } else { if (controller.input.swapWeapon) //切换武器 { if (upperAction != UpperAction.SwapWeapon) { if (player.weaponType == WeaponType.Melee) { nextWeapon = WeaponType.Pistol; } else { nextWeapon = WeaponType.Melee; } player.SetUpperAniState(Player.StateNameHash.swapWeapon); upperAction = UpperAction.SwapWeapon; } } if (controller.input.offHand && player.weaponType == WeaponType.Melee && upperAction == UpperAction.Empty) //格挡 { player.blocking = true; } else { player.blocking = false; } if (!controller.input.hasMove) //没输入方向,idle { if (player.targetId > 0) { Player target = UnityHelper.GetLevelManager().GetPlayer(player.targetId); controller.faceYaw = CommonHelper.YawOfVector3(target.transform.position - player.transform.position); } if (player.blocking) { if (upperAction == UpperAction.Empty) { player.SetLowerAniState(Player.StateNameHash.blockIdle); } player.SetUpperAniState(Player.StateNameHash.blockIdle); } else { if (upperAction == UpperAction.Empty) { player.SetUpperAniState(Player.StateNameHash.idle); } player.SetLowerAniState(Player.StateNameHash.idle); } controller.rigidBody.Sleep(); controller.moveSpeed = Player.walkSpeed; //idle时,重置移动速度 player.footIk = true; } else //输入了方向,则移动 { player.footIk = false; if (player.targetId >= 0 && !controller.input.run) { StrafeMove(); } else { NormalMove(); //普通移动 } } } } }
/// <summary> /// 得到敌人的随机出生点位置 /// </summary> /// <param name="spawnTras">敌人位置数组</param> /// <returns></returns> public Transform GetRandomEnemySpawnPosition(Transform[] spawnTras) { int randomNum = UnityHelper.GetInstance().GetRandomNum(0, spawnTras.Length - 1); return(spawnTras[randomNum]); }
public async Task <IEnumerable <BeverageMakingStep> > GetByBeverageId(int id) { ISampleData <BeverageMakingStep> data = UnityHelper.Retrieve <ISampleData <BeverageMakingStep> >(); return(await Task.Run(() => data.DbSet.Where(x => x.BeverageId == id))); }
protected void Application_Start() { // Register routes AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); // Start unity var unityContainer = UnityHelper.Start(); // Run scheduled tasks ScheduledRunner.Run(unityContainer); // Custom Code: GlobalConfiguration.Configure(config => { config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore; // Web API configuration and services config.DependencyResolver = new UnityWebApiDependencyResolver(unityContainer); // Web API routes WebApiConfig.RegisterRoutes(config); } ); RegisterRoutes(RouteTable.Routes); // Register Data annotations DataAnnotationsModelValidatorProviderExtensions.RegisterValidationExtensions(); // Store the value for use in the app Application["Version"] = AppHelpers.GetCurrentVersionNo(); // If the same carry on as normal LoggingService.Initialise(ConfigUtils.GetAppSettingInt32("LogFileMaxSizeBytes", 10000)); LoggingService.Error("START APP"); // Set default theme var defaultTheme = "Metro"; // Only load these IF the versions are the same if (AppHelpers.SameVersionNumbers()) { // Get the theme from the database. defaultTheme = SettingsService.GetSettings().Theme; // Do the badge processing using (var unitOfWork = UnitOfWorkManager.NewUnitOfWork()) { try { BadgeService.SyncBadges(); unitOfWork.Commit(); } catch (Exception ex) { LoggingService.Error(string.Format("Error processing badge classes: {0}", ex.Message)); } } } // Set the view engine ViewEngines.Engines.Clear(); ViewEngines.Engines.Add(new ForumViewEngine(defaultTheme)); // Initialise the events EventManager.Instance.Initialize(LoggingService); }