Exemplo n.º 1
0
    void Start()
    {
        Time.timeScale = 1;

        //attach components
        _char = GetComponent <CharacterController>();
        _absoluteTransform = Camera.main.transform;
        _sprite            = transform.Find("Sprite");
        _legs         = _sprite.Find("Legs").GetComponent <LegsScript>();
        _face         = _sprite.Find("Face").GetComponent <FaceScript>();
        _dialogue     = GameObject.FindGameObjectWithTag("Dialogue").GetComponent <DialogueScript>();
        _faceStartPos = _face.transform.localPosition;
        _save         = GetComponent <SavePosition>();

        //set init vars
        _startPosSprite = _sprite.localPosition;

        float savedPos = _save.Load();

        if (savedPos != 0)
        {
            Vector3 newPos = transform.position;
            newPos.x           = savedPos;
            transform.position = newPos;
        }
    }
    void Awake()
    {
        database = GameObject.Find("_DATABASE").GetComponent <Database>();
        rb       = gameObject.GetComponent <Rigidbody2D>();

        controls = new Inputs();

        controls.Player.Vertical.started    += _ => MovingVertical();
        controls.Player.Vertical.canceled   += _ => ExitVertical();
        controls.Player.Horizontal.started  += _ => MovingHorizontal();
        controls.Player.Horizontal.canceled += _ => ExitHorizontal();

        coinEjector = transform.Find("LightHolder").transform.Find("CoinEjector").gameObject;

        LS = GetComponentInChildren <LegsScript>();
    }