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.

47 lines
1.1 KiB

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