Exemple #1
0
 void Awake()
 {
     renderer       = GetComponent <Renderer>();
     showMoveDialog = EventRegistry.GetEvent <ETowerType>("showMoveDialog");
     EventRegistry.RegisterAction <bool>("moveTransaction", MoveTransaction);
     toDestroy = false;
 }
    void Start()
    {
        dialogSystem = transform.Find("Dialog")?.GetComponent <DialogSystem>();
        cashDisplay  = transform.Find("WalletBG/Cash")?.GetComponent <Text>();

        // Register events and callbacks
        createTower         = EventRegistry.GetEvent <ETowerType>("createTower");
        cancelTowerCreation = EventRegistry.GetEvent("cancelTowerCreation");
        EventRegistry.RegisterAction <ETowerType>("showUpgradeDialog", ShowUpgradeDialog);
    }
Exemple #3
0
        public IEnumerator UIShowsUpOnUpgradeClick()
        {
            TDEvent <ETowerType> showUpgradeDialog = EventRegistry.GetEvent <ETowerType>("showUpgradeDialog");

            showUpgradeDialog.Invoke(ETowerType.Base);
            GameObject dialogBox = GameObject.Find("UIManager").transform.Find("WalletUI/Dialog").gameObject;

            yield return(null);

            Assert.True(dialogBox.activeSelf);
        }
Exemple #4
0
        public IEnumerator CashDeductedUponAction()
        {
            GameObject           walletUI       = GameObject.Find("UIManager").transform.Find("WalletUI").gameObject;
            int                  originalCash   = GameState.CurrentCash;
            TDEvent <ETowerType> showMoveDialog = EventRegistry.GetEvent <ETowerType>("showMoveDialog");

            showMoveDialog.Invoke(ETowerType.Base);
            walletUI.GetComponent <WalletUISystem>().OnOKClickMove();
            yield return(null);

            Assert.AreNotEqual(originalCash, GameState.CurrentCash);
        }
Exemple #5
0
        public IEnumerator UIButtonTextDependsOnConfig()
        {
            TDEvent <ETowerType> showMoveDialog = EventRegistry.GetEvent <ETowerType>("showMoveDialog");

            showMoveDialog.Invoke(ETowerType.Base);
            GameObject dialogBox    = GameObject.Find("UIManager").transform.Find("WalletUI/Dialog").gameObject;
            GameObject okButtonText = dialogBox.transform.Find("OKButton/Text").gameObject;

            yield return(null);

            Assert.AreEqual("Move", okButtonText.GetComponent <Text>().text);
        }
    void Start()
    {
        // Initialize private fields
        mainCamera = Camera.main;
        player     = GameObject.Find("Player");

        // Show mouse in game
        Cursor.visible = true;

        // Register events and callbacks
        showMenu = EventRegistry.GetEvent <GameObject, Type>("showMenu");
        hideMenu = EventRegistry.GetEvent("hideMenu");
    }
Exemple #7
0
        public IEnumerator UIGoesAwayOnCancelClick()
        {
            TDEvent <ETowerType> showMoveDialog = EventRegistry.GetEvent <ETowerType>("showMoveDialog");

            showMoveDialog.Invoke(ETowerType.Base);
            GameObject dialogBox = GameObject.Find("UIManager").transform.Find("WalletUI/Dialog").gameObject;

            yield return(null);

            dialogBox.GetComponent <DialogSystem>().CancelClicked();
            yield return(null);

            Assert.False(dialogBox.activeSelf);
        }
Exemple #8
0
    void Start()
    {
        // Initialize private fields
        GameObject image = GameObject.Find("UpgradeUI/Image");

        for (int i = 1; i < image.transform.childCount; i++)
        {
            upgradeButtons.Add(image.transform.GetChild(i).gameObject);
        }

        // Hide canvas
        Hide();

        // Register events and callbacks
        showUpgradeDialog = EventRegistry.GetEvent <ETowerType>("showUpgradeDialog");
        EventRegistry.RegisterAction <ETowerType>("createTower", CreateTower);
        EventRegistry.RegisterAction("cancelTowerCreation", CancelTowerCreation);
    }
        private void EnsureRowIndexListCurrent()
        {
            int rebuildIndex = rowListRebuild;
            int journalCount = EventRegistry.EventCount;

            while (rebuildIndex < journalCount)
            {
                var command = EventRegistry.GetEvent(rebuildIndex);
                if (command is TableRowEvent)
                {
                    var rowEvent = (TableRowEvent)command;
                    var index    = rowEvent.RowNumber;

                    if (rowEvent.EventType == TableRowEventType.Add ||
                        rowEvent.EventType == TableRowEventType.UpdateAdd)
                    {
                        // Add to 'row_list'.
                        if (!RowIndex.UniqueInsertSort(index))
                        {
                            throw new InvalidOperationException(String.Format("Row index already used in this table ({0})", index));
                        }
                    }
                    else if (rowEvent.EventType == TableRowEventType.Remove ||
                             rowEvent.EventType == TableRowEventType.UpdateRemove)
                    {
                        // Remove from 'row_list'
                        if (!RowIndex.RemoveSort(index))
                        {
                            throw new InvalidOperationException("Row index removed that wasn't in this table!");
                        }
                    }
                    else
                    {
                        throw new InvalidOperationException(String.Format("Table row event type {0} is invalid.", rowEvent.EventType));
                    }
                }

                ++rebuildIndex;
            }

            // It's now current (row_list_rebuild == journal_count);
            rowListRebuild = rebuildIndex;
        }
Exemple #10
0
        private void EnsureColumnIndexCurrent(int column)
        {
            var index = columnIndexes[column];

            // NOTE: We should be assured that no Write operations can occur over
            //   this section of code because writes are exclusive operations
            //   within a transaction.
            // Are there journal entries pending on this scheme since?
            int rebuildIndex = indexRebuilds[column];
            int journalCount = EventRegistry.EventCount;

            while (rebuildIndex < journalCount)
            {
                var tableEvent = EventRegistry.GetEvent(rebuildIndex);
                if (tableEvent is TableRowEvent)
                {
                    var rowEvent = (TableRowEvent)tableEvent;
                    if (rowEvent.EventType == TableRowEventType.Add ||
                        rowEvent.EventType == TableRowEventType.UpdateAdd)
                    {
                        index.Insert(rowEvent.RowNumber);
                    }
                    else if (rowEvent.EventType == TableRowEventType.Remove ||
                             rowEvent.EventType == TableRowEventType.UpdateRemove)
                    {
                        index.Remove(rowEvent.RowNumber);
                    }
                    else
                    {
                        throw new InvalidOperationException(String.Format("Table row event type {0} is invalid.", rowEvent.EventType));
                    }
                }

                ++rebuildIndex;
            }

            indexRebuilds[column] = rebuildIndex;
        }
 void Start()
 {
     a = EventRegistry.GetEvent <string, int>("test");
 }