Example #1
0
    // Use this for initialization
    void Start()
    {
        //haetaan kaikki tarvittavat komponentit
        rb                              = GetComponent <Rigidbody>();
        healthSystem                    = GetComponent <HealthSystem>();
        healthSystem.dieHandler         = OnDie;
        keeper                          = GetComponent <PathKeeper>();
        cameraTarget                    = GameObject.Find("CameraTarget");
        movement                        = GetComponent <GroundMovement>();
        movement.OnHitGround            = OnHitGround;
        anim                            = transform.Find("PlayerModel").GetComponent <Animator>();
        damageBlinker                   = GetComponent <MaterialBlinker>();
        footStepHandler                 = transform.Find("PlayerModel").GetComponent <FootstepHandler>();
        footStepHandler.FootStepHandler = Footstep;

        //animaatiot
        anim.SetFloat("RunBlend", 0f);
        animBaseLayer    = anim.GetLayerIndex("BaseLayer");
        animFallLayer    = anim.GetLayerIndex("FallLayer");
        animHurtLayer    = anim.GetLayerIndex("HurtLayer");
        animJumpLayer    = anim.GetLayerIndex("JumpLayer");
        animLandingLayer = anim.GetLayerIndex("LandingLayer");

        anim.GetBehaviour <AttackLayerScript>().OnSlashEndHandler = OnSlashEnd;
        swordHitbox.SetActive(false);

        //lataa pelaajan tilanne tallennuksesta
        GameData.Player playerData = GameDataManager.Instance.GameData.player;
        if (playerData.firstCheckPointReached)
        {
            //paikka, suunta ja polku
            transform.position   = playerData.position.toVector3();
            transform.rotation   = playerData.rotation.toQuaternion();
            keeper.currentSpline = GameObject.Find(playerData.pathName).GetComponent <BezierSpline>();
            //health
            healthSystem.currentHealth = playerData.currentHealth;
            healthSystem.maxHealth     = playerData.maxHealth;
        }

        //siirrä kamera pelaajan paikalle
        cmDefaultCamera = GameObject.FindGameObjectWithTag("CMDefaultCamera");
        mainCamera      = GameObject.FindGameObjectWithTag("MainCamera");
        if (cmDefaultCamera != null)
        {
            cmDefaultCamera.SetActive(false);
            mainCamera.SetActive(false);
            cmDefaultCamera.transform.position = transform.position;
            mainCamera.transform.position      = transform.position;
            StartCoroutine(ActivateCameras());
        }
    }
    // Use this for initialization
    protected override void Start()
    {
        base.Start();
        keeper           = GetComponent <PathKeeper>();
        target           = GameObject.Find("Player");
        targetDamageable = target.GetComponent <IDamageable>();
        targetKeeper     = target.GetComponent <PathKeeper>();
        rb                      = GetComponent <Rigidbody>();
        movement                = GetComponent <GroundMovement>();
        healthSystem            = GetComponent <HealthSystem>();
        healthSystem.dieHandler = OnDie;
        damageBlinker           = GetComponent <MaterialBlinker>();

        anim = GetComponentInChildren <Animator>();
        anim.SetFloat("RunBlend", 0f);
    }