예제 #1
0
 void OnAttachKnife(object sender, object args)
 {
     knifeController    = (KnifeController)args;
     knifeObject        = knifeController.gameObject;
     safeWarpCollider   = knifeObject.GetComponentInChildren <SafeWarpCollider>();
     colliding          = false;
     transform.position = knifeObject.transform.position;
     transform.rotation = GlobalGravityControl.GetGravityRotation();
     lastUsablePos      = knifeObject.transform.position;
     Enabled(true);
 }
예제 #2
0
    /*
     * Throw knife at given strength
     */
    void ThrowKnife(float _strength, bool _secondary = false)
    {
        if (currentWarps < 1)
        {
            return;
        }

        // TODO: replace with consistent knife instances. one for each type
        // instantiate knife prefab
        knife           = Instantiate((_secondary) ? secondaryKnifePrefab : primaryKnifePrefab, transform.position, GlobalGravityControl.GetGravityRotation());
        knifeController = knife.GetComponent <KnifeController>();

        // check that we have actually got a knife
        if (knifeController == null)
        {
            Debug.LogError("No KnifeController found on knife prefab");
            return;
        }

        // set up and throw knife object
        knifeController.Setup(knifeInHand.transform, warpLookAheadCollider);
        knifeController.Throw(transform.forward * _strength);

        // hide knife view object
        HideKnife(true);
    }
예제 #3
0
 void OnGravityChangeNotification(object sender, object args)
 {
     currentGravVector   = GlobalGravityControl.GetCurrentGravityVector();
     currentGravRotation = GlobalGravityControl.GetGravityRotation();
 }