Esempio n. 1
0
 public void ApplyPlayersForce(ScreenSegment segment)
 {
     foreach (GameObject gameObject in spawnedObjects[segment])
     {
         gameObject.GetComponent <Rigidbody>().AddForce(new Vector3(0, 0, 14));
     }
 }
Esempio n. 2
0
    private void FixedUpdate()
    {
        fixedUpdateModuloCounter = (fixedUpdateModuloCounter + 1) % 50;
        if (fixedUpdateModuloCounter == 0)
        {
            ImportedItem  item    = PickItem();
            ScreenSegment segment = PickScreenSegment();

            ThrowItem(item, segment);
        }
    }
Esempio n. 3
0
    private void Start()
    {
        // VRTK input here
        var interact = GetComponent <VRTK_InteractableObject>();

        interact.InteractableObjectTouched   += OnTouch;
        interact.InteractableObjectUntouched += OnUnTouch;
        interact.InteractableObjectUsed      += OnUse;

        Segment = GetComponentInChildren <ScreenSegment>();
    }
Esempio n. 4
0
    public void Land(GameObject gameObject)
    {
        ScreenSegment segment = inverseDictionary[gameObject];

        if (segment == ScreenSegment.TOP_LEFT)
        {
            inverseDictionary[gameObject] = ScreenSegment.BOTTOM_LEFT;
            spawnedObjects[ScreenSegment.BOTTOM_LEFT].Add(gameObject);
            spawnedObjects[ScreenSegment.TOP_LEFT].Remove(gameObject);
        }
        else if (segment == ScreenSegment.TOP_RIGHT)
        {
            inverseDictionary[gameObject] = ScreenSegment.BOTTOM_RIGHT;
            spawnedObjects[ScreenSegment.BOTTOM_RIGHT].Add(gameObject);
            spawnedObjects[ScreenSegment.TOP_RIGHT].Remove(gameObject);
        }
    }
Esempio n. 5
0
    private void ThrowItem(ImportedItem item, ScreenSegment segment)
    {
        GameObject spawnedObject = Instantiate(item.gameObject, spawnPoint, transform.rotation);

        broker.Register(segment, spawnedObject);

        ItemProperties properties = item.itemProperties;

        Rigidbody rigidBody = spawnedObject.GetComponent <Rigidbody>();

        rigidBody.mass = properties.mass;

        Vector3 side;
        Vector3 up;
        Vector3 towards;

        switch (segment)
        {
        case ScreenSegment.TOP_LEFT:
            side    = properties.forceSide * Vector3.left;
            up      = properties.forceUpHigh * Vector3.up;
            towards = properties.forceBack * Vector3.back;
            break;

        case ScreenSegment.BOTTOM_LEFT:
            side    = properties.forceSide * Vector3.left;
            up      = properties.forceUpLow * Vector3.up;
            towards = properties.forceBack * Vector3.back;
            break;

        case ScreenSegment.TOP_RIGHT:
            side    = properties.forceSide * Vector3.right;
            up      = properties.forceUpHigh * Vector3.up;
            towards = properties.forceBack * Vector3.back;
            break;

        default:
            side    = properties.forceSide * Vector3.right;
            up      = properties.forceUpLow * Vector3.up;
            towards = properties.forceBack * Vector3.back;
            break;
        }

        rigidBody.AddForce(side + up + towards);
    }
Esempio n. 6
0
 public void Register(ScreenSegment segment, GameObject gameObject)
 {
     spawnedObjects[segment].Add(gameObject);
     inverseDictionary[gameObject] = segment;
 }