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

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.UI;
public class PlayerJoinIcon : MonoBehaviour
{
[SerializeField]
private Image m_apron;
private PlayerData m_data;
private Vector3 m_startingScale;
private void OnEnable()
{
m_startingScale = transform.localScale;
Debug.Log("New player awake");
if (m_data != null)
{
m_data.Input.currentActionMap.FindAction("Ping").started += OnPlayerPing;
m_data.Input.currentActionMap.FindAction("Ping").canceled += OnPlayerPing;
}
}
public void Initialise(PlayerData data)
{
Debug.Log("Initialised new Player");
m_data = data;
m_apron.color = data.Color;
}
public void OnPlayerPing(InputAction.CallbackContext args)
{
Debug.Log($"Ping: {args.phase}");
if (args.phase == InputActionPhase.Started)
transform.localScale = m_startingScale * 1.1f;
else if (args.phase == InputActionPhase.Canceled)
transform.localScale = m_startingScale;
}
}