Exemple #1
0
    /*
     * Could change ui to single bar?
     * Gravity Rush style
     * midair momentum halt uses bar?
     * warp uses percentage of bar?
     */

    void Start()
    {
        // check for missing prefabs
        if (primaryKnifePrefab == null)
        {
            throw new MissingReferenceException("No primaryKnifePrefab object given.");
        }
        if (secondaryKnifePrefab == null)
        {
            throw new MissingReferenceException("No secondaryKnifePrefab object given.");
        }
        if (knifeInHand == null)
        {
            throw new MissingReferenceException("No knifeInHand object given.");
        }

        knifeViewModelRenderer = knifeInHand.GetComponent <Renderer>();

        player = GameObject.FindGameObjectWithTag("Player");
        if (player == null)
        {
            throw new MissingReferenceException("No player object found.");
        }
        playerColliders = player.GetComponentsInChildren <Collider>();
        playerMotor     = player.GetComponent <PlayerMotor>();

        weapon = GetComponent <WeaponController>();
        weapon.Setup(this);

        currentWarps = maxWarps;

        warpLookAheadCollider = GameObject.FindGameObjectWithTag("WarpLookAheadCollider").GetComponent <WarpLookAheadCollider>();
    }
    /*
     * Passes the knifecontroller and parameter spin speed to the knife
     */
    public virtual void Setup(Transform _ownerTransform, WarpLookAheadCollider _lookAhead)
    {
        ownerTransform        = _ownerTransform;
        warpLookAheadCollider = _lookAhead;

        stuckInSurface = false;

        gravShiftVector = Vector3.zero;

        rb = GetComponent <Rigidbody>();
        dontGoThroughThings = GetComponent <DontGoThroughThings>();
        trailRenderer       = GetComponentInChildren <TrailRenderer>();

        // Attach the WarpLookAheadCollider to this knife
        this.PostNotification(AttachLookAheadColliderNotification, this);

        //transform.LookAt(transform.position + _controller.transform.forward, _controller.transform.up); //? <-(why is this question mark here?)
    }