Exemple #1
0
        // Start is called before the first frame update
        void OnEnable()
        {
            Debug.Log("Enabling Powerline");
            game = (GameController)GameObject.FindGameObjectWithTag("gameController").GetComponent(typeof(IGameController));
            transform.position = game.getBound().center + new Vector3(0f, 1f, 0f);

            //Scale
            float boundX = game.getBound().extents.x;
            float boundY = game.getBound().extents.y;

            GetComponent <Collider2D>().enabled = true;
            Bounds thisBound = GetComponent <Collider2D>().bounds;

            zoomFactor = Mathf.Max(0.6f * boundX / thisBound.extents.x, (0.6f * boundY / thisBound.extents.y));

            //Set the scale
            transform.localScale *= zoomFactor;

            //Set the width of the line
            GetComponent <LineRenderer>().widthMultiplier          = zoomFactor * 0.1f;
            fillLine.GetComponent <LineRenderer>().widthMultiplier = zoomFactor * 0.1f;
            fillLine.StartEndPoints(originPole, destinationPole);

            foreach (LineRenderer otherLine in otherLines)
            {
                otherLine.widthMultiplier = zoomFactor * 0.1f;
            }
        }
Exemple #2
0
        private void InitializePowerline(GameObject interactableLine)
        {
            coroutines = new List <Coroutine>();

            interactableLine.GetComponent <PowerlineSpline>().enabled = true;

            coroutines.Add(StartCoroutine(interactableLine.GetComponent <Transition>().lineRendererFadeIn()));
            foreach (GameObject powerline in powerlines)
            {
                coroutines.Add(StartCoroutine(powerline.GetComponent <Transition>().lineRendererFadeIn()));
            }

            hand.SetActive(true);
            if (interactableLine.Equals(interactableLineLeft))
            {
                hand.transform.position = new Vector3(game.getBound().center.x + game.getBound().extents.x * 0.2f, game.getBound().center.y, HAND_Z_OFFSET);
            }
            else
            {
                hand.transform.position = new Vector3(game.getBound().center.x, game.getBound().center.y, HAND_Z_OFFSET);
            }
        }