Пример #1
0
    void Throw()
    {
        if (holdingObject == null || !canThrow)
        {
            return;
        }
        Rigidbody2D leekRigidbody = holdingObject.GetComponent <Rigidbody2D>();

        Vector2 actualThrowDirection = new Vector2((1 - currentThrowCharge / MaxThrowCharge), currentThrowCharge / MaxThrowCharge);

        Vector3 throwVelocity = actualThrowDirection.normalized * ThrowForce + ThrowMovementFactor * new Vector2(Mathf.Abs(movement.Velocity.x), movement.Velocity.y);

        throwVelocity.x              *= movement.Direction;
        leekRigidbody.velocity        = throwVelocity;
        leekRigidbody.angularVelocity = Random.Range(140, 180) * currentThrowCharge * movement.Direction;
        leekRigidbody.isKinematic     = false;
        holdingObject.GetComponent <Collider2D>().isTrigger = false;
        LeekComponent leek = holdingObject.GetComponent <LeekComponent>();

        if (leek != null)
        {
            leek.IsActive = true;
            leek.owner    = gameObject;
        }
        holdingObject = null;
        canThrow      = false;
        GameManager.Instance.SoundManager.PlaySound(GameManager.Instance.SoundManager.throwSound);
        currentThrowCharge = InitialThrowCharge;
    }
Пример #2
0
 public void WaterIt()
 {
     currentWater += WaterPerSecond * Time.deltaTime;
     if (leek == null)
     {
         leek = (GameObject.Instantiate(leekPrefab, transform.localPosition + new Vector3(0, 0.2f, 6), Quaternion.identity) as GameObject).GetComponent <LeekComponent>();
     }
     leek.transform.rotation = originalOrientation * Quaternion.AngleAxis(Random.Range(-10f, 10f), Vector3.forward);
     leek.LeekLevel          = (int)(currentWater / WaterPerLevel);
 }
Пример #3
0
    public GameObject HarvestLeek()
    {
        if (leek == null)
        {
            return(null);
        }
        GameObject tmpLeek = leek.gameObject;

        leek         = null;
        currentWater = 0;
        return(tmpLeek);
    }