Пример #1
0
 public void LoadArrow()
 {
     if (loadedArrow == null)
     {
         loadedArrow = Instantiate(prefabArrow, this.transform);
         ArrowMain arrowMain = loadedArrow.GetComponent <ArrowMain>();
         arrowMain.currentState = ArrowMain.ArrowState.LoadedToBow;
         Rigidbody rigidbody = loadedArrow.GetComponent <Rigidbody>();
         rigidbody.constraints = RigidbodyConstraints.FreezeAll;
         BowEvents.RaiseBowEvent(BowEvents.BowEventType.LoadArrow);
     }
 }
Пример #2
0
    public void ShootArrow()
    {
        if (!(BowPullStrength > MinimumStrengthToShootArrow))   //prevent shooting if shooting strength is below minimum or no arrow is loaded.
        {
            return;
        }
        if (loadedArrow == null)
        {
            return;
        }

        loadedArrow.transform.parent = null;
        Rigidbody rigidbody = loadedArrow.GetComponent <Rigidbody>();

        rigidbody.constraints = RigidbodyConstraints.None;
        rigidbody.AddForce(transform.forward * ShootForce * BowPullStrength, ForceMode.Impulse);
        ArrowMain arrowMain = loadedArrow.GetComponent <ArrowMain>();

        arrowMain.currentState = ArrowMain.ArrowState.ShootArrow;
        arrowMain.variableTransform.enabled = false;
        BowPullStrength = 0;
        loadedArrow     = null;
        BowEvents.RaiseBowEvent(BowEvents.BowEventType.ShootArrow);
    }