Ejemplo n.º 1
0
    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();
    }
Ejemplo n.º 2
0
    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);
    }
Ejemplo n.º 3
0
    // 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();
    }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
    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();
        });
    }
Ejemplo n.º 6
0
 public void AddOnDataReceivedListener(UnityAction <string> listener)
 {
     if (onDataReceived == null)
     {
         onDataReceived = new StringEvent();
     }
     onDataReceived.AddListener(listener);
 }
Ejemplo n.º 7
0
    void Start()
    {
        LogWindow logWindow = GameObject.Find("LogWindow").GetComponent <LogWindow>();

        logEvent.AddListener(logWindow.DisplayIntoLogWindow);

        StartTurn();
    }
Ejemplo n.º 8
0
 public void Set(string answer, NatoQuestion natoQuestion)
 {
     Show(true);
     onClicked.AddListener(natoQuestion.Answer);
     answerText.text     = answer;
     buttonText          = answer;
     button.interactable = true;
 }
Ejemplo n.º 9
0
 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注册成功!!!");
        }
Ejemplo n.º 12
0
        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");
        }
Ejemplo n.º 13
0
    public override void OnLoadSystem()
    {
        cachedSaveData = SaveUtility.LoadSave(saveSlot.Value);

        if (cachedSaveData == null)
        {
            CreateNewSave();
            isNewGame = true;
        }

        onSceneWarp?.AddListener(OnSceneWarp);
        onWarpStart?.AddListener(OnWarpStart);
        onWarpEnd?.AddListener(OnWarpEnd);
    }
Ejemplo n.º 14
0
    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);
 }
Ejemplo n.º 16
0
 private void Awake()
 {
     warpEvent?.AddListener(OnSceneWarp);
 }
Ejemplo n.º 17
0
 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);
 }
Ejemplo n.º 19
0
 private void OnEnable()
 {
     debugEvent.AddListener(Debug);
 }
Ejemplo n.º 20
0
 public Suggestion(string label)
 {
     this.label = label;
     onComplete.AddListener((input) => { Interpreter.UpdateTermField(label); });
     onSubmit.AddListener((input) => { Debug.Log(label); });
 }
Ejemplo n.º 21
0
    private void Awake()
    {
        onSceneChanged.AddListener(OnSceneChanged);

        GetConfinement();
    }