private void NewGame(int playersAmount) { if (!IsGameInProgress) { UIManager.Instance.catastropheCard.FillCatastropheCard(Generator.GenerateCatastrophy()); UIManager.Instance.bunkerCard.FillBunkerCard(Generator.GenerateBunker()); for (int i = 0; i < playersAmount; i++) { PlayerShortcard sc = Instantiate(UIManager.Instance.shortcardPrefab, UIManager.Instance.playersContainer); sc.FillShortcard(Generator.GeneratePlayerCard(), i + 1); shortcards.Add(sc); } IsGameInProgress = true; } }
private IEnumerator TakeHiddenSSAndShare(PlayerShortcard sc) { UIManager.Instance.OpenPlayerShortcard(sc); yield return(new WaitForEndOfFrame()); Texture2D ss = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false); ss.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0); ss.Apply(); string filePath = Path.Combine(Application.temporaryCachePath, "sharedImg.png"); File.WriteAllBytes(filePath, ss.EncodeToPNG()); // to avoid memory loss Destroy(ss); new NativeShare().AddFile(filePath).SetSubject("").SetText("").Share(); UIManager.Instance.ClosePlayerShortcard(); }
public void OpenPlayerShortcard(PlayerShortcard s) { playerCardPanel.Show(TransitionType.Fade); closeShortcardButton.gameObject.SetActive(true); playerCard.FillPlayerCard(s.GetShortcardInfo()); }
public void ClickHiddenShortcardShare(PlayerShortcard sc) { StartCoroutine(TakeHiddenSSAndShare(sc)); }