示例#1
0
    private void Awake()
    {
        weapon = FindObjectOfType <PlayerWeapon>();

        if (instance == null || instance == this)
        {
            DontDestroyOnLoad(this.gameObject);
            instance = this;
        }
        else
        {
            Destroy(this.gameObject);
        }

        if (instance != null)
        {
            Debug.Log(instance);
            Debug.Log(instance.gameObject);

            Debug.Log("Instances same: " + (instance == this));
        }
        else
        {
            Debug.Log("instance = null");
        }

        /*  if (instance == null)
         *  {
         *      DontDestroyOnLoad(this.gameObject);
         *      instance = this;
         *  } else {
         *      Destroy(this.gameObject);
         *  }
         */

        controller   = GetComponent <Controller2D>();
        animator     = GetComponent <Animator>();
        collider     = GetComponent <BoxCollider2D>();
        gravity      = -(2 * jumpHeight) / Mathf.Pow(timeToJumpApex, 2);
        jumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;

        inputScale = gameObject.AddComponent <FloatTimer>().Constructor(1f);
        accelerationTimeAirborne = gameObject.AddComponent <FloatTimer>().Constructor(baseAccelerationTimeAirborne);
        accelerationTimeGrounded = gameObject.AddComponent <FloatTimer>().Constructor(baseAccelerationTimeGrounded);
        dashOnCooldown           = gameObject.AddComponent <BoolTimer>().Constructor(false);
    }
示例#2
0
 public void addValue(float value)
 {
     _timer = new FloatTimer(_timer.getValue(), _timer.getValue() + value, _animationTime);
 }
示例#3
0
 public void setValue(float value)
 {
     _numberMesh.SetText(value.ToString());
     _timer = new FloatTimer(value, value, _animationTime);
 }