Beispiel #1
0
    private void Awake()
    {
        spriteRenderer = GetComponent <SpriteRenderer>();
        GameObject player = GameObject.Find("Player");

        playerTransform            = player.transform;
        playerAimController        = player.GetComponent <PlayerAimController>();
        playerPlatformerController = player.GetComponent <PlayerPlatformerController>();
        rb2d        = GetComponent <Rigidbody2D>();
        originPoint = transform.position;
    }
    // Update is called once per frame
    void Update()
    {
        if (!rootObj)
        {
            rootObj = transform.root.gameObject;
            return;
        }

        switch (mSpriteSelType)
        {
        case SelectionType.eSelectionAim:
        {
            PlayerAimController playerAimControl = rootObj.GetComponent <PlayerAimController>();
            if (playerAimControl)
            {
                currentDirection = playerAimControl.GetAimDirection();
            }
            break;
        }

        case SelectionType.eSelectionMove:
        {
            PlayerMoveController playerMove = rootObj.GetComponent <PlayerMoveController>();
            if (playerMove)
            {
                currentDirection = playerMove.GetAimDirection();
            }
            break;
        }
        }
        if (m_directionalSprites.ContainsKey(currentDirection))
        {
            SpriteRenderer spriteRender = GetComponent <SpriteRenderer>();
            if (spriteRender)
            {
                SpriteSelection chosen = m_directionalSprites[currentDirection];
                spriteRender.sprite = chosen.spriteSelection;
            }
        }

        if (bVerboseLogging)
        {
            Debug.Log("Current direction :" + currentDirection.ToString());
        }
    }