67 lines
1.7 KiB
C#
67 lines
1.7 KiB
C#
using Input;
|
|
using Pixelplacement;
|
|
using System.Collections;
|
|
using UnityEngine;
|
|
using UnityEngine.Audio;
|
|
using UnityEngine.Events;
|
|
using static Input.PlayerTouchController;
|
|
using System;
|
|
|
|
|
|
public class TakePhotoState : State
|
|
{
|
|
|
|
public Transform playerTargetObject;
|
|
private GameObject playerCharacter;
|
|
private PlayerTouchController playerTouchController;
|
|
private Vector3 newPlayerPosition;
|
|
|
|
public UnityEvent animFlash;
|
|
public UnityEvent animStart;
|
|
|
|
void OnEnable()
|
|
{
|
|
playerCharacter = GameObject.FindWithTag("Player");
|
|
playerTouchController = playerCharacter.GetComponent<PlayerTouchController>();
|
|
playerTouchController.OnArrivedAtTarget += PlayerHasArrived;
|
|
|
|
newPlayerPosition = new Vector3(playerTargetObject.transform.position.x, playerTargetObject.transform.position.y, playerTargetObject.transform.position.z);
|
|
playerTouchController.InterruptMoveTo();
|
|
playerTouchController.MoveToAndNotify(newPlayerPosition);
|
|
InputManager.Instance.SetInputMode(InputMode.InputDisabled);
|
|
|
|
}
|
|
|
|
// When the player has arrived at the bush do Animator.SetTrigger(Takephoto) and whatevs
|
|
|
|
public void PhotoTaken()
|
|
{
|
|
ChangeState("Hidden");
|
|
InputManager.Instance.SetInputMode(InputMode.Game);
|
|
}
|
|
|
|
void PlayerHasArrived()
|
|
{
|
|
GetComponent<Animator>().SetTrigger("TakePhoto");
|
|
playerTouchController.OnArrivedAtTarget -= PlayerHasArrived;
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
playerTouchController.OnArrivedAtTarget -= PlayerHasArrived;
|
|
|
|
}
|
|
|
|
public void AnimStarted()
|
|
{
|
|
animStart.Invoke();
|
|
}
|
|
|
|
public void Flash()
|
|
{
|
|
animFlash.Invoke();
|
|
}
|
|
|
|
|
|
}
|