public SceneAssetRequest(string path, bool addictive) { name = path; LoadModule.GetAssetBundleName(path, out assetBundleName); sceneName = Path.GetFileNameWithoutExtension(name); loadSceneMode = addictive ? LoadSceneMode.Additive : LoadSceneMode.Single; }
private IEnumerator LoadGameScene() { OnMessage("正在初始化"); var init = LoadModule.Initialize(); yield return(init); if (string.IsNullOrEmpty(init.error)) { LoadModule.AddSearchPath("Assets/_Scenes"); init.Release(); OnProgress(0); OnMessage("加载游戏场景"); var scene = LoadModule.LoadSceneAsync(gameScene, false); while (!scene.isDone) { OnProgress(scene.progress); yield return(null); } } else { init.Release(); var mb = MessageBox.Show("提示", "初始化异常错误:" + init.error + "请联系技术支持"); yield return(mb); Quit(); } }
public void LoadAsset(Action <GameObject> loadedCallback = null) { m_LoadedCallback = loadedCallback; string path = battleEntity.GetModelPath(); LoadModule.LoadModel(path, OnLoadComplete); }
public void Dispose() { if (m_assetRequest != null) { LoadModule.UnloadAsset(m_assetRequest); } }
AssetRequest LoadSprite(string path) { var request = LoadModule.LoadAsset(path, typeof(Sprite)); _requests.Add(request); return(request); }
internal override void Load() { BundleRequest = LoadModule.LoadBundleAsync(assetBundleName); var bundles = LoadModule.GetAllDependencies(assetBundleName); foreach (var item in bundles) { children.Add(LoadModule.LoadBundleAsync(item)); } loadState = AssetLoadState.LoadAssetBundle; }
void Start() { dropdown.ClearOptions(); _assets = LoadModule.GetAllAssetPaths(); foreach (var item in _assets) { dropdown.options.Add(new Dropdown.OptionData(item)); } dropdown.onValueChanged.AddListener(OnDropdown); }
public void SetSprite(string name) { if (string.IsNullOrEmpty(name)) { this.sprite = null; } else { var path = Util.GetSpritePath(name); LoadModule.LoadAssetAsync(path, typeof(Sprite), OnLoadComplete); } }
// PopupViewBase 拿Mask,全局就一个 public static GameObject GetUIMask() { if (m_UIMask == null) { AssetRequest assetRequest = LoadModule.LoadUI(m_prefabPath); var asset = assetRequest.asset as GameObject; m_UIMask = GameObject.Instantiate(asset, GetParent(ViewType.POPUP)); m_UIMask.transform.SetAsFirstSibling(); m_UIMask.transform.localPosition = Vector3.zero; return(m_UIMask); } return(m_UIMask); }
internal override void Load() { assetName = Path.GetFileName(name); if (LoadModule.runtimeMode) { var assetBundleName = assetName.Replace(".asset", ".unity3d").ToLower(); request = LoadModule.LoadBundleAsync(assetBundleName); loadState = AssetLoadState.LoadAssetBundle; } else { loadState = AssetLoadState.Loaded; } }
internal virtual void Load() { if (!LoadModule.runtimeMode && LoadModule.loadDelegate != null) { asset = LoadModule.loadDelegate(name, assetType); } if (asset == null) { error = "error! file not exist:" + name; } loadState = AssetLoadState.Loaded; }
private Transform GetIndicatorAsset(AbilityIndicatorType abilityIndicatorType) { string path = string.Empty; AbilityIndicatorAssetConfig.TryGetValue(abilityIndicatorType, out path); if (!string.IsNullOrEmpty(path)) { path = IndicatorPrefix + path + Indicatorsuffix; var request = LoadModule.LoadAsset(path, typeof(GameObject)); var asset = request.asset as GameObject; var go = Object.Instantiate(asset); return(go.transform); } return(null); }
public void Dispose() { if (m_assetRequest != null) { LoadModule.UnloadAsset(m_assetRequest); } if (UI != null && UI.Count > 0) { UI.Clear(); } if (gameObject != null) { GameObject.Destroy(gameObject); } }
internal override void Load() { if (!string.IsNullOrEmpty(assetBundleName)) { BundleRequest = LoadModule.LoadBundleAsync(assetBundleName); var bundles = LoadModule.GetAllDependencies(assetBundleName); foreach (var item in bundles) { children.Add(LoadModule.LoadBundleAsync(item)); } loadState = AssetLoadState.LoadAssetBundle; } else { LoadScene(); } }
internal override bool Update() { if (!base.Update()) { return(false); } if (loadState == AssetLoadState.Init) { return(true); } if (request == null) { loadState = AssetLoadState.Loaded; error = "request == null"; return(false); } if (request.isDone) { if (request.assetBundle == null) { error = "assetBundle == null"; } else { var manifest = request.assetBundle.LoadAsset <Manifest>(assetName); if (manifest == null) { error = "manifest == null"; } else { LoadModule.OnManifestLoaded(manifest); } } loadState = AssetLoadState.Loaded; return(false); } return(true); }
public void OnClear() { OnMessage("数据清除完毕"); OnProgress(0); _versions.Clear(); _downloader.Clear(); _step = Step.Wait; _reachabilityChanged = false; LoadModule.Clear(); if (listener != null) { listener.OnClear(); } if (Directory.Exists(_savePath)) { Directory.Delete(_savePath, true); } }
private IntPtr loadModule(IntPtr vm, string name) { if (LoadModule == null) { return(IntPtr.Zero); } // Only one of the multiple possible LoadModule implementations must actually return the source for the module var result = LoadModule.GetInvocationList().Cast <WrenLoadModule>() .Select(loadModule => loadModule(WrenVM.GetVM(vm), name)) .Single(res => res != null); if (result == null) { return(IntPtr.Zero); } // Possibly have to free this again var resultPtr = Marshal.StringToCoTaskMemAnsi(result); return(resultPtr); }
internal override void Load() { if (!string.IsNullOrEmpty(assetBundleName)) { BundleRequest = LoadModule.LoadBundle(assetBundleName); if (BundleRequest != null) { var bundles = LoadModule.GetAllDependencies(assetBundleName); foreach (var item in bundles) { children.Add(LoadModule.LoadBundle(item)); } SceneManager.LoadScene(sceneName, loadSceneMode); } } else { SceneManager.LoadScene(sceneName, loadSceneMode); } loadState = AssetLoadState.Loaded; }
internal override void Load() { BundleRequest = LoadModule.LoadBundle(assetBundleName); var names = LoadModule.GetAllDependencies(assetBundleName); foreach (var item in names) { children.Add(LoadModule.LoadBundle(item)); } var assetName = Path.GetFileName(name); var ab = BundleRequest.assetBundle; if (ab != null) { asset = ab.LoadAsset(assetName, assetType); } if (asset == null) { error = "asset == null"; } loadState = AssetLoadState.Loaded; }
public void OnHeroActorCreated(HeroActor actor, bool isFriend) { // 创建一个血条 LoadModule.LoadUI(path, delegate(AssetRequest data) { GameObject asset = data.asset as GameObject; GameObject go = Object.Instantiate(asset); go.transform.SetParent(parentNode); go.transform.localPosition = Vector3.zero; go.transform.localScale = Vector3.one; GameObject heroGO = actor.gameObject; HudController hudController = go.GetComponent <HudController>(); Transform targetTransform = heroGO.transform.Find("Dummy OverHead"); hudController.Init(canvasTransform, targetTransform, uiCamera, 0, isFriend); HudActor hudActor = new HudActor(go, hudController); float hpPercent = actor.battleEntity.GetHPPercent(); hudActor.SetValue(hpPercent); m_actorMap.Add(actor.id, hudActor); }); }
private static AbilityData CreateAbility(string path) { JsonData jsonData = LoadModule.LoadJson(path); if (jsonData == null) { BattleLog.LogError("[CreateAbility]没有找到指定json配置!", path); return(null); } AbilityData abilityData = new AbilityData(); abilityData.configFileName = GetStringValue(jsonData, "Name"); string abilityType = GetStringValue(jsonData, "AbilityType"); abilityData.abilityType = abilityType; abilityData.abilityBranch = GetEnumValue <AbilityBranch>(jsonData, "AbilityBranch"); abilityData.abilityBehavior = ParseAbilityBehaviorArray(jsonData, "AbilityBehavior"); abilityData.aiTargetCondition = GetEnumValue <AbilityUnitAITargetCondition>(jsonData, "AbilityUnitAiTargetCondition"); abilityData.castRange = GetFloatValue(jsonData, "AbilityCastRange"); abilityData.castPoint = GetFloatValue(jsonData, "AbilityCastPoint"); abilityData.castDuration = GetFloatValue(jsonData, "AbilityCastDuration"); abilityData.castAnimation = GetStringValue(jsonData, "AbilityCastAnimation"); abilityData.cooldown = GetFloatValue(jsonData, "AbilityCooldown"); abilityData.costType = GetEnumValue <AbilityCostType>(jsonData, "AbilityCostType"); abilityData.costValue = GetFloatValue(jsonData, "AbilityCostValue"); abilityData.abilityTarget = ParseAbilityRange(jsonData, abilityData); // 解析技能事件 abilityData.eventMap = ParseAbilityEvents(jsonData, abilityData); // 解析Modifier abilityData.modifierMap = ParseModifiers(jsonData, abilityData); return(abilityData); }
/// <summary> /// 界面加载 /// </summary> /// <param name="loadedCallback"></param> public void Load(Action <ViewBase> loadedCallback = null) { m_loadedCallback = loadedCallback; m_loadState = LoadState.LOADING; LoadModule.LoadUI(assetPath, OnLoadCompleted); }
public void Load(Action <AssetRequest> loadedCallback = null) { m_loadedCallback = loadedCallback; LoadState = LoadState.LOADING; LoadModule.LoadSceneAsync(assetPath, false, OnLoadCompleted); }
protected override unsafe int OnLoadModule(CorDebugAppDomain pAppDomain, CorDebugModule pModule) { LoadModule?.Invoke(this, pAppDomain, pModule); return(Continue()); }
float m_lastClear = 0; // 上一次清除时间 void Awake() { Instance = this; }
public async Task Handle(NewConsoleMessage newConsoleMessage, string replyTo, string correlationId) { // Reset Error stuff error = false; errorMessage = ""; // figure out what agent we're dealing with Agent agent = _taskRepository.GetAgent(newConsoleMessage.AgentId); agent.AgentType = _taskRepository.GetAgentType(agent.AgentTypeId); // flesh out and save the ConsoleMessage object ConsoleMessage consoleMessage = new ConsoleMessage(); consoleMessage.AgentId = newConsoleMessage.AgentId; consoleMessage.UserId = newConsoleMessage.UserId; consoleMessage.Agent = agent; consoleMessage.User = _taskRepository.GetUser(consoleMessage.UserId.Value); consoleMessage.Content = newConsoleMessage.Content; consoleMessage.Display = newConsoleMessage.Display; consoleMessage.Received = DateTime.UtcNow; consoleMessage.Type = "AgentTask"; _taskRepository.Add(consoleMessage); // Announce our new message to Rabbit ConsoleMessageAnnouncement messageAnnouncement = new ConsoleMessageAnnouncement(); messageAnnouncement.Success = true; messageAnnouncement.Username = consoleMessage.User.Username; messageAnnouncement.ConsoleMessage = consoleMessage; _eventBus.Publish(messageAnnouncement); // These are the commands we allow. If one of these isn't the first part of a command List <string> allowedActions = new List <string>(); allowedActions.Add("HELP"); allowedActions.Add("SHOW"); allowedActions.Add("LOAD"); allowedActions.Add("SET"); allowedActions.Add("USE"); allowedActions.Add("RUN"); allowedActions.Add("EXIT"); // we assume that the command is a RUN command string action = "RUN"; string[] consoleMessageComponents = consoleMessage.Content.Split(' '); if (consoleMessageComponents.Length > 0) { if (allowedActions.Contains(consoleMessageComponents[0].ToUpper())) { action = consoleMessageComponents[0].ToUpper(); } } // if this is a SHOW or HELP commmand, we won't be sending anything to the agent // so lets take care of that here: AgentDetails.Language = _taskRepository.GetLanguage(consoleMessage.Agent.AgentType.LanguageId); AgentDetails.AvailableModules = _taskRepository.GetModules(AgentDetails.Language.Id); AgentDetails.LoadedModules = _taskRepository.GetAgentModules(consoleMessage.AgentId); AgentDetails.AgentType = consoleMessage.Agent.AgentType; if (action == "HELP") { ConsoleMessage message = ProcessHelpMessage(consoleMessage); _taskRepository.Add(message); ConsoleMessageAnnouncement response = new ConsoleMessageAnnouncement(); response.Success = true; response.Username = "******"; response.ConsoleMessage = message; _eventBus.Publish(response); } else if (action == "SHOW") { ConsoleMessage message = ProcessShowMessage(consoleMessage); _taskRepository.Add(message); ConsoleMessageAnnouncement response = new ConsoleMessageAnnouncement(); response.Success = true; response.Username = "******"; response.ConsoleMessage = message; _eventBus.Publish(response); } else { // We'll be tasking the agent to do something so lets create an agentTask AgentTask agentTask = new AgentTask(); agentTask.Action = action; agentTask.AgentId = consoleMessage.AgentId; agentTask.ConsoleMessageId = consoleMessage.Id; agentTask.ConsoleMessage = consoleMessage; agentTask.Agent = consoleMessage.Agent; // Package the AgentTask into a envelope for seralization & encryption. // Then process the ACTION and populate CONTENTS appropriately Dictionary <String, String> outboundMessage = new Dictionary <String, String>(); outboundMessage.Add("AgentName", agentTask.Agent.Name); outboundMessage.Add("Name", agentTask.Name); outboundMessage.Add("Action", agentTask.Action); // Message formats // * load stdlib // * load dotnet/stdlib // * load transport/dns if (agentTask.Action == "LOAD") { LoadModule msg = new LoadModule(); if (consoleMessageComponents[1].Contains("/")) { msg.Language = consoleMessageComponents[1].Split("/")[0]; msg.Name = consoleMessageComponents[1].Split("/")[0]; } else { msg.Language = (_taskRepository.GetLanguage(consoleMessage.Agent.AgentType.LanguageId)).Name; msg.Name = consoleMessageComponents[1]; } bool LoadSuccess = false; foreach (Module module in AgentDetails.AvailableModules) { if (String.Equals(module.Name, msg.Name, StringComparison.CurrentCultureIgnoreCase)) { _eventBus.Publish(msg, null, null, true); string message = _eventBus.ResponseQueue.Take(); ModuleResponse moduleResponse = JsonConvert.DeserializeObject <ModuleResponse>(message); outboundMessage.Add("Command", moduleResponse.Contents); LoadSuccess = true; AgentUpdated agentUpdated = new AgentUpdated { Success = true, Agent = agentTask.Agent }; _eventBus.Publish(agentUpdated); break; } } if (!LoadSuccess) { error = true; errorMessage = $"Module {msg.Name} is not a valid module. Use the 'show modules' command to view available modules"; } } // Message formats // * set beacon:5 else if (agentTask.Action == "SET") { outboundMessage.Add("Command", consoleMessageComponents[1]); } else if (agentTask.Action == "EXIT") { outboundMessage.Add("Command", "exit"); } // Example commands: // * ls // * ls "C:\Program Files" // * ls /path:"C:\Program Files" if (agentTask.Action == "RUN") { string submittedCommand = consoleMessage.Content; string[] processedArgs = null; // check to see if we have parameters (for example: ls /path:foo) int index = submittedCommand.IndexOf(' '); if (index > 0) { // change submittedCommand to just the first part of the command (ex: ls) submittedCommand = submittedCommand.Substring(0, index); string submittedArgs = consoleMessage.Content.Substring(index + 1); if (submittedArgs.Length > 0) { processedArgs = SplitArguments(submittedArgs); } } // Check if command is available try { Command commandObject = _taskRepository.GetCommand(submittedCommand); if (!AgentDetails.IsModuleLoaded(commandObject.Module)) { error = true; errorMessage = $"The module for this command isn't loaded. You can load it by running: 'load {commandObject.Module.Name}'"; } } catch { error = true; errorMessage = $"{submittedCommand} is not a valid command for this agent. To view available commands, run: 'show commands'"; } if (!error) { FactionCommand factionCommand = ProcessCommand(submittedCommand, processedArgs); string command = factionCommand.Command; if (factionCommand.Arguments.Count > 0) { command = $"{factionCommand.Command} {JsonConvert.SerializeObject(factionCommand.Arguments)}"; } outboundMessage.Add("Command", command); } } // If there's an error, send it back if (error) { ConsoleMessage message = new ConsoleMessage(); message.AgentId = consoleMessage.AgentId; message.AgentTaskId = agentTask.Id; message.UserId = 1; message.Type = "AgentTaskError"; message.Display = errorMessage; _taskRepository.Add(message); ConsoleMessageAnnouncement response = new ConsoleMessageAnnouncement(); response.Success = true; response.Username = "******"; response.ConsoleMessage = message; _eventBus.Publish(response); } // Else, create a new task for the agent else { // update agentTask with final command format and save it agentTask.Command = outboundMessage["Command"]; _taskRepository.Add(agentTask); // update the incoming consoleMessage with this task Id consoleMessage.AgentTaskId = agentTask.Id; _taskRepository.Update(consoleMessage.Id, consoleMessage); string jsonOutboundMessage = JsonConvert.SerializeObject(outboundMessage); Dictionary <string, string> encCommand = Crypto.Encrypt(jsonOutboundMessage, agentTask.Id, agentTask.Agent.AesPassword); // Create a AgentTaskMessage object with the seralized/encrypted message contents AgentTaskMessage agentTaskMessage = new AgentTaskMessage(); agentTaskMessage.Agent = agentTask.Agent; agentTaskMessage.Message = encCommand["encryptedMsg"]; agentTaskMessage.AgentId = consoleMessage.Agent.Id; agentTaskMessage.AgentTaskId = agentTask.Id; agentTaskMessage.AgentTask = agentTask; agentTaskMessage.Hmac = encCommand["hmac"]; agentTaskMessage.Iv = encCommand["iv"]; agentTaskMessage.Sent = false; _taskRepository.Add(agentTaskMessage); } } }