/*
  * public override void FadeOut()
  * {
  *  GameController.Instance.SetTargetCameraSettings(GameController.CameraStatusE.Center);
  *  GameController.Instance.PlayerCharacter.transform.position = PlayerPosition.transform.position;
  *  GameController.Instance.PlayerCharacter.transform.SetParent(PlayerPosition.transform, true);
  *  GameController.Instance.PlayerCharacter.SetAnimationBool("IsIdle", false);
  *  AnimatorRef.SetTrigger("FadeOut");
  * }
  */
 public override void StartAnimation()
 {
     AnimatorRef.SetBool("IsStart", true);
     SoundManager.Instance.PlayMusicClip(Music, true);
     Cinemachine.CinemachineBrain brain = Camera.main.gameObject.GetComponent <Cinemachine.CinemachineBrain>();
     brain.m_UpdateMethod      = Cinemachine.CinemachineBrain.UpdateMethod.LateUpdate;
     brain.m_BlendUpdateMethod = Cinemachine.CinemachineBrain.BrainUpdateMethod.LateUpdate;
 }
示例#2
0
    private void Update()
    {
        if (!NetworkingPause.IsPaused)
        {
            //Pega posição do mouse para andar
            Vector2 mouseWorldPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

            //clicked something?
            Collider2D   clickedCollider = Physics2D.OverlapCircle(mouseWorldPos, inputOverlapRadius, overlapLayerMask);
            Interactable interactableObj = null;
            Obstacle     obstacleObj     = null;

            if (clickedCollider != null)
            {
                float deltaY = clickedCollider.transform.position.y - transform.position.y;
                //only objects within reach
                if (deltaY >= minReachHeight && deltaY <= maxReachHeight)
                {
                    //Objeto interativo
                    if (clickedCollider.gameObject.CompareTag("Interactables"))
                    {
                        interactableObj = clickedCollider.GetComponent <Interactable>();
                    }
                    //Obstáculos
                    else if (clickedCollider.gameObject.CompareTag("Obstacles"))
                    {
                        obstacleObj = clickedCollider.GetComponent <Obstacle>();
                    }
                }
            }
            Interactable.hovered = interactableObj;

            //interact with the objects
            if (Input.GetMouseButtonDown(0) && !UIRegion.ContainsMousePos(uiRegionTypeToIgnoreInput))
            {
                //walk to that position
                xTargetPos         = mouseWorldPos.x;
                hasTarget          = true;
                targetInteractable = interactableObj;
                //Se tem o item necessário para destruir aquele obstáculo
                if (obstacleObj != null && inventory.GetItem(obstacleObj.id.ToString()))
                {
                    obstacleObj.DestroyObstacle();
                }
            }

            if (isLookingRight && ShouldStartLookingLeft)
            {
                isLookingRight = false;
            }
            else if (!isLookingRight && ShouldStartLookingRight)
            {
                isLookingRight = true;
            }

            if (gameObject != null)
            {
                AnimatorRef?.SetBool(walkAnimParameterName, IsWalking);
                SpriteRendererRef.flipX = isLookingRight;
            }
        }
    }