Example #1
0
    void OnMouseDown()
    {
        //blocks the player if they are hovering over a UI overlay.
        if (EventSystem.current.IsPointerOverGameObject())
        {
            return;
        }

        //if there is already a turret, then it will select the node instead.
        if (tower != null)
        {
            buildmanager_script.SelectNode(this);
            return;
        }

        //if the player aren't able to build, then exit out now.
        if (!buildmanager_script.CanBuild)
        {
            return;
        }

        //otherwise, build the selected turret on top of this node.
        BuildTurret(buildmanager_script.GetTurretToBuild());
    }
Example #2
0
    void OnMouseDown()
    {
        Debug.Log("!!!!!DO");
        if (IsPointerOverUIObject())
        {
            return;
        }
//		buildmanager.DisableCanvas();
        DisTurretRange();

        if (isServer)
        {
            if (this.tag != "HostNode")
            {
                return;
            }
        }
        if (!isServer)
        {
            if (this.tag != "ClientNode")
            {
                return;
            }
        }

        if (EventSystem.current.IsPointerOverGameObject())
        {
            return;
        }

        if (turret != null)
        {
            buildmanager.DisBuild();
            buildmanager.ResetNodeUIColor();
            SelectAudiance.Play();
            if (turret.tag == "turret" | turret.tag == "UpgradedTurret")
            {
                DisTurretRange();
                Tower tower = turret.GetComponent <Tower>();
                tower.ShowRange();
                buildmanager.SelectNode(this);
            }
            else if (turret.tag == "path")
            {
                AstarPath.active.AddWorkItem(new AstarWorkItem(() => {
                    // Safe to update graphs here
                    var node      = AstarPath.active.GetNearest(transform.position).node;
                    node.Walkable = false;
                }));
                StartCoroutine(WaitForAstar());
            }
            else if (turret.tag == "MoneyTurret")
            {
                Debug.Log("TouchMony!!!");
                turret.GetComponent <MoneyTurret>().Money();
            }
            else if (turret.tag == "HolyTurret")
            {
                Debug.Log("Heal!!!!");
                turret.GetComponent <HolyTurret>().Heal();
            }

            return;
        }
        else
        {
            buildmanager.OffNodeUI();
        }

        if (!buildmanager.CanBuild)
        {
            return;
        }
    }