コード例 #1
0
 void Start()
 {
     Anime  = GetComponent <Animator_Controller>();
     t      = GetComponent <Timer>();
     Magic1 = false;
     Magic2 = false;
     Magic3 = false;
 }
コード例 #2
0
 private void SetRefrences()
 {
     characterStats   = this.GetComponentInParent <Character_Stats>();
     anim             = this.GetComponent <Animator>();
     equipmentManager = this.GetComponentInParent <Equipment_Manager>();
     equipmentManager.equipBodyArmour       += SetCurrentArmour;
     equipmentManager.restartAnimationEvent += RestartAnimation;
     equipmentManager.equipWeapon           += SetCurrentWeapon;
     //characterStats.amWalking += SetWalking;
     animCon = this.GetComponentInParent <Animator_Controller>();
     animCon.callingAttack += Attack;
 }
コード例 #3
0
    void Start()
    {
        PlayerRigidbody = PlayerUnit.GetComponent <Rigidbody>();
        Anime           = GetComponent <Animator_Controller>();

        PlayerRigidbody.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;

        //Cursor.visible = false;//隱藏滑鼠
        //Cursor.lockState = CursorLockMode.Locked;
        walk     = false;
        run      = false;
        backward = false;
        rwalk    = false;
        lwalk    = false;
        jump     = false;
        fly      = false;
    }
コード例 #4
0
using UnityEngine;
using System.Collections;

public class Animator_Controller : MonoBehaviour
{
    // Public variables
    public static Animator_Controller instance;

    // Private variables
    Transform myTrans;
    Animator myAnim;
    Vector3 artScaleCache;

    // Use this for initialization
    void Start()
    {
        myTrans = this.transform;
        myAnim = this.gameObject.GetComponent<Animator>();
        instance = this;

        artScaleCache = myTrans.localScale;
    }

    void FilpArt(float currentSpeed)
    {
        if((currentSpeed < 0 && artScaleCache.x > 0) ||     // Going left and facing right
           (currentSpeed > 0 && artScaleCache.x < 0))       // Going right and facing left
        {
            // Flip the art
            artScaleCache.x *= -1;
            myTrans.localScale = artScaleCache;
        }
    }

    // Update is called once per frame
    public void UpdateSpeed(float currentSpeed)
    {
        myAnim.SetFloat("speed", currentSpeed);
        FilpArt(currentSpeed);
    }

    public void UpdateIsGrounded(bool isGrounded)
    {
        myAnim.SetBool("isGrounded", isGrounded);
    }
}