Esempio n. 1
0
 IEnumerator ActivateActivables()
 {
     if (_board != null)
     {
         Activable activable = _board.FindActivableAt(_board.PlayerNode);
         if (activable != null)
         {
             yield return(StartCoroutine(activable.Activate()));
         }
     }
     else
     {
         Debug.LogWarning("PLAYERMANAGER ActivateActivables Error: _board is null");
     }
     yield return(new WaitForSeconds(0f));
 }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        RaycastHit hit = new RaycastHit();
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        if (Physics.Raycast(ray, out hit, rayCastInteractionRange))
        {
            GameObject obj = hit.transform.gameObject;
            if ((obj.gameObject.layer == LayerMask.NameToLayer("UI")) && (currentObj != obj))
            {
                ApplyShader(obj, "Outlined/Silhouetted Diffuse");
                if (currentObj != null)
                {
                    ApplyShader(currentObj, "Diffuse");
                }
                currentObj = obj;
            }
        }
        else if (currentObj != null)
        {
            ApplyShader(currentObj, "Diffuse");
            currentObj = null;
        }
        if (currentObj != null)
        {
            // FIRE1 = Pick up/Release
            if (Input.GetButtonDown("Fire1"))
            {
                if (itemPicked != null)
                {
//					itemPicked.transform.SetParent(null);
                    ((Rigidbody)itemPicked.GetComponent <Rigidbody> ()).isKinematic = false;
                    itemPicked = null;
                }
                else if (currentObj.tag == "PickUp")
                {
                    itemPicked = currentObj;
                    ((Rigidbody)itemPicked.GetComponent <Rigidbody> ()).isKinematic = true;
                    screenPoint = Camera.main.WorldToScreenPoint(itemPicked.transform.position);
                    offset      = itemPicked.transform.position - Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z));
//					itemPicked.transform.SetParent(transform.parent);
                }
            }
            // FIRE2 = Activate/Desactivate
            if (Input.GetButtonDown("Fire2"))
            {
                Activable activable = currentObj.GetComponent <Activable>();
                if (activable != null)
                {
                    activable.Activate();
                }
            }
            //FIRE3 = Rotate
            if (Input.GetButtonDown("Fire3"))
            {
            }
        }
        if (itemPicked != null)
        {
            MoveItem();
        }
    }
 private void ActivateButton()
 {
     activated          = true;
     transform.position = activatedPosition.position;
     activableObject.Activate();
 }