Ejemplo n.º 1
0
    public void Show(UnitDialodEntity dialogData, Action clickCallback)
    {
        //set click callback
        _btnOverlay.onClick.AddListener(() => { clickCallback(); });

        //set text position
        Vector2 textPosition = _textRootTransform.anchoredPosition;

        textPosition.x = dialogData.Speaker == EFightDialogSpeaker.PlayerHero ? Mathf.Abs(textPosition.x) : -Mathf.Abs(textPosition.x);
        _textRootTransform.anchoredPosition = textPosition;

        //target camera to speaker
        if (dialogData.Speaker == EFightDialogSpeaker.PlayerHero)
        {
            _characterCamera.transform.position = FightManager.SceneInstance.AllyHero.transform.position + dialogData.CameraOffset;
            FightManager.SceneInstance.AllyHero.ModelView.PlaySpeakAnimation();
        }
        else if (dialogData.Speaker == EFightDialogSpeaker.EnemyUnit && dialogData.UnitKey != EUnitKey.Idle)
        {
            for (int i = 0; i < FightManager.SceneInstance.EnemyUnits.Length; i++)
            {
                if (FightManager.SceneInstance.EnemyUnits[i].UnitData.Data.Key == dialogData.UnitKey)
                {
                    _characterCamera.transform.position = FightManager.SceneInstance.EnemyUnits[i].transform.position + dialogData.CameraOffset;
                }
            }
        }

        //position self
        float screenWidthOffset = 0f;

        switch (dialogData.Speaker)
        {
        case EFightDialogSpeaker.PlayerHero:
            screenWidthOffset = 0.2f;
            break;

        case EFightDialogSpeaker.EnemyUnit:
            screenWidthOffset = 0.85f;
            break;
        }

        Vector3 worldPos = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width * screenWidthOffset, Screen.height * 0.5f, Camera.main.nearClipPlane));

        worldPos.z += 1f;

        transform.position      = worldPos;
        transform.localRotation = Quaternion.Euler(GameConstants.CAMERA_ROTATION);

        _lblText.text = dialogData.Text;
        gameObject.SetActive(true);
        _characterCamera.gameObject.SetActive(true);
        _canvasOverlay.enabled = true;
    }
Ejemplo n.º 2
0
	public void Show(UnitDialodEntity dialogData, Action clickCallback) {
		//set click callback
		_btnOverlay.onClick.AddListener(() => { clickCallback(); });

		//set text position
		Vector2 textPosition = _textRootTransform.anchoredPosition;
		textPosition.x = dialogData.Speaker == EFightDialogSpeaker.PlayerHero ? Mathf.Abs(textPosition.x) : -Mathf.Abs(textPosition.x);
		_textRootTransform.anchoredPosition = textPosition;

		//target camera to speaker
		if (dialogData.Speaker == EFightDialogSpeaker.PlayerHero) {
			_characterCamera.transform.position = FightManager.SceneInstance.AllyHero.transform.position + dialogData.CameraOffset;
			FightManager.SceneInstance.AllyHero.ModelView.PlaySpeakAnimation();
		} else if(dialogData.Speaker == EFightDialogSpeaker.EnemyUnit && dialogData.UnitKey != EUnitKey.Idle) {
			for (int i = 0; i < FightManager.SceneInstance.EnemyUnits.Length; i++) {
				if (FightManager.SceneInstance.EnemyUnits[i].UnitData.Data.Key == dialogData.UnitKey) {
					_characterCamera.transform.position = FightManager.SceneInstance.EnemyUnits[i].transform.position + dialogData.CameraOffset;
				}
			}
		}

		//position self
		float screenWidthOffset = 0f;
		switch (dialogData.Speaker) {
			case EFightDialogSpeaker.PlayerHero:
				screenWidthOffset = 0.2f;
				break;
			case EFightDialogSpeaker.EnemyUnit:
				screenWidthOffset = 0.85f;
				break;
		}

		Vector3 worldPos = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width * screenWidthOffset, Screen.height * 0.5f, Camera.main.nearClipPlane));
		worldPos.z += 1f;

		transform.position = worldPos;
		transform.localRotation = Quaternion.Euler(GameConstants.CAMERA_ROTATION);

		_lblText.text = dialogData.Text;
		gameObject.SetActive(true);
		_characterCamera.gameObject.SetActive(true);
		_canvasOverlay.enabled = true;
	}