示例#1
0
    /// <summary>
    /// Callback for the Upgrade UI.
    /// <param name="type">String indicating the type of tower upgrade requested.</param>
    /// </summary>
    public void OnClick(string type)
    {
        Hide();
        ETowerType requestedType = ETowerTypeUtils.GetTowerType(type);

        showUpgradeDialog.Invoke(requestedType);
    }
示例#2
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);
        }
示例#3
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);
        }
示例#4
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);
        }
示例#5
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);
        }
示例#6
0
    void Update()
    {
        // Check left mouse click or "select"
        if (Input.GetButtonDown("Fire1"))
        {
            if (Physics.Raycast(mainCamera.ScreenPointToRay(Input.mousePosition), out RaycastHit hit))
            {
                GameObject hitObject = hit.transform.parent.gameObject;
                if (hitObject.CompareTag("Tower"))
                {
                    showMenu.Invoke(hitObject, typeof(TowerMenuUISystem));
                }
            }
        }

        // Check right mouse click or "walk"
        if (Input.GetButtonDown("Fire2"))
        {
            if (Physics.Raycast(mainCamera.ScreenPointToRay(Input.mousePosition), out RaycastHit hit))
            {
                player.GetComponent <AIController>().MoveTo(hit.point);
            }
        }

        // Check escape button or "cancel"
        if (Input.GetButtonDown("Cancel"))
        {
            hideMenu.Invoke();
        }

        // TODO: Use input mappings here
        // Check the X button or "place", toggle the selector
        if (Input.GetKeyDown(KeyCode.X))
        {
            Physics.Raycast(mainCamera.ScreenPointToRay(Input.mousePosition), out RaycastHit hit, LayerMask.GetMask("Ground"));
            EventRegistry.Invoke("togglePlacer", BaseTower, hit.point, false);
        }

        if (Input.GetKeyDown(KeyCode.P))
        {
            EventRegistry.Invoke("pause");
        }
    }
示例#7
0
 /// <summary>
 /// Instantiate the tower.
 /// </summary>
 /// <returns>True if successfully instantiated the tower.</returns>
 public bool PlaceTower()
 {
     placePoint = transform.position;
     if (!blocked)
     {
         if (toDestroy)
         {
             string     type          = ETowerTypeUtils.GetString(TowerObject.GetComponent <TowerType>().Type);
             ETowerType requestedType = ETowerTypeUtils.GetTowerType(type);
             showMoveDialog.Invoke(requestedType);
         }
         else
         {
             isActionComplete = true;
             Instantiate(TowerObject, placePoint, transform.rotation);
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
 /// <summary>
 /// Passed as a callback for the Cancel button on the upgrade dialog.
 /// </summary>
 public void OnCancelClick()
 {
     cancelTowerCreation.Invoke();
 }
 /// <summary>
 /// Passed an a callback for the OK button on the upgrade dialog.
 /// </summary>
 public void OnOKClick()
 {
     GameState.CurrentCash -= currentType.GetCost();
     createTower.Invoke(currentType);
 }
示例#10
0
 /// <summary>
 /// Passed as a callback for the OK button on the move dialog.
 /// </summary>
 public void OnOKClickMove()
 {
     GameState.CurrentCash -= currentType.GetMoveCost();
     moveTransaction.Invoke(true);
 }
示例#11
0
 void Update()
 {
     a.Invoke("Hello", 1);
 }