Пример #1
0
    protected void BreakLink(GameData.Link link)
    {
        //Unlink Stars
        Stars[link.StarIds[0]].LinkedStars.Remove(link.StarIds[1]);
        Stars[link.StarIds[1]].LinkedStars.Remove(link.StarIds[0]);

        //Delete Link
        Destroy(link.LineComponent.gameObject);

        CheckStrandedStar(Stars[link.StarIds[0]]);
        CheckStrandedStar(Stars[link.StarIds[1]]);
    }
Пример #2
0
    protected void CheckLink(GameData.Link link)
    {
        RaycastHit hit;

        if (Physics.Linecast(link.StartPos, link.EndPos, out hit))
        {
            if (hit.transform.gameObject.name.Contains("Player"))
            {
                BreakConstellation();
            }
        }
    }
Пример #3
0
    protected void BreakStarLink(GameData.Constellation constellation, Guid starId)
    {
        var star = constellation.Stars[starId];

        //Remove star from linked stars
        for (int i = 0; i < star.LinkedStars.Count; i++)
        {
            if (constellation.Stars.ContainsKey(star.LinkedStars[i]))
            {
                GameData.Star linkedStar = constellation.Stars[star.LinkedStars[i]];
                linkedStar.LinkedStars.Remove(star.StarId);
            }
        }

        //Get all involved links
        List <GameData.Link> removedLinks = new List <GameData.Link>();

        for (int i = 0; i < constellation.Links.Count; i++)
        {
            if (constellation.Links[i].StarIds.Contains(star.StarId))
            {
                removedLinks.Add(constellation.Links[i]);
            }
        }

        //Destroy Link
        for (int i = 0; i < removedLinks.Count; i++)
        {
            GameData.Link link = removedLinks[i];
            constellation.Stars[link.StarIds[0]].LinkedStars.Remove(constellation.Stars[link.StarIds[1]].StarId);
            constellation.Stars[link.StarIds[1]].LinkedStars.Remove(constellation.Stars[link.StarIds[0]].StarId);
            Destroy(link.LineComponent.gameObject);
            constellation.Links.Remove(link);
        }

        //Return to original layer
        star.Controller.UpdateLayerToStar();

        //Remove star from constellation
        constellation.Stars.Remove(starId);
        PooledObject pool = star.Controller.gameObject.GetComponent <PooledObject>();

        pool.ReturnToPool();
    }
Пример #4
0
    public void AddStar(GameData.Star star)
    {
        //If star not already stored
        if (!Stars.ContainsKey(star.StarId))
        {
            Stars.Add(star.StarId, star);
        }

        //There is a last star
        if (LastStar != null)
        {
            //Is not currently linked to star
            if (!LastStar.LinkedStars.Contains(star.StarId))
            {
                //Link Stars to Eachother
                LastStar.LinkedStars.Add(star.StarId);
                star.LinkedStars.Add(star.StarId);

                //Create Link
                var link = new GameData.Link();
                link.StarIds.Add(LastStar.StarId);
                link.StarIds.Add(star.StarId);

                //Create Link Object
                var linkObject = Instantiate(LinkPrefab);
                var line       = linkObject.GetComponent <LineRenderer>();

                if (StarLinkParent != null)
                {
                    linkObject.transform.SetParent(StarLinkParent);
                    linkObject.transform.localScale = Vector3.one;
                }

                link.LineComponent = line;
                link.StartPos      = LastStar.Position;
                link.EndPos        = star.Position;
                line.SetPosition(0, link.StartPos);
                line.SetPosition(1, link.EndPos);
                Links.Add(link);
            }
        }
        LastStar = star;
    }
Пример #5
0
    public void AddStar(GameData.Star star)
    {
        //If star not already stored
        if (!Stars.ContainsKey(star.StarId))
        {
            Stars.Add(star.StarId, star);
        }

        //There is a last star
        if (LastStarId != null)
        {
            GameData.Star lastStar = Stars[(Guid)LastStarId];

            //Is not currently linked to star
            if (!lastStar.LinkedStars.Contains(star.StarId) || !star.LinkedStars.Contains(lastStar.StarId))
            {
                //Error Checking - make sure links are being properly linked to both stars
                if (lastStar.LinkedStars.Contains(star.StarId) != star.LinkedStars.Contains(lastStar.StarId))
                {
                    Debug.Log("Previous Linkes weren't properly created");
                }

                //Link Stars to Eachother
                if (!lastStar.LinkedStars.Contains(star.StarId))
                {
                    lastStar.LinkedStars.Add(star.StarId);
                }
                if (!star.LinkedStars.Contains(lastStar.StarId))
                {
                    star.LinkedStars.Add(lastStar.StarId);
                }

                //Create Link
                var link = new GameData.Link();
                link.StarIds.Add(lastStar.StarId);
                link.StarIds.Add(star.StarId);

                //Create Link Object
                var linkObject = Instantiate(LinkPrefab);
                var line       = linkObject.GetComponent <LineRenderer>();
                line.useWorldSpace = false;

                if (StarLinkParent != null)
                {
                    linkObject.transform.SetParent(StarLinkParent);
                    linkObject.transform.localScale = Vector3.one;
                }

                link.LineComponent = line;
                link.StartPos      = lastStar.Position;
                link.EndPos        = star.Position;
                line.SetPosition(0, new Vector3(link.StartPos.x, link.StartPos.y, 1f));
                line.SetPosition(1, new Vector3(link.EndPos.x, link.EndPos.y, 1f));

                Links.Add(link);
                InvincibilityCountdown = InvincibiltyCountdownMax;
            }
        }

        LastStarId = star.StarId;
    }