public void Init(GroupComponent groupComponent) { _activeParameter.Reset(0f); _volumeParameter.Reset(0f); _pitchParameter.Reset(0f); _groupComponent = groupComponent; }
private void RegisterPrefab(GameObject prefab) { if (prefab == null) { return; } GroupComponent component = prefab.GetComponent <GroupComponent>(); if (component == null) { return; } GameObject gameObject = GameObject.Find(prefab.name); if (gameObject == null) { GroupComponent._createProxy = false; gameObject = UnityEngine.Object.Instantiate(prefab); GroupComponent._createProxy = true; gameObject.name = gameObject.name.Replace("(Clone)", ""); } if (gameObject != null) { GroupComponent component2 = gameObject.GetComponent <GroupComponent>(); if (component2 != null) { component2.IncRef(); } _prefabInstances.Add(gameObject); } }
public void Add(ClientComponent client, ServerComponent server, GroupComponent group) { Entity entity = new Entity(); entity.Add(client); ClientOptionsComponent options = new ClientOptionsComponent(); entity.Add(options); entity.Add(server); entity.Add(group); FolderListComponent folderList = new FolderListComponent(); entity.Add(folderList); FileMapComponent fileMap = new FileMapComponent(); entity.Add(fileMap); FolderMapComponent folderMap = new FolderMapComponent(); entity.Add(folderMap); ClientMachineComponent machine = new ClientMachineComponent(); entity.Add <MachineComponent>(machine); SessionComponent session = new SessionComponent(); entity.Add(session); FileComponent file = new FileComponent(); entity.Add(file); SearchListComponent search = new SearchListComponent(SearchController.Dispatcher); entity.Add(search); BrowseComponent browse = new BrowseComponent(); entity.Add(browse); DownloadListComponent download = new DownloadListComponent(DownloadController.Dispatcher); entity.Add(download); UploadListComponent upload = new UploadListComponent(UploadController.Dispatcher); entity.Add(upload); #if DEBUG LogComponent log = new LogComponent(LogController); entity.Add(log); #endif Add(entity); }
public override void Encode(ProtocolBuffer protocolBuffer, object data) { base.Encode(protocolBuffer, data); GroupComponent component = (GroupComponent)data; long uidByType = this.protocol.GetUidByType(component.GetType()); this.longCodec.Encode(protocolBuffer, uidByType); this.longCodec.Encode(protocolBuffer, component.Key); }
private void LoadSnapShot(GroupComponent group, string snapShotName, float time) { if (group == null) { Debug.LogWarning("UNABLE TO LOAD SNAPSHOT -----> LoadSnapShot: " + snapShotName); return; } group._audioMixerGroup.audioMixer.FindSnapshot(snapShotName).TransitionTo(time); }
public void Initialize() { if (audioMixer != null) { var groupComponentObj = audioManager.transform.Find(GAME_SOUND); if (groupComponentObj != null) { gameGroupComponent = groupComponentObj.GetComponent <GroupComponent>(); } groupComponentObj = audioManager.transform.Find(MUSIC); if (groupComponentObj != null) { musicGroupComponent = groupComponentObj.GetComponent <GroupComponent>(); } groupComponentObj = audioManager.transform.Find(SOUND_EFFECT); if (groupComponentObj != null) { sfxGroupComponent = groupComponentObj.GetComponent <GroupComponent>(); } } var playerPrefHelper = PlayerPrefHelper.Instance; if (!playerPrefHelper.HasKey(Constants.GamePrefs.MUSIC_KEY) || !playerPrefHelper.HasKey(Constants.GamePrefs.SOUND_FX_KEY)) { playerPrefHelper.SetMusicPreference(1); playerPrefHelper.SetSoundFXPreference(1); } var musicStatus = playerPrefHelper.GetMusicPreference(); var soundStatus = playerPrefHelper.GetSoundFXPreference(); if (musicStatus) { LoadSnapShot(musicGroupComponent, UNMUTED, 0.0f); } else { LoadSnapShot(musicGroupComponent, MUTED, 0.0f); } if (soundStatus) { LoadSnapShot(gameGroupComponent, UNMUTED, 0.0f); LoadSnapShot(sfxGroupComponent, UNMUTED, 0.0f); } else { LoadSnapShot(gameGroupComponent, MUTED, 0.0f); LoadSnapShot(sfxGroupComponent, MUTED, 0.0f); } }
private void Save(AudioClip clip, GroupComponent parent, string name) { if (string.IsNullOrEmpty(name)) { EditorUtility.DisplayDialog("错误", "不能为空,请输入目标节点或事件名称", "确定"); return; } name.Trim(); string eventName = string.Empty; string objName = string.Empty; if (name.Contains("_")) { objName = name; eventName = name.Replace("_", "/"); } else if (name.Contains("/")) { eventName = name; objName = name.Replace("_", "/"); } else { EditorUtility.DisplayDialog("错误", "请正确输入目标节点或事件名称,需包含“_”或“/”字符间隔", "确定"); return; } var temp = parent.transform.Find(objName); if (temp != null) { EditorUtility.DisplayDialog("错误", string.Format("{0}节点目录下已存在{1}节点", parent.gameObject.name, name), "确定"); return; } if (eventManager._eventList.Contains(eventName)) { EditorUtility.DisplayDialog("错误", string.Format("EventManager中已存在该事件名:{0}", eventName), "确定"); return; } else { eventManager._eventList.Add(eventName); } eventManager._eventList.Sort(); Repaint(); temp = parent.transform.Find("Template"); var obj = GameObject.Instantiate(temp.gameObject, parent.transform); obj.name = objName; obj.GetComponent <AudioComponent>().AudioClip = clip; obj.GetComponent <EventListener>()._eventName = eventName; }
private void Update() { if (!_isInitialised) { _groupComponents = FabricManager.Instance.gameObject.GetComponentsInChildren <GroupComponent>(); _isInitialised = true; } if (_presetList != null) { for (int i = 0; i < _presetList.Length; i++) { Preset preset = _presetList[i]; if (preset.HasEventNameSet() && preset.IsEventActive()) { AddPreset(preset); } } } if (_groupComponents == null) { return; } for (int j = 0; j < _groupComponents.Length; j++) { GroupComponent groupComponent = _groupComponents[j]; float num = 0f; float num2 = 1f; for (int k = 0; k < _activePresets.Count; k++) { Preset preset2 = _activePresets[k]; if (preset2.HasEventNameSet() && !preset2.IsEventActive() && !preset2.IsDeactivating) { preset2.Deactivate(); } if (preset2.IsActive()) { GroupPreset groupComponentByID = preset2.GetGroupComponentByID(groupComponent.GetInstanceID()); if (groupComponentByID != null) { num += groupComponentByID.CalculateVolume(); num2 *= groupComponentByID.CalculatePitch(); } } else { _activePresets.Remove(preset2); } } float value = AudioTools.DBToLinear(num); AudioTools.Limit(ref value, 0f, 1f); groupComponent.MixerVolume = value; groupComponent.MixerPitch = num2; } }
public GroupComponent GetGroupComponent(string GroupName) { GroupComponent group = GameObject.Find(GroupName).GetComponent <GroupComponent>(); if (group) { return(group); } EB.Debug.LogError("can not find group : {0}", GroupName); return(null); }
public bool HasGroupComponent(GroupComponent groupComponent) { GroupPreset[] componentsInChildren = base.gameObject.GetComponentsInChildren <GroupPreset>(); foreach (GroupPreset groupPreset in componentsInChildren) { if (groupPreset.GroupComponent != null && groupPreset.GroupComponent == groupComponent) { return(true); } } return(false); }
private void UnregisterPrefab(GameObject prefab) { GroupComponent component = prefab.GetComponent <GroupComponent>(); if (component != null) { component.DecRef(); if (component._registeredWithMainRefCount == 0) { UnityEngine.Object.Destroy(component.gameObject); } } }
public void MixerSlot(string title, GroupComponent component) { GUILayout.BeginVertical(); GUILayout.BeginVertical(); DisplayCenterText("Pitch"); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); component.Pitch = GUILayout.HorizontalSlider(component.Pitch, -4f, 4f, GUILayout.MinWidth(50f)); GUILayout.Label(component.Pitch.ToString("F")); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.BeginHorizontal(GUILayout.MaxHeight(GetActualSize(40f))); GUILayout.FlexibleSpace(); component.Mute = GUILayout.Toggle(component.Mute, "Mute", "button"); bool solo = component.Solo; component.Solo = GUILayout.Toggle(component.Solo, "Solo", "button"); if (component.Solo) { for (int i = 0; i < _soloComponents.Count; i++) { if (_soloComponents[i] != null && _soloComponents[i] != component) { _soloComponents[i].Mute = true; } } } else if (solo != component.Solo) { for (int j = 0; j < _soloComponents.Count; j++) { if (_soloComponents[j] != null && _soloComponents[j] != component) { _soloComponents[j].Mute = false; } } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.BeginVertical(); DisplayCenterText("Volume"); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); component.Volume = GUILayout.VerticalSlider(component.Volume, 1f, 0f, GUILayout.MinHeight(100f)); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); DisplayCenterText(AudioTools.LinearToDB(component.Volume).ToString("F") + "dB"); GUILayout.EndVertical(); GUILayout.EndVertical(); }
private IList <N> DoSelect <N>(Entity entity, Type groupComponentType) where N : Node { ICollection <Entity> is2; GroupComponent componentUnsafe = (GroupComponent)((EntityUnsafe)entity).GetComponentUnsafe(groupComponentType); if (componentUnsafe == null) { return(Collections.EmptyList <N>()); } NodeClassInstanceDescription orCreateNodeClassDescription = NodeDescriptionRegistry.GetOrCreateNodeClassDescription(typeof(N), null); NodeDescriptionRegistry.AssertRegister(orCreateNodeClassDescription.NodeDescription); return(((is2 = componentUnsafe.GetGroupMembers(orCreateNodeClassDescription.NodeDescription)).Count != 0) ? ((is2.Count != 1) ? ((IList <N>) this.ConvertNodeCollection(orCreateNodeClassDescription, is2)) : Collections.SingletonList <N>((N)this.GetNode(Collections.GetOnlyElement <Entity>(is2), orCreateNodeClassDescription))) : Collections.EmptyList <N>()); }
public GroupComponent FindOrRegisterGroup(GroupComponent groupComponent) { Type key = groupComponent.GetType(); long num = groupComponent.Key; if (!this.groups.ContainsKey(key)) { this.groups[key] = new Dictionary <long, GroupComponent>(); } IDictionary <long, GroupComponent> dictionary = this.groups[key]; if (!dictionary.ContainsKey(num)) { dictionary[num] = groupComponent; } return(dictionary[num]); }
public override void Select(Entity entity) { BitmapImage image = null; if (entity != null) { GroupComponent group = entity.Get <GroupComponent>(); image = group.Image; FileComponent file = entity.Get <FileComponent>(); FileController.Select(file); } else { FileController.Select(entity); } Main.GroupImage.Source = image; }
public static void TryRotate(GroupComponent component) { if (!GridUtil.gameIsPaused) { component.transform.Rotate(0, 0, -90); // See if valid if (isValidGridPos(component)) { // It's valid. Update grid. updateGrid(component); } else { // It's not valid. revert. component.transform.Rotate(0, 0, 90); } } }
public void Initialize() { GroupComponent groupComponent = transform.parent.GetComponent <GroupComponent>(); UseDestination = groupComponent.UseDestination; if (UseDestination) { Destination = VectorHelpers.Vector3ToVector2(groupComponent.DestinationWaypoint.position); } else { Direction = groupComponent.Direction; } Position = VectorHelpers.Vector3ToVector2(transform.position); Vector3 localScale = transform.localScale; float scale = ((localScale.x + localScale.y + localScale.z) / 3); Radius = (scale / 2); }
public static void TryMoveRight(GroupComponent component) { if (!GridUtil.gameIsPaused) { component.transform.position += new Vector3(1, 0, 0); // See if valid if (isValidGridPos(component)) { // It's valid. Update grid. updateGrid(component); } else { // It's not valid. revert. component.transform.position += new Vector3(-1, 0, 0); } } }
private void ClientEditCommand_Executed(object sender, ExecutedRoutedEventArgs e) { DemonSaw.Entity.Entity entity = ClientController.SelectedItem; ClientEditWindow wnd = new ClientEditWindow(entity) { Owner = this }; bool result = (bool)wnd.ShowDialog(); if (result) { // Client ClientComponent client = entity.Get <ClientComponent>(); client.Name = wnd.ClientName.Text; client.Download = wnd.DownloadPath.Text; // Group GroupComponent group = entity.Get <GroupComponent>(); bool groupChanged = (entity == MenuController.Entity) && !group.Path.Equals(wnd.GroupPath.Text); group.Path = wnd.GroupPath.Text; GroupImage.Source = group.Image; // Options ClientOptionsComponent options = entity.Get <ClientOptionsComponent>(); options.MaxDownloads = int.Parse(wnd.MaxDownloads.Text); options.MaxUploads = int.Parse(wnd.MaxUploads.Text); // Machine MachineComponent machine = entity.Get <MachineComponent>(); machine.Restart(); // Controller MenuController.Update(); if (groupChanged) { SearchController.Clear(); BrowseController.Clear(); } } }
private void DrawComponent(Fabric.Component component, ref float x, float y) { if (component.ToString().Contains("GroupComponent")) { GroupComponent groupComponent = (GroupComponent)component; if (!_soloComponents.Contains(groupComponent)) { _soloComponents.Add(groupComponent); } component.ToString().LastIndexOf("."); string name = component.name; int num = name.Length * 10; float num2 = slotHeight; if (num < 120) { num = 120; } VolumeMeter component2 = groupComponent.GetComponent <VolumeMeter>(); if ((bool)component2) { num2 += 120f; } SideChain component3 = groupComponent.GetComponent <SideChain>(); if ((bool)component3) { num2 += 120f; } GUILayout.BeginArea(new Rect(x, y, num, GetActualSize(num2)), name, GUI.skin.window); MixerSlot(name, groupComponent); if ((bool)component2) { DrawVolumeMeters(component2, GetActualSize(num - 10)); } if ((bool)component3) { DrawSideChain(component3, GetActualSize(num - 30)); } GUILayout.EndArea(); x += num + 20; } }
private void ClientAddCommand_Executed(object sender, ExecutedRoutedEventArgs e) { ClientAddWindow wnd = new ClientAddWindow(); wnd.Owner = this; bool result = (bool)wnd.ShowDialog(); if (result) { if (!NetworkUtil.IsPortValid(wnd.Port.Text)) { return; } // Client ClientComponent client = new ClientComponent(); client.Name = wnd.ClientName.Text; client.Download = wnd.DownloadFolder.Text; client.Enabled = true; // Router ServerComponent server = new ServerComponent(); server.Address = wnd.Address.Text; server.Port = int.Parse(wnd.Port.Text); server.Passphrase = wnd.Passphrase.Text; // Group GroupComponent group = new GroupComponent(); group.Path = wnd.GroupPath.Text; GroupImage.Source = group.Image; ClientController.Add(client, server, group); ClientListView.SelectedIndex = ClientController.Count - 1; ClientController.Select(); // Controller MenuController.Update(); BrowseController.Select(); } }
public override void Select(BrowseComponent browse) { if (browse != null) { Entity entity = MenuController.Entity; ServerComponent server = entity.Get <ServerComponent>(); string path = server.Name; if (string.IsNullOrEmpty(path)) { GroupComponent group = entity.Get <GroupComponent>(); path = group.Name; } browse = entity.Get <BrowseComponent>(); browse.ComponentChanged += Update; browse.Path = path; } base.Select(browse); }
public static bool isValidGridPos(GroupComponent component) { foreach (Transform child in component.transform) { Vector2 v = GridUtil.roundVec2(child.position); // Not inside Border? if (!GridUtil.insideBorder(v)) { return(false); } // Block in grid cell (and not part of same group)? if (GridUtil.grid[(int)v.x, (int)v.y] != null && GridUtil.grid[(int)v.x, (int)v.y].parent != component.transform) { return(false); } } return(true); }
private void WriteClient(XmlWriter writer, Entity entity) { writer.WriteStartElement(XmlTag.Client); ClientComponent client = entity.Get <ClientComponent>(); writer.WriteAttributeString(XmlTag.Enabled, client.Enabled.ToString()); writer.WriteElementString(XmlTag.Id, entity.Id); writer.WriteElementString(XmlTag.Name, client.Name); writer.WriteElementString(XmlTag.Download, client.Download); GroupComponent group = entity.Get <GroupComponent>(); writer.WriteElementString(XmlTag.Group, group.Path); WriteRouter(writer, entity); WriteOptions(writer, entity); WriteFolders(writer, entity); writer.WriteEndElement(); }
private void ClientEditWindow_Loaded(object sender, RoutedEventArgs e) { // Client ClientComponent client = _entity.Get <ClientComponent>(); ClientName.Text = client.Name; DownloadPath.Text = client.Download; ClientName.Focus(); // Group GroupComponent group = _entity.Get <GroupComponent>(); GroupPath.Text = group.Path; SetGroup(); // Options ClientOptionsComponent options = _entity.Get <ClientOptionsComponent>(); MaxDownloads.Text = options.MaxDownloads.ToString(); MaxUploads.Text = options.MaxUploads.ToString(); }
public static void Update(GroupComponent component, Action yes, Action no) { if (!GridUtil.gameIsPaused) { //Vector3 pos = component.transform.position; component.transform.position += new Vector3(0, -1, 0); if (isValidGridPos(component)) { updateGrid(component); } else { component.transform.position += new Vector3(0, 1, 0); GridUtil.deleteFullRows(); yes.Invoke(); return; } no.Invoke(); } }
private void ClientListView_GroupImageButton_Click(object sender, RoutedEventArgs e) { DemonSaw.Entity.Entity entity = ClientController.SelectedItem; if (entity == null) { return; } // Group GroupComponent group = entity.Get <GroupComponent>(); OpenFileDialog dlg = new OpenFileDialog() { Title = "Browse For Group Image", FileName = group.Path, Filter = "BMP Files (*.bmp)|*.bmp|JPEG Files (*.jpeg)|*.jpeg|JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif|ICO Files (*.ico)|*.ico|PNG Files (*.png)|*.png|All files (*.*)|*.*", FilterIndex = 7 }; if (dlg.ShowDialog() == true) { // Group bool groupChanged = (entity == MenuController.Entity) && !group.Path.Equals(dlg.FileName); group.Path = dlg.FileName; GroupImage.Source = group.Image; // Machine MachineComponent machine = entity.Get <MachineComponent>(); machine.Restart(); // Controllers if (groupChanged) { SearchController.Clear(); BrowseController.Clear(); } } }
private static void updateGrid(GroupComponent component) { // Remove old children from grid for (int y = 0; y < GridUtil.h; ++y) { for (int x = 0; x < GridUtil.w; ++x) { if (GridUtil.grid[x, y] != null) { if (GridUtil.grid[x, y].parent == component.transform) { GridUtil.grid[x, y] = null; } } } } // Add new children to grid foreach (Transform child in component.transform) { Vector2 v = GridUtil.roundVec2(child.position); GridUtil.grid[(int)v.x, (int)v.y] = child; } }
public void RemoveGroupComponent(GroupComponent groupComponent) { _groupPreset = GetComponents <GroupPreset>(); if (_groupPreset == null) { return; } int num = 0; while (true) { if (num < _groupPreset.Length) { if (_groupPreset[num].GroupComponent != null && _groupPreset[num].GroupComponent.Name == groupComponent.Name) { break; } num++; continue; } return; } UnityEngine.Object.DestroyImmediate(_groupPreset[num]); }
public AddEntityToGroupEvent(GroupComponent group) { this.groupComponent = group; }