Esempio n. 1
0
    private void Launch()
    {
        _launched = false;

        //  Use object already set in UpdateRaycast
        if (RaycastSelectObject != null)
        {
            NodeBehaviour newNode = RaycastSelectObject.GetComponent <NodeBehaviour>();

            if (newNode != null)
            {
                if (newNode.IsCursorSelected && newNode.IsOpen)
                {
                    //  Update this NodeBehaviour
                    NodeBehaviour currentNode = GetComponentInParent <NodeBehaviour>();
                    currentNode.OnTravelFrom();

                    SetToNode(RaycastSelectObject);
                    newNode.OnTravelTo();
                    _launched = true;

                    GameLoop.Instance.CurrentLevel.PushLightLine(currentNode.transform, newNode.transform);
                }
                else
                {
                    newNode.FlashWarningColor();
                }
            }
        }
    }
Esempio n. 2
0
    private void EnergizeNode(GameObject node)
    {
        //  Parent this object to the new node
        this.transform.SetParent(node.transform);
        this.transform.localPosition = Vector3.zero;

        //    _lineRenderer.positionCount = 0;

        //  Update this NodeBehaviour
        NodeBehaviour nodeBehaviour = GetComponentInParent <NodeBehaviour>();

        nodeBehaviour.OnTravelFrom();

        //Energize the next node
        Energize(LaunchDirector);

        {
            ////Copy the EnergyLauncher component to next node
            //System.Type EnergyLauncher = this.GetType();
            //var nextNodeEnergyLauncher = node.AddComponent(EnergyLauncher) as EnergyLauncher;
            //System.Reflection.FieldInfo[] fields = EnergyLauncher.GetFields();
            //foreach (var field in fields) {
            //    field.SetValue(nextNodeEnergyLauncher, field.GetValue(this));
            //}

            ////Reposition the LaunchDirector relative to next node
            //var directorDistance = (transform.position - LaunchDirector.transform.position).magnitude;
            //var translateDirection = (node.transform.position - LaunchDirector.transform.position).normalized;
            //LaunchDirector.transform.position = node.transform.position + (translateDirection * directorDistance);

            ////Set material to unfocused
            //_meshRenderer.material = UnfocusMaterial;

            ////  Update this NodeBehaviour
            //NodeBehaviour nodeBehaviour = this.GetComponent<NodeBehaviour>();
            //nodeBehaviour.OnTravelFrom();

            ////Energize the next node and destroy this energyLauncher
            //nextNodeEnergyLauncher.Energize(LaunchDirector);
            //StartCoroutine(SelfDestruct());
        }
    }