// Make generic so different types of button interactions can be used, not just Maze Entry public void CreateMapInteractionButton(OverworldPlayerCharacter player, Vector2 pos, string mapText) { Logger.Log($"Create map interaction for player {player.PlayerNumber}"); GameObject mapInteractionButtonGO = GameObject.Instantiate(MapInteractionButtonPrefab, transform); MapInteractionButton mapInteractionButton = mapInteractionButtonGO.GetComponent <MapInteractionButton>(); mapInteractionButton.ShowMapInteractionButton(player, pos, mapText); MapInteractionButtons.Add(mapInteractionButton); player.MapInteractionButtonsForPlayer.Add(mapInteractionButton); }
public void DestroyMapMapInteractionButton(OverworldPlayerCharacter player) { Logger.Log($"Destroy map interaction label for player {player.PlayerNumber}"); for (int i = 0; i < MapInteractionButtons.Count; i++) { if (MapInteractionButtons[i].TriggerPlayer.PlayerNumber == player.PlayerNumber) { MapInteractionButton mapInteractionButton = MapInteractionButtons[i]; player.MapInteractionButtonsForPlayer.Remove(MapInteractionButtons[i]); MapInteractionButtons.Remove(MapInteractionButtons[i]); mapInteractionButton.DestroyMapInteractionButton(); break; } } }
public void ShowMapInteractionButton(OverworldPlayerCharacter player, Vector2 pos, string mapText) { _buttonWorldBasePosition = pos; TriggerPlayer = player; if (GameRules.GamePlayerType == GamePlayerType.SplitScreenMultiplayer && player.PlayerNumber == PlayerNumber.Player2) { _cameraToUse = CameraManager.Instance.CameraControllers[1].GetCamera(); } else { _cameraToUse = CameraManager.Instance.CameraControllers[0].GetCamera(); } Vector2 positionAdjustedForScreenPoint = _cameraToUse.WorldToScreenPoint(new Vector2(_buttonWorldBasePosition.x + 0.5f, _buttonWorldBasePosition.y + 1)); SetMapInteractionButtonLabel(mapText); transform.position = new Vector2(positionAdjustedForScreenPoint.x, positionAdjustedForScreenPoint.y); gameObject.SetActive(true); }
void Start() { mPlayerCharacter = transform.Find("Player").GetComponent <OverworldPlayerCharacter>(); OverworldInput.OnTap += HandleOnTap; OverworldInput.OnSwipe += HandleOnSwipe; }