Global Game Jam 2021
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.0 KiB

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.InputSystem;
  5. public class PlayerJoinIcon : MonoBehaviour
  6. {
  7. private PlayerData m_data;
  8. private Vector3 m_startingScale;
  9. private void OnEnable()
  10. {
  11. m_startingScale = transform.localScale;
  12. Debug.Log("New player awake");
  13. if (m_data != null)
  14. {
  15. m_data.Input.currentActionMap.FindAction("Ping").started += OnPlayerPing;
  16. m_data.Input.currentActionMap.FindAction("Ping").canceled += OnPlayerPing;
  17. }
  18. }
  19. public void Initialise(PlayerData data)
  20. {
  21. Debug.Log("Initialised new Player");
  22. m_data = data;
  23. }
  24. public void OnPlayerPing(InputAction.CallbackContext args)
  25. {
  26. Debug.Log($"Ping: {args.phase}");
  27. if (args.phase == InputActionPhase.Started)
  28. transform.localScale = m_startingScale * 1.1f;
  29. else if (args.phase == InputActionPhase.Canceled)
  30. transform.localScale = m_startingScale;
  31. }
  32. }