Beispiel #1
0
    private void Awake()
    {
        Application.targetFrameRate = FPS;

        Mask.SetActive(false);
        oriSize = StartSize;
        loadSetting();
        hat = gameObject.GetComponent <HashsAndTags>();

        if (gameManager.instance == null)
        {
            Screen.SetResolution(width * setting.windowSize, height * setting.windowSize, false);
            //创造管理器实例
            gameManager.instance = this;
            DontDestroyOnLoad(gameManager.instance.gameObject);
        }
        else if (gameManager.instance != this)
        {
            Destroy(this.gameObject);
        }
    }
Beispiel #2
0
    void Awake()
    {
        rushTimer     = rushTime;
        hat           = gameManager.instance.hat;
        _rigidbody    = gameObject.GetComponent <Rigidbody2D>();
        anima         = gameObject.GetComponent <Animator>();
        render        = gameObject.GetComponent <SpriteRenderer>();
        _audio        = gameObject.GetComponent <AudioSource>();
        _audio.volume = gameManager.instance.setting.SEValue;

        if (!useIdleAnima)
        {
            anima.enabled = false;
            if (turn.y > moveEpsilon)
            {
                render.sprite = idle[1];
            }
            else if (turn.y < -moveEpsilon)
            {
                render.sprite = idle[2];
            }
            else
            {
                if (turn.x > moveEpsilon)
                {
                    render.flipX = left;
                }
                else if (turn.x < -moveEpsilon)
                {
                    render.flipX = !left;
                }
                render.sprite = idle[0];
            }
        }
        else
        {
            playSE(step, true);
            anima.enabled = true;
            if (turn.y > moveEpsilon)
            {
                anima.SetFloat(hat.idleAnima, 1);
            }
            else if (turn.y < -moveEpsilon)
            {
                anima.SetFloat(hat.idleAnima, 2);
            }
            else
            {
                if (turn.x > moveEpsilon)
                {
                    render.flipX = left;
                }
                else if (turn.x < -moveEpsilon)
                {
                    render.flipX = !left;
                }
                anima.SetFloat(hat.idleAnima, 0);
            }
        }
        transform.position = new Vector3(transform.position.x, transform.position.y, transform.position.y);
        rayMask            = (1 << LayerMask.NameToLayer("collider")) | (1 << LayerMask.NameToLayer("npc"));

        init();
    }