Exemplo n.º 1
0
    public void AddToModel(GameObject socket)
    {
        transform.parent           = coreParent.transform;
        targetPosition             = socket.transform.position;
        onModel                    = true;
        localRigidBody.isKinematic = true;
        localRigidBody.useGravity  = false;

        parentPartScript = socket.transform.parent.gameObject.GetComponent <Local_Part_Manager>();
        parentSocket     = socket;
        parentPartScript.SocketToggle(false, socket);
    }
Exemplo n.º 2
0
    // Update is called once per frame
    void FixedUpdate()
    {
        bool raycast = Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out hit, distanceOfRay, layerMask);

        if (raycast)
        {
            if (hit.collider != previousCollider)
            {
                //disconnect previous particle system before connecting to the new one
                if (previousCollider != null)
                {
                    currentParticleScriptRef.Disconnect(previousCollider.gameObject);
                    if (currentHeldScriptRef != null)
                    {
                        currentHeldScriptRef.UnsetRotate();
                    }
                    connected = false;
                }

                currentParticleScriptRef = hit.collider.transform.parent.GetComponent <Local_Part_Manager>();

                //connect enables the new particle system
                currentParticleScriptRef.Connect(hit.collider.gameObject);
                if (currentHeldScriptRef != null)
                {
                    currentHeldScriptRef.SetRotate(hit.collider.gameObject);
                }

                connected = true;

                //reset previousCollider
                previousCollider = hit.collider;
            }
        }
        else
        {
            //disconnect disables the particle system
            if (previousCollider != null)
            {
                currentParticleScriptRef.Disconnect(previousCollider.gameObject);
                if (currentHeldScriptRef != null)
                {
                    currentHeldScriptRef.UnsetRotate();
                }
            }
            previousCollider         = null;
            currentParticleScriptRef = null;
            connected = false;
        }
    }
Exemplo n.º 3
0
    public void Initalise()
    {
        materialRef = gameObject.transform.GetChild(0).GetComponent <Renderer>().material;
        //colorMeter = materialRef.GetFloat("colorMeter");
        //shadowMeter = materialRef.GetFloat("shadowMeter");

        //weird script reference setting
        GameObject gameManagerObject = GameObject.Find("GameManager");

        globalPartManager = gameManagerObject.GetComponent <Part_Manager>();
        var gameManager = gameManagerObject.GetComponent <Game_Manager>();

        socketLaser = gameManager.socketLaser;

        //grab these from the GameManager
        rotateSpeed = gameManager.rotateSpeed;
        moveSpeed   = gameManager.moveSpeed;

        coreParent = gameManager.partCreator.coreParent;
        thisScript = gameObject.GetComponent <Local_Part_Manager>();

        myHand         = gameManagerObject.GetComponent <Game_Manager>().myHand;
        localRigidBody = gameObject.GetComponent <Rigidbody>();

        //grabs the parent when initalised, the part parent object.
        origParent = transform.parent;

        //sets the length of socketOccupied
        socketOccupied = new bool[socketList.Count];

        //turn off the socket colliders
        if (shape != Shape.corePart00 || shape != Shape.corePart01)
        {
            SocketToggle(false);
        }
        else
        {
            masterBlueprintReference = globalPartManager.masterBlueprint[0];
        }

        childObjects = new GameObject[socketList.Count];
    }
Exemplo n.º 4
0
 // Start is called before the first frame update
 void Start()
 {
     localManager = GetComponentInParent <Local_Part_Manager>();
 }