I'm trying to get user status through google play services to make a daily rewards system for my game and I'm not getting the value back as true, my game connects to google play but I can not get the user's data. Here is the code snippet below
private string gameId = "3140248";
private bool testMode = true;
public List<Upgrades> upgrades = new List<Upgrades>();
public List<Area> areas = new List<Area>();
public Text Loading;
public GameObject ErrorGoogle;
public PlayerStats PlayerStats;
public void Start()
{
StartCoroutine("Connection");
}
IEnumerator Connection()
{
yield return new WaitForSeconds(2f);
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().Build();
PlayGamesPlatform.DebugLogEnabled = true;
PlayGamesPlatform.InitializeInstance(config);
PlayGamesPlatform.Activate();
PlayerStats = new PlayerStats();
Social.localUser.Authenticate((bool success) =>
{
if (success == false)
{
ErrorGoogle.SetActive(true);
}
else if (PlayerStats.Valid)
{
Database();
}
});
}
Related
I hope you are well, I need help, I am creating a software that starts at the same time as Windows with Selenium, this software opens a web browser in the background, but when the computer starts, I get this error:
But if I open my app again it works. How can I make it runs at the same time as Windows?
//register the application key
private void Start()
{
RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (rkApp.GetValue(Application.ProductName, Application.ExecutablePath.ToString()) != null)
{
rkApp.SetValue(Application.ProductName, Application.ExecutablePath.ToString());
}
}
private Dictionary<string, WebExplorer > _WebExplorer = new Dictionary<string, WebExplorer >()
{
["chrome"] = new ChromeWebExplorer(),
["firefox"] = new FireFoxWebExplorer(),
["edge"] = new MicrosoftEdgeWebExplorer()
};
private DriverManager _Mananger = new DriverManager();
private IWebDriver _Driver;
public WebDriver(string WebExplorer , string Version)
{
Init(WebExplorer , Version);
}
private void Init(string WebExplorer , string Version)
{
_Mananger.SetUpDriver(_WebExplorer [WebExplorer].GetConfig(), Version);
_WebExplorer[WebExplorer].Start().HideCommandPromptWindow = true;
_Driver = Navegadores[WebExplorer].GetDriver();
}
//A web explorer class
internal class MicrosoftEdgeWebExplorer: WebExplorer
{
public MicrosoftEdgeWebExplorer()
{
_Options= new EdgeOptions();
}
public override IDriverConfig GetConfig()
{
return new EdgeConfig();
}
public override IWebDriver GetDriver()
{
var Options = _Options as EdgeOptions;
Opciones.AddArguments(_Arguments);
return new EdgeDriver(_Service as EdgeDriverService,Options);
}
public override DriverService StartService()
{
_Service= EdgeDriverService.CreateDefaultService();
return _Service;
}
}
added a leaderboard to the Google Play Service. Resources are added, authorization is working, adding a record is working. But when use ShowLeaderboardUI() only shows the name of the highscore table, but there are no highscores. Help pls ;(
CODE Ads Init:
public class AdsInitialize : MonoBehaviour
{
public static AdsInitialize instance = null;
private string LEADER_BOARD = "******";
public Text _text;
private void Awake()
{
if (instance == null)
{
instance = this;
MobileAds.Initialize(initStatus => { });
PlayGamesPlatform.DebugLogEnabled = true;
PlayGamesPlatform.Activate();
Social.localUser.Authenticate(success =>
{
if (success)
{
_text.text = "Auth working";
}
else
{
_text.text = "Auth not working";
}
});
}
else if (instance != this)
{
Destroy(gameObject);
}
DontDestroyOnLoad(gameObject);
}
public void ShowLeaderBoard()
{
//Social.ShowLeaderboardUI();
PlayGamesPlatform.Instance.ShowLeaderboardUI(LEADER_BOARD);
}
}
Write highscores:
Social.ReportScore(_time, AdsInitialize.instance.LEADER_BOARD, (bool success) => {
if (success)
{
_text.text = "ReportScore working";
}
else
{
_text.text = "ReportScore not working";
}
});
Show leaderboard in menu (this method is hanging on button):
public void ShowLeaderBoard()
{
AdsInitialize.instance.ShowLeaderBoard();
}
You need update your Google Play Games at phone
sorry im newish to programming so this may be an easy solvable problem that im not knowledgeable enough to know how to fix
Im using this tutorial for a simple dungeon crawler https://bitbucket.org/FaronBracy/roguesharpv3tutorial/src/master/
when it came to implementing the behaviors of the kobolds (mutants in my project) i would get an error saying 'Argument 1: cannot convert from 'Poc.Core.(Player/monster)" to "Poc.Interface.ISchedule"
this was happening on the addplayer void, addmonster void, and removemonster void in the DungeonMap.cs and twice on the ActivateMonsters void in CommandSystem.cs
i would appreciate it so much if someone could help me fix this problem
problem voids:
public void AddPlayer(Player player)
{
Game.Player = player;
SetIsWalkable(player.X, player.Y, false);
UpdatePlayerFieldOfView();
**Game.SchedulingSystem.Add(player);**
}
public void AddMonster(Monster monster)
{
_monsters.Add(monster);
// After adding the monster to the map make sure to make the
cell not walkable
SetIsWalkable(monster.X, monster.Y, false);
**Game.SchedulingSystem.Add( monster );**
}
public void RemoveMonster(Monster monster)
{
_monsters.Remove(monster);
SetIsWalkable(monster.X, monster.Y, true);
**SchedulingSystem.Remove(monster);**
}
public void ActivateMonsters()
{
IScheduleable scheduleable = Game.SchedulingSystem.Get();
if (scheduleable is Player)
{
IsPlayerTurn = true;
**Game.SchedulingSystem.Add(Game.Player);**
}
else
{
Monster monster = scheduleable as Monster;
if (monster != null)
{
monster.PerformAction(this);
**Game.SchedulingSystem.Add(monster);**
}
ActivateMonsters();
}
}
then my Scheduling System code
namespace Poc.Systems
{
public class SchedulingSystem
{
private int _time;
private readonly SortedDictionary<int, List<IScheduleable>> _scheduleables;
public SchedulingSystem()
{
_time = 0;
_scheduleables = new SortedDictionary<int, List<IScheduleable>>();
}
public void Add(IScheduleable scheduleable)
{
int key = _time + scheduleable.Time;
if (!_scheduleables.ContainsKey(key))
{
_scheduleables.Add(key, new List<IScheduleable>());
}
_scheduleables[key].Add(scheduleable);
}
public void Remove(IScheduleable scheduleable)
{
KeyValuePair<int, List<IScheduleable>> scheduleableListFound
= new KeyValuePair<int, List<IScheduleable>>(-1, null);
foreach (var scheduleablesList in _scheduleables)
{
if (scheduleablesList.Value.Contains(scheduleable))
{
scheduleableListFound = scheduleablesList;
break;
}
}
if (scheduleableListFound.Value != null)
{
scheduleableListFound.Value.Remove(scheduleable);
if (scheduleableListFound.Value.Count <= 0)
{
_scheduleables.Remove(scheduleableListFound.Key);
}
}
}
public IScheduleable Get()
{
var firstScheduleableGroup = _scheduleables.First();
var firstScheduleable = firstScheduleableGroup.Value.First();
Remove(firstScheduleable);
_time = firstScheduleableGroup.Key;
return firstScheduleable;
}
// Get the current time (turn) for the schedule
public int GetTime()
{
return _time;
}
{
_time = 0;
_scheduleables.Clear();
}
}
}
Make sure that your Actor class, which Player and Monster inherit from, is implementing IScheduleable:
public class Actor : IActor, IDrawable, IScheduleable
{
// ... Previous Actor code omitted
// IScheduleable
public int Time
{
get
{
return Speed;
}
}
}
first, there is a singleton object simply is subscribed to activeSceneChanged
SomeSingleton.cs
void Awake ()
{
Debug.LogError ("AWAKE");
if (instance == null) {
Debug.LogError ("instance == null");
instance = this;
MusicController.instance = this;
SceneManager.activeSceneChanged += OnSceneChanged;
DontDestroyOnLoad (this.gameObject);
} else {
Debug.LogError ("destroy");
Destroy (this.gameObject);
}
}
void OnSceneChanged (Scene previousScene, Scene changedScene)
{
Debug.LogError ("OnSceneChanged changedScene = " + changedScene.name);
}
from Lobby Scene player moves to Room Scene.
in room scene.
the "Arena" Scene gets preloaded for better game experience.
LoadSceneAsync("Arena")
with allowSceneActivation = false
when player clicks play button, sets allowSceneActivation = true
but when user decides to go back and clicks Leave Button, LoadScene("Lobby") gets called.
At this time in console, it will Log
LOGS
OnSceneChanged changedScene = Lobby // time : 0.793
OnSceneChanged changedScene = Room // time : 3.982
[when player clicks Leave Button]
OnSceneChanged changedScene = Arena // time : 7.583
OnSceneChanged changedScene = Lobby // time : 7.583
like this...
it just gets activated but wont actually load the scene. why is Arena getting activatd? how to solve this problem???
should i do some unload thing to the AsyncLoading?
==== EDITED =====
when leave button clicked
public void LeaveRoom ()
{
print ("Leave Room And Move To Lobby");
SetCanStartIfMasterClient (false);
PhotonNetwork.LeaveRoom ();
AdmobController.DestroyBanner ();
Waiting.instance.StartWaiting (waitingForLeaveRoomData);
SceneFader.instance.LoadSceneWhenFadingComplete (SceneType.Lobby);
}
in SceneFader.cs
public enum SceneFadeType
{
FadeIn = 1,
FadeOut = -1
}
public class SceneFader : MonoBehaviour
{
public static SceneFader instance;
void Awake ()
{
instance = this;
// StartFadeOut
StartFading (SceneFadeType.FadeOut, null);
}
public void LoadSceneWhenFadingComplete (SceneType sceneType)
{
// 1. start Fading
// 2. on fading complete, LoadScene
StartFading
(
fadeType: SceneFadeType.FadeIn,
onFadingComplete: () => {
SceneManager.LoadScene (sceneType.ToString ());
}
);
}
public void LoadSceneWhenFadingCompleteAsync (ScenePreloader scenePreloader)
{
// 1 start preloading scene
// 2 on preloading complete, start fading
// 3 on fading complete LoadScene
scenePreloader.AddOnPreloadCompleteAndTriggerIfLoaded (
onPreloadComplete: () => {
StartFading (
fadeType: SceneFadeType.FadeIn,
onFadingComplete: () => {
scenePreloader.ActivateSceneWhenReady ();
}
);
}
);
}
private void StartFading (SceneFadeType fadeType, Action onFadingComplete)
{
Debug.LogWarning ("StartFAding ");
ScreenFader.instance.BeginFade (fadeType, onFadingComplete);
AudioMasterController.instance.StartFading (fadeType, null);
}
}
in ScenePreloader.cs
public class ScenePreloader : MonoBehaviour
{
Action<float> onPreloadRateChanged;
Action onPreloadComplete;
public AsyncOperation sceneLoader;
public bool isPreloadCompleted;
public void StartPreloadingScene (SceneType sceneType, LoadSceneMode loadSceneMode, Action<float> onPreloadRateChanged = null, Action onPreloadComplete = null)
{
this.onPreloadComplete = onPreloadComplete;
this.onPreloadRateChanged = onPreloadRateChanged;
StartCoroutine (PreloadSceneOperation (sceneType, loadSceneMode));
}
public IEnumerator PreloadSceneOperation (SceneType sceneType, LoadSceneMode loadSceneMode = LoadSceneMode.Single)
{
print ("PreloadSceneOperation sceneType = " + sceneType.ToString ());
sceneLoader = SceneManager.LoadSceneAsync (sceneType.ToString (), loadSceneMode);
sceneLoader.allowSceneActivation = false;
while (!sceneLoader.isDone) {
yield return null;
if (sceneLoader.progress >= 0.9f) {
print ("onPreloadComplete");
isPreloadCompleted = true;
if (onPreloadComplete != null) {
onPreloadComplete ();
}
break;
} else {
if (onPreloadRateChanged != null) {
onPreloadRateChanged (sceneLoader.progress);
}
}
}
}
public void ActivateSceneWhenReady ()
{
sceneLoader.allowSceneActivation = true;
}
public void AddOnPreloadCompleteAndTriggerIfLoaded (Action onPreloadComplete)
{
AddOnPreloadComplete (onPreloadComplete);
if (isPreloadCompleted) {
print ("isAlreadyLoadedTrigeringCallback");
onPreloadComplete ();
}
}
public void AddOnPreloadComplete (Action onPreloadComplete)
{
this.onPreloadComplete += onPreloadComplete;
}
public void SetOnLoadProgressValueChanged (Action<float> onLoadProgressValueChanged)
{
this.onPreloadRateChanged = onLoadProgressValueChanged;
}
}
I read a lot of documentation regarding this problem, but I don't seen any answer.
I have a Xamarin form app that play mp3 sample music from the Groove music service.
On Android, everyhting workd fine.
On Ios, I'm not able to play the sound. I get the URL and it's not possible to ear anything (I was able to play a local mp3)
I see this problem occured also for people using SWIFT : How to play MP3 From URL in iOS
I also found several exemple on the Xamarin forum but no sound neither: https://forums.xamarin.com/discussion/19883/how-do-i-get-the-avplayer-to-play-an-mp3-from-a-remote-url
Here is the code I use:
public class AudioService : IAudio
{
protected string FileName = string.Empty;
protected AVPlayer Player;
public bool IsPlaying { get; private set; }
public void Init(string fileName)
{
//FileName = fileName;
string second = "http://progdownload.zune.net/145/119/034/170/audio.mp3?rid=0b80911a-ba3b-42ec-b17f-c242ba087024-s4-nl-BE-music-asset-location";
FileName = second;
QueueFile();
}
public async void PlayStream(string uri)
{
Init(uri);
System.Diagnostics.Debug.WriteLine("Enter in function");
Player.Play();
System.Diagnostics.Debug.WriteLine("Play sound");
System.Diagnostics.Debug.WriteLine(FileName);
IsPlaying = true;
System.Diagnostics.Debug.WriteLine(IsPlaying);
}
public void Pause()
{
IsPlaying = false;
Player.Pause();
}
public void Stop()
{
IsPlaying = false;
if (Player == null) return;
Player.Dispose();
Player = null;
}
public bool HasFile
{
get { return Player != null; }
}
private void QueueFile()
{
if (string.IsNullOrWhiteSpace(FileName))
{
throw new Exception("No file specified to play");
}
using (var url = NSUrl.FromString(FileName))
{
var test = AVAsset.FromUrl(url);
var playerItem = AVPlayerItem.FromAsset(test);
// if Player is null, we're creating a new instance and seeking to the spot required
// otherwise we simply resume from where we left off.
if (Player == null)
{
Player = AVPlayer.FromPlayerItem(playerItem);
if (Player == null)
{
// todo: what should we do if the file doesn't exist?
return;
}
}
}
}}
(IAudio just implements playstream and stop)
If you click on the url, your browser will be able to play music
http://progdownload.zune.net/145/119/034/170/audio.mp3?rid=0b80911a-ba3b-42ec-b17f-c242ba087024-s4-nl-BE-music-asset-location
Does any one was able to play mp3 from internet
The answer in the info.list file. You need to add this to your info.list:
<key>NSAppTransportSecurity</key><dict>
<key>NSAllowsArbitraryLoads</key>
<true/></dict>
I had the same issue and resolved it.
I've made some cleaning for your code :)
This is what we got, including the detecting the end of playing
public class AudioService
{
#region Members
protected AVPlayer Player;
#endregion
#region Properties
public bool IsPlaying { get; private set; }
public bool HasFile => Player != null;
public Action MediaEnded { get; set; }
#endregion
#region Public Methods
public void PlayStream(string uri)
{
try
{
if (Player != null)
Player.Dispose();
Player = null;
QueueFile(uri);
Player.Play();
IsPlaying = true;
}
catch (Exception ex)
{
IsPlaying = false;
Crashes.TrackError(ex);
}
}
public void Pause()
{
IsPlaying = false;
Player.Pause();
}
public void Stop()
{
IsPlaying = false;
if (Player == null)
return;
Player.Dispose();
Player = null;
}
public void QueueFile(string fileName)
{
if (string.IsNullOrWhiteSpace(fileName))
{
return;
}
using (var url = NSUrl.FromString(fileName))
{
var asset = AVAsset.FromUrl(url);
var playerItem = AVPlayerItem.FromAsset(asset);
if (Player == null)
{
Player = AVPlayer.FromPlayerItem(playerItem);
if (Player == null)
{
return;
}
else
{
NSNotificationCenter.DefaultCenter.AddObserver(AVPlayerItem.DidPlayToEndTimeNotification, OnPlayerDidFinishPlaying, NSObject.FromObject(playerItem));
}
}
}
}
#endregion
#region Private Methods
private void OnPlayerDidFinishPlaying(NSNotification notification)
{
IsPlaying = false;
MediaEnded?.Invoke();
}
#endregion