//=================================================================================================================o
    void Start()
    {
        hero = transform;
        hClimb = GetComponent <HeroClimb> () as HeroClimb;
        hKey = GetComponent <HeroKeymap> () as HeroKeymap;

        Vector3 angls = cam.eulerAngles;
        xAngl = angls.x;
        yAngl = angls.y;

        curDist = heroDistance;
        desDist = heroDistance;
        finalDist = heroDistance;

        hClimb.doClimbDel += DoClimb;

        cam.camera.nearClipPlane = 0.01f;

        //Screen.lockCursor = true;
        Screen.showCursor = false;

        // if no headbone search for it
        if (headBone == null) {
            Transform[] bones = GetComponentsInChildren <Transform>() as Transform[];
            foreach (Transform t in bones) {
                if (t.name == "head")
                    headBone = t;
            }
        }
    }
示例#2
0
    //=================================================================================================================o
    void Start()
    {
        hero = transform;
        //a = GetComponent <Animation>() as Animation;
        if (a.clip) {
            aC = a.clip;
        } else aC = a["idle"].clip;
        impactM = a["land"].clip;

        hMotor = GetComponent <HeroMotor>() as HeroMotor;
        hClimb = GetComponent <HeroClimb>() as HeroClimb;
        hPhys = GetComponent <HeroPhysic>() as HeroPhysic;
        hSwim = GetComponent <HeroSwim>() as HeroSwim;
        hKey = GetComponent <HeroKeymap>() as HeroKeymap;

        // Pass Delegates
        hMotor.doJumpDel += DoJump;
        hMotor.doBalanceDel += DoBalance;
        hMotor.doCombatDel += DoCombat;
        hMotor.doSwitchWeapDel += DoSwitchWeapons;
        hMotor.doEvadeDel += DoEvade;
        hMotor.doSneakDel += DoSneak;
        hClimb.doClimbDel += DoClimb;
        hSwim.doSwimDel += DoSwim;
        hPhys.doPhysDel += DoPhysx;

        currRot = 0.0f;
        leanRot = 0.0f;
        //sprintRot = 0.0f;
        lastRootForward = hero.forward;

        // Start is in Weaponstate.None, weaponless

        // Sword
        if (sword_Hand == null) // If no weapon is assigned
        {
            sword_Hand = new GameObject("emptyObj");
            sword_Hand.active = false;
        }
        else
            sword_Hand.active = false;
        if (sword_Holster == null) // If no weapon is assigned
        {
            sword_Holster = new GameObject("emptyObj");
            sword_Holster.active = false;
        }
        else
            sword_Holster.active = false;

        // Bow
        if (bow_Hand == null) // If no weapon is assigned
        {
            bow_Hand = new GameObject("emptyObj");
            bow_Hand.active = false;
        }
        else
            bow_Hand.active = false;
        if (bow_Holster == null) // If no weapon is assigned
        {
            bow_Holster = new GameObject("emptyObj");
            bow_Holster.active = false;
        }
        else
            bow_Holster.active = false;

        // Quiver
        if (bow_Quiver == null) // If no weapon is assigned
        {
            bow_Quiver = new GameObject("emptyObj");
            bow_Quiver.active = false;
        }
        else
            bow_Quiver.active = false;

        // Rifle
        if (rifle_Hand == null) // If no weapon is assigned
        {
            rifle_Hand = new GameObject("emptyObj");
            rifle_Hand.active = false;
        }
        else
            rifle_Hand.active = false;
        if (rifle_Holster == null)// If no weapon is assigned
        {
            rifle_Holster = new GameObject("emptyObj");
            rifle_Holster.active = false;
        }
        else
            rifle_Holster.active = false;

        // Pistol
        if (pistol_Hand == null)// If no weapon is assigned
        {
            pistol_Hand = new GameObject("emptyObj");
            pistol_Hand.active = false;
        }
        else
            pistol_Hand.active = false;
        if (pistol_Holster == null)// If no weapon is assigned
        {
            pistol_Holster = new GameObject("emptyObj");
            pistol_Holster.active = false;
        }
        else
            pistol_Holster.active = false;

        // Look for setup
        DoSwitchWeapons ();

        actionState = ActionState.None;
        evadeState = EvadeState.None;
        climbState = ClimbState.None;
    }
 //=================================================================================================================o
 void Start()
 {
     hero = transform;
     rb = rigidbody;
     climbState = ClimbState.None;
     Physics.IgnoreLayerCollision(8,9); // ignore player / climb collision
     hMove = GetComponent <HeroMotor> () as HeroMotor;
     hSwim = GetComponent <HeroSwim> () as HeroSwim;
     hKey = GetComponent <HeroKeymap> () as HeroKeymap;
     cacheDist = checkDistance;
 }
    //=================================================================================================================o
    void Start()
    {
        origField = Camera.main.fieldOfView;

        rb = rigidbody;
        hero = transform;
        rb.freezeRotation = true;

        hClimb = GetComponent <HeroClimb> () as HeroClimb;
        hAnim = GetComponent <HeroAnim> () as HeroAnim;
        hPhys = GetComponent <HeroPhysic> () as HeroPhysic;
        hKey = GetComponent <HeroKeymap> () as HeroKeymap;

        hAnim.doSpeedDel += DoSetSpeed;
        hAnim.doSwitchDel += DoSwitch;
        hPhys.doPhysDel += DoReset;
        hClimb.doClimbDel += DoReset;
    }
    //=================================================================================================================o
    void Start()
    {
        hero = transform;
        rb = rigidbody;
        hMotion = GetComponent <HeroAnim> () as HeroAnim;
        hMove = GetComponent <HeroMotor> () as HeroMotor;
        hClimb = GetComponent <HeroClimb> () as HeroClimb;
        hKey = GetComponent <HeroKeymap> () as HeroKeymap;

        bones = GetComponentsInChildren <Transform> () as Transform[];

        foreach (Transform t in bones)
        {
            if (t.name != hero.name && t.collider && t.rigidbody)
            {
                t.collider.isTrigger = true;
                t.rigidbody.isKinematic = true;

                if (t.name == "root")
                    rootBone = t;
            }
        }
    }