void Awake() { logEvent = new StringEvent(); LogWindow logWindow = GameObject.Find("LogWindow").GetComponent <LogWindow>(); logEvent.AddListener(logWindow.DisplayIntoLogWindow); //Для тестирования установим персонажам некоторую экипировку if (name == "Warrior") { onMainHand = new Weapon("Longsword", 3, 15, EquipmentType.FindByShortcut("M"), DiceSet.GetByName("1d8"), DamageType.Slashing, 5); armor = new Armor("Chain Mail", 55, 75, EquipmentType.FindByShortcut("HA"), 16); } else if (name == "Wizard") { //onMainHand = new Weapon("Quarterstaff", 2, 4, EquipmentType.FindByShortcut("M"), DiceSet.GetDiceSet("1d6"), DamageType.FindByShortcut("B"), 5); onMainHand = new Weapon("Fire bolt", 0, 0, EquipmentType.FindByShortcut("R"), DiceSet.GetByName("1d10"), DamageType.Fire, 30); } //Если зомби - установим оружие "когти зомби" else if (name.Contains("Zombie")) { onMainHand = new Weapon("Zombie's claws", 0, 0, EquipmentType.FindByShortcut("M"), DiceSet.GetByName("1d6"), DamageType.Bludgeoning, 5); } InitializeParameters(); CalculateArmorClass(); CalculateInitiative(); DefineAttackRange(); }
void Start() { allCharacters = new List <Character>(); initiativeTracker = new LinkedList <Character>(); GameObject[] allCharacterObjects = GameObject.FindGameObjectsWithTag("Character"); foreach (GameObject characterObject in allCharacterObjects) { Character character = characterObject.GetComponent <Character>(); allCharacters.Add(character); addCharacterToInitiativeTracker(character); } LogWindow logWindow = GameObject.Find("LogWindow").GetComponent <LogWindow>(); logEvent.AddListener(logWindow.DisplayIntoLogWindow); //Для тестирования выведем на экран трекер инициативы foreach (Character character in initiativeTracker) { logEvent.Invoke(character.name + "'s initiative is " + character.Initiative); } currentRound = 1; logEvent.Invoke("Round " + currentRound); }
// Start is called before the first frame update void Start() { OnStartButtonCombination.AddListener(() => { if (!isDoingTest) { if (isRandom) { CreateRandomButtonCombination(); } else { CreateStringCombination(); } } }); OnStartButtonCombinationDrop.AddListener(SetStringCombination); OnNewCombination.AddListener((unused) => { //Debug.LogWarning("NEW COMBINATION: " + unused); if (CurrentPlayer != null) { CurrentPlayer.GivenWord = unused; } isDoingTest = true; index = 0; }); OnCombinationComplete.AddListener(() => { isDoingTest = false; }); ParseWords(); }
public override void Init() { //Cleaning out old listeners in case of reuse ServerMethod.RemoveAllListeners(); if (ServerMethod.GetPersistentEventCount() == 0) { return; } //some reflection is required here. //reading prefab-based listener information: var tabToLookup = ServerMethod.GetPersistentTarget(0); MethodInfo methodInfo = UnityEventBase.GetValidMethodInfo(tabToLookup, ServerMethod.GetPersistentMethodName(0), new[] { typeof(string) }); //disabling rigid listener ServerMethod.SetPersistentListenerState(0, UnityEventCallState.Off); //looking up a live instance of that tab we initially mapped listener to (in editor) var foundComponent = GetComponentInParent(tabToLookup.GetType()); //making a dynamic copy of initial prefab-based listener UnityAction <string> execute = str => methodInfo.Invoke(foundComponent, new object[] { str }); //applying a dynamic copy of initial prefab-based listener ServerMethod.AddListener(execute); }
public void Initialize(List <GameObject> cards) { gameLogic = FindObjectOfType <VariantGameLogic>(); foreach (var card in cards) { var selectableComponent = card.GetComponent <VariantCardSelectable>(); selectedCards.Add(selectableComponent); } startGameBtn.onClick.AddListener(() => { if (DataIsValid()) { startGameBtn.gameObject.SetActive(false); StartGame(); } }); SelectEvent.AddListener((key) => { selectedCardsKeys.Add(key); UpdateIndicator(); }); UnselectEvent.AddListener((key) => { selectedCardsKeys.Remove(key); UpdateIndicator(); }); }
public void AddOnDataReceivedListener(UnityAction <string> listener) { if (onDataReceived == null) { onDataReceived = new StringEvent(); } onDataReceived.AddListener(listener); }
void Start() { LogWindow logWindow = GameObject.Find("LogWindow").GetComponent <LogWindow>(); logEvent.AddListener(logWindow.DisplayIntoLogWindow); StartTurn(); }
public void Set(string answer, NatoQuestion natoQuestion) { Show(true); onClicked.AddListener(natoQuestion.Answer); answerText.text = answer; buttonText = answer; button.interactable = true; }
private static void AddEventListeners() { connectResponseEvent.AddListener(OnConnect); disconnectResponseEvent.AddListener(OnDisconnect); joinRoomResponseEvent.AddListener(OnJoinRoom); leaveRoomResponseEvent.AddListener(OnLeaveRoom); roomListResponseEvent.AddListener(OnRoomListReceived); customMessageResponseEvent.AddListener(OnCustomMessage); }
private void Awake() { parent = transform.parent; localPosition = transform.localPosition; inputComponent.onEndEdit.AddListener(AddNewOption); OnOptionRemoved.AddListener(OnRemove); OnOptionRenamed.AddListener(OnRename); OnOptionAdd.AddListener(OnAdd); canvasGroup.alpha = 0; }
private void UEventRegisterTest() { //Register non param UEventsManager.Instance.PutUEventInVoidDic(m_VoidEvent, "uv0"); m_VoidEvent.AddListener(new UnityAction(NonParamInScript)); //Register one param UEventsManager.Instance.PutUEventInVoidDic <string>(m_StringEvent, "uv1"); m_StringEvent.AddListener(new UnityAction <string>(OneParamInScript)); print("OLiOUEvent注册成功!!!"); }
public void StringEventTest() { var e = new StringEvent(); string counter = ""; e.AddListener((val) => counter += "-" + val); Assert.AreEqual(counter, ""); e.Invoke("1"); Assert.AreEqual(counter, "-1"); e.Invoke("22"); e.Invoke("33"); Assert.AreEqual(counter, "-1-22-33"); }
public override void OnLoadSystem() { cachedSaveData = SaveUtility.LoadSave(saveSlot.Value); if (cachedSaveData == null) { CreateNewSave(); isNewGame = true; } onSceneWarp?.AddListener(OnSceneWarp); onWarpStart?.AddListener(OnWarpStart); onWarpEnd?.AddListener(OnWarpEnd); }
public static void StartListening(string eventName, UnityAction <string> listener) { StringEvent thisEvent = null; if (Instance.stringEventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.AddListener(listener); } else { thisEvent = new StringEvent(); thisEvent.AddListener(listener); Instance.stringEventDictionary.Add(eventName, thisEvent); } }
public static void AddOnce(this StringEvent thisEvent, UnityAction <string> reciever) { thisEvent.RemoveListener(reciever); thisEvent.AddListener(reciever); }
private void Awake() { warpEvent?.AddListener(OnSceneWarp); }
public ShortcutSuggestion(string shortcut) { this.shortcut = shortcut; onComplete.AddListener((input) => { Interpreter.UpdateTermField(label); }); onSubmit.AddListener((input) => { TriggerShortcut(shortcut); }); }
public void AddOnObjectReleasedListener(UnityAction <string> onObjectReleasedListener) { onObjectReleased.AddListener(onObjectReleasedListener); }
private void OnEnable() { debugEvent.AddListener(Debug); }
public Suggestion(string label) { this.label = label; onComplete.AddListener((input) => { Interpreter.UpdateTermField(label); }); onSubmit.AddListener((input) => { Debug.Log(label); }); }
private void Awake() { onSceneChanged.AddListener(OnSceneChanged); GetConfinement(); }