Example #1
0
 private void SpawnCoin()
 {
     StartThrownigPosition.x = _minScreenPosition.x + _widthOfScreen * Random.Range(0f, 1f);
     _throwedObject          = Instantiate(Coin, StartThrownigPosition, Quaternion.identity);
     //NumberOfObject++;
     _throwedObjectScript = _throwedObject.GetComponent <ThrowingObject>();
     _throwedObjectScript.SetCounter(_counter);
     _throwedObjectScript.SetForce(Random.Range(3000f, 3501f));
     _throwedObjectScript.TrowObjectUp();
 }
Example #2
0
 private void SpawnObject()
 {
     StartThrownigPosition.x = _minScreenPosition.x + _widthOfScreen * _currentLvlPreset.TrowingObjects[_numberOfObject].PositionOfThrowing;
     _throwedObject          = Instantiate(FallingObjects[Random.Range(0, FallingObjects.Length)], StartThrownigPosition, Quaternion.identity);
     _numberOfObject++;
     _throwedObjectScript = _throwedObject.GetComponent <ThrowingObject>();
     _throwedObjectScript.SetCounter(_counter);
     _throwedObjectScript.SetForce(_currentLvlPreset.TrowingObjects[_numberOfObject - 1].ForceOfThrowing);
     _throwedObjectScript.TrowObjectUp();
 }
    IEnumerator ThrowingObject(GameObject ObjectFlinging, GameObject MovingTo)
    {
        ThrowingObject ThrowScript = ObjectFlinging.GetComponent <ThrowingObject>();

        while (ObjectFlinging != null)
        {
            //Debug.Log(ThrowScript.TriggerCheck.name);

            if (ThrowScript.TriggerCheck != null && ThrowScript.TriggerCheck == MovingTo)
            {
                Destroy(ObjectFlinging.gameObject);
                Destroy(MovingTo.gameObject);
            }
            ObjectFlinging.transform.position = Vector3.Lerp(ObjectFlinging.transform.position, MovingTo.transform.position, .05f);
            yield return(new WaitForFixedUpdate());
        }
    }