Example #1
0
    public void UpdateLinks()
    {
        triMenu.DestroyLinks();
        if (selectedBuilding != null)
        {
            Dictionary <GameObject, LinkType> links = selectedBuilding.GetLinks();
            if (links != null)
            {
                foreach (KeyValuePair <GameObject, LinkType> val in links)
                {
                    Vector3 linkPos = new Vector3();

                    linkPos = val.Key.transform.position;
                    linkPos = gameCam.WorldToScreenPoint(linkPos);
                    GameObject newObject;
                    newObject = Instantiate(linkFab);
                    newObject.transform.SetParent(this.transform.parent);
                    newObject.transform.position = linkPos;
                    newObject.GetComponent <LinkToggle>().SetToggle(val.Value);
                    newObject.GetComponent <LinkToggle>().linkingTower   = selectedBuilding.gameObject;
                    newObject.GetComponent <LinkToggle>().linkingAugment = val.Key;
                    GameObject collider = newObject.GetComponentInChildren <MeshCollider>().gameObject;
                    collider.transform.position = val.Key.transform.position;
                    triMenu.AddLink(newObject);
                    triMenu.CreateDetails();
                    triMenu.LoadDetails(selectedBuilding.GetDetails());
                    triMenu.RefreshDetails();
                }
                if (selectedBuilding is TowerBase towerBase)
                {
                    towerBase.ShowHexes();
                }
            }
        }
    }