示例#1
0
    public void HidePath(LinkElementPlaceholder elementClicked)
    {
        GameObject activator = elementClicked.type == LinkElementPlaceholder.LinkElementType.Activator ? elementClicked.gameObject : elementClicked.elementLinked.gameObject;

        ClearPath(TileMapPathfinding.FindPathCoordinates(V3Helper.V3ToV3Int(currentActivatorShowed.transform.position), V3Helper.V3ToV3Int(currentActivatorShowed.GetComponent <LinkElementPlaceholder>().elementLinked.transform.position)));
        currentActivatorShowed = null;
    }
示例#2
0
 public void ClearCurrentPath()
 {
     if (currentActivatorShowed)
     {
         ClearPath(TileMapPathfinding.FindPathCoordinates(V3Helper.V3ToV3Int(currentActivatorShowed.transform.position), V3Helper.V3ToV3Int(currentActivatorShowed.GetComponent <LinkElementPlaceholder>().elementLinked.transform.position)));
         currentActivatorShowed = null;
     }
 }
示例#3
0
    public void DeleteLinkingObject(LinkElementPlaceholder LGO)
    {
        GameObject activator = LGO.type == LinkElementPlaceholder.LinkElementType.Activator ? LGO.gameObject : LGO.elementLinked.gameObject;

        if (LGO.elementLinked && currentActivatorShowed)
        {
            ClearPath(TileMapPathfinding.FindPathCoordinates(V3Helper.V3ToV3Int(activator.transform.position), V3Helper.V3ToV3Int(activator.GetComponent <LinkElementPlaceholder>().elementLinked.transform.position)));

            currentActivatorShowed = null;
        }

        if (linkingObjects.ContainsKey(LGO.gameObject))
        {
            linkingObjects.Remove(LGO.gameObject);
        }
    }
示例#4
0
    public void MovedLinkingObject(LinkElementPlaceholder LEP, Vector3 oldPos)
    {
        GameObject activator = LEP.type == LinkElementPlaceholder.LinkElementType.Activator ? LEP.gameObject : LEP.elementLinked.gameObject;

        if (currentActivatorShowed)
        {
            if (activator != LEP.gameObject)
            {
                ClearPath(TileMapPathfinding.FindPathCoordinates(V3Helper.V3ToV3Int(activator.transform.position), V3Helper.V3ToV3Int(oldPos)));
            }
            else
            {
                ClearPath(TileMapPathfinding.FindPathCoordinates(V3Helper.V3ToV3Int(oldPos), V3Helper.V3ToV3Int(LEP.elementLinked.transform.position)));
            }
        }

        DrawLine(TileMapPathfinding.FindPathCoordinates(V3Helper.V3ToV3Int(activator.transform.position), V3Helper.V3ToV3Int(activator.GetComponent <LinkElementPlaceholder>().elementLinked.transform.position)));
        currentActivatorShowed = activator;
        LEP.canvas.gameObject.SetActive(true);
        LEP.elementLinked.GetComponent <LinkElementPlaceholder>().canvas.gameObject.SetActive(true);
    }
示例#5
0
    public void ShowPath(LinkElementPlaceholder elementClicked)
    {
        if (currentActivatorShowed)
        {
            ClearPath(TileMapPathfinding.FindPathCoordinates(V3Helper.V3ToV3Int(currentActivatorShowed.transform.position), V3Helper.V3ToV3Int(currentActivatorShowed.GetComponent <LinkElementPlaceholder>().elementLinked.transform.position)));
        }

        foreach (KeyValuePair <GameObject, LinkElementPlaceholder.LinkElementType> pair in linkingObjects)
        {
            if (pair.Key != elementClicked.gameObject && pair.Key != elementClicked.elementLinked.gameObject)
            {
                LinkElementPlaceholder LEP = pair.Key.GetComponent <LinkElementPlaceholder>();
                if (LEP.canvas.gameObject.activeSelf)
                {
                    LEP.canvas.gameObject.SetActive(false);
                }
            }
        }

        GameObject activator = elementClicked.type == LinkElementPlaceholder.LinkElementType.Activator ? elementClicked.gameObject : elementClicked.elementLinked.gameObject;

        currentActivatorShowed = activator;
        DrawLine(TileMapPathfinding.FindPathCoordinates(V3Helper.V3ToV3Int(activator.transform.position), V3Helper.V3ToV3Int(activator.GetComponent <LinkElementPlaceholder>().elementLinked.transform.position)));
    }
示例#6
0
    public void LinkElement(LinkElementPlaceholder GOToLink)
    {
        // Unlink
        if (GOToLink.elementLinked)
        {
            LinkElementPlaceholder anotherLep = GOToLink.elementLinked.GetComponent <LinkElementPlaceholder>();

            currentActivatorShowed = null;
            GameObject activator = GOToLink.type == LinkElementPlaceholder.LinkElementType.Activator ? GOToLink.gameObject : anotherLep.gameObject;
            ClearPath(TileMapPathfinding.FindPathCoordinates(V3Helper.V3ToV3Int(activator.transform.position), V3Helper.V3ToV3Int(activator.GetComponent <LinkElementPlaceholder>().elementLinked.transform.position)));

            anotherLep.elementLinked   = null;
            anotherLep.buttonText.text = "Link";

            GOToLink.elementLinked   = null;
            GOToLink.buttonText.text = "Link";
            return;
        }

        // Element pending to be linked
        if (currentLinkingObject)
        {
            // Different Link types, link
            if (currentLinkingObject.type != GOToLink.type)
            {
                if (!GOToLink.elementLinked)
                {
                    GOToLink.elementLinked = currentLinkingObject.gameObject;
                    currentLinkingObject.buttonText.text = "Unlink";
                    currentLinkingObject.elementLinked   = GOToLink.gameObject;
                    GOToLink.buttonText.text             = "Unlink";
                    currentLinkingObject.ShowCanvas(true);
                    currentLinkingObject = null;

                    foreach (KeyValuePair <GameObject, LinkElementPlaceholder.LinkElementType> linkingGO in linkingObjects)
                    {
                        LinkElementPlaceholder LEP = linkingGO.Key.GetComponent <LinkElementPlaceholder>();
                        if (LEP != GOToLink && LEP != GOToLink.elementLinked.GetComponent <LinkElementPlaceholder>())
                        {
                            LEP.ShowCanvas(false);
                        }
                    }

                    GameObject activator = GOToLink.type == LinkElementPlaceholder.LinkElementType.Activator ? GOToLink.gameObject : GOToLink.elementLinked.gameObject;
                    currentActivatorShowed = activator;
                    DrawLine(TileMapPathfinding.FindPathCoordinates(V3Helper.V3ToV3Int(activator.transform.position), V3Helper.V3ToV3Int(activator.GetComponent <LinkElementPlaceholder>().elementLinked.transform.position)));
                    return;
                }
            }
            else
            {
                // Same Link types different objects, substitute
                if (currentLinkingObject != GOToLink)
                {
                    currentLinkingObject.buttonText.text = "Link";
                    GOToLink.buttonText.text             = "Cancel";
                    currentLinkingObject = GOToLink;
                }
                // Same object, cancel linking process
                else
                {
                    currentLinkingObject.buttonText.text = "Link";
                    currentLinkingObject = null;

                    HideAllInspectors();
                }
            }
        }

        // Start Linking
        currentLinkingObject = GOToLink;
        currentLinkingObject.buttonText.text = "Cancel";

        foreach (KeyValuePair <GameObject, LinkElementPlaceholder.LinkElementType> linkingGO in linkingObjects)
        {
            LinkElementPlaceholder LEP = linkingGO.Key.GetComponent <LinkElementPlaceholder>();
            if (LEP != GOToLink && !LEP.elementLinked && LEP.type != GOToLink.type)
            {
                LEP.ShowCanvas(true);
            }
        }
    }