コード例 #1
0
    // Fetch Currency from ChilliConnect
    public void FetchCurrency(ChilliConnectSdk chilliConnect)
    {
        this.chilliConnect = chilliConnect;
        Debug.Log("Fetching currency");

        chilliConnect.Economy.GetCurrencyBalance(new GetCurrencyBalanceRequestDesc()
                                                 , (request, response) =>
        {
            // Handle Currency Response from ChilliConnect
            Debug.Log("Currency fetched: ");
            foreach (var item in response.Balances)
            {
                switch (item.Key)
                {
                case "COINS":
                    playerCoins = item.Balance;
                    break;

                case "USERLEVEL":
                    playerLevel = item.Balance;
                    break;
                }
            }
            UpdatePlayerStatistics();
        }
                                                 , (request, error) => Debug.LogError(error.ErrorDescription));
    }
コード例 #2
0
    // Start the ChilliConnect SDK, creating a player if one is not stored on the client.
    private void ChilliConnectInit()
    {
        // InitialiseChilliConnect SDK with our Game Token
        //chilliConnect = new ChilliConnectSdk("6PvaW0XKPZF3wUTOavDPwcLQUho9DQdS", true);
        chilliConnect = new ChilliConnectSdk("hxNSsyHz0KYmgNweytP4AiJGiuJIfl8t", true);

        // Create a Player and store the ChilliConnectId if we don't already have one
        if (!PlayerPrefs.HasKey("ChilliConnectId") || !PlayerPrefs.HasKey("ChilliConnectSecret"))
        {
            var createPlayerRequest = new CreatePlayerRequestDesc();

            // Create Player Account
            chilliConnect.PlayerAccounts.CreatePlayer(createPlayerRequest,
                                                      (CreatePlayerRequest request, CreatePlayerResponse response) =>
            {
                Debug.Log("Create Player successfull : " + response.ChilliConnectId);

                PlayerPrefs.SetString("ChilliConnectId", response.ChilliConnectId);
                PlayerPrefs.SetString("ChilliConnectSecret", response.ChilliConnectSecret);

                chilliConnectId     = response.ChilliConnectId;
                chilliConnectSecret = response.ChilliConnectSecret;
            },
                                                      (CreatePlayerRequest request, CreatePlayerError error) =>
            {
                Debug.Log("An error occurred Creating Player : " + error.ErrorDescription);
            }
                                                      );
        }
        else
        {
            chilliConnectId     = PlayerPrefs.GetString("ChilliConnectId");
            chilliConnectSecret = PlayerPrefs.GetString("ChilliConnectSecret");
        }
    }
コード例 #3
0
 /// Initialise all the main systems
 ///
 private void Awake()
 {
     m_chilliConnect = new ChilliConnectSdk(GAME_TOKEN, true);
     m_accountSystem.Initialise(m_chilliConnect);
     m_leaderboardSystem.Initialise(m_chilliConnect);
     m_profilePicSystem.Initialise();
 }
コード例 #4
0
    void Awake()
    {
        //Get a reference to ShowPanels attached to UI object
        showPanels = GetComponent <ShowPanels> ();

        //Get a reference to PlayMusic attached to UI object
        playMusic = GetComponent <PlayMusic> ();

        playMusic = GetComponent <PlayMusic> ();

        //setup ChilliConnect SDK with game token and verbose logging
        chilliConnect       = new ChilliConnectSdk(GAME_TOKEN, true);
        ChilliConnectId     = PlayerPrefs.GetString("ChilliConnectId");
        ChilliConnectSecret = PlayerPrefs.GetString("ChilliConnectSecret");
        UnityEngine.Debug.Log("Loaded from PlayerPrefs ChilliconnectId: " + ChilliConnectId + " ChilliConnectSecret: " + ChilliConnectSecret);

        //if player not created
        if (ChilliConnectId.Length == 0)
        {
            CreateAndLoginPlayer();
        }
        else
        {
            LoginPlayer();
        }
    }
コード例 #5
0
        /// <summary>
        /// Standard starting point for Unity scripts.
        /// </summary>
        IEnumerator Start()
        {
            IDataAccessLayer dataLayer = null;

#if CHILLICONNECT_ENABLED
            var sdk = new ChilliConnectSdk(chilliConnectAppToken, false);

            string
                userId     = default,
コード例 #6
0
ファイル: IAPSystem.cs プロジェクト: zhangxinyu1120/Samples
    /// Initialises the IAP system by pulling the available IAP items from ChilliConnect.
    /// Like most of the IAP calls this is asynchronous and completion can be polled using IsInitialised()
    ///
    /// @param chilliConnect
    ///     SDK instance
    ///
    public void Initialise(ChilliConnectSdk chilliConnect)
    {
        Debug.Log("Initialising IAP system");

        m_chilliConnect = chilliConnect;

        var desc = new GetRealMoneyPurchaseDefinitionsRequestDesc();

        // Make a request for all "Real money purchase" items that have been registered on the ChilliConnect dashboard.
        m_chilliConnect.Catalog.GetRealMoneyPurchaseDefinitions(desc, OnAvailableItemsFetched, (request, error) => Debug.LogError(error.ErrorDescription));
    }
コード例 #7
0
 /// If a player account has already been created and saved in PlayerPrefs
 /// log that player in. Otherwise, will create a new account.
 ///
 /// @param chilliConnect
 ///		Instance of the chilliConnect SDK
 ///
 public void Initialise(ChilliConnectSdk chilliConnect)
 {
     m_chilliConnect = chilliConnect;
     if (PlayerPrefs.HasKey("CCId") && PlayerPrefs.HasKey("CCSecret"))
     {
         Login(PlayerPrefs.GetString("CCId"), PlayerPrefs.GetString("CCSecret"));
     }
     else
     {
         CreateNewAccount();
     }
 }
コード例 #8
0
    /// Must be called before any other FB API calls.
    ///
    /// @param chilliConnect
    ///     SDK instance
    ///
    public void Initialise(ChilliConnectSdk chilliConnect)
    {
        m_chilliConnect = chilliConnect;

        if (FB.IsInitialized == false)
        {
            FB.Init(OnFBInitComplete);
        }
        else
        {
            OnFBInitComplete();
        }
    }
コード例 #9
0
    //------------------------------------------------------------------
    /// Initilisation that creates an instance of ChilliConnect and subscribes
    /// to Push Notification listener events.
    //------------------------------------------------------------------
    private void Awake()
    {
        m_chilliConnect = new ChilliConnectSdk(k_chilliConnectToken, false);

#if UNITY_ANDROID && !UNITY_EDITOR
        GooglePushNotificationHandler.SetRecieverGameObject("GooglePushNotificationListener");
        GameObject.FindObjectOfType <GooglePushNotificationListener>().RegistrationSucceededEvent = OnPluginRegistered;
        GameObject.FindObjectOfType <GooglePushNotificationListener>().RegistrationFailedEvent    = OnPluginFailed;
#elif UNITY_IOS
        GameObject.FindObjectOfType <iOSPushNotificationListener>().RegistrationSucceededEvent = OnPluginRegistered;
        GameObject.FindObjectOfType <iOSPushNotificationListener>().RegistrationFailedEvent    = OnPluginFailed;
#endif
    }
コード例 #10
0
    /// If a player account has already been created and saved in PlayerPrefs
    /// log that player in. Otherwise, will create a new account.
    ///
    /// @param chilliConnect
    ///		Instance of the chilliConnect SDK
    ///
    public void Initialise(ChilliConnectSdk chilliConnect)
    {
        m_chilliConnect = chilliConnect;
        var player = LoadPlayer();

        if (player != null)
        {
            Login(player.ChilliConnectId, player.ChilliConnectSecret);
        }
        else
        {
            CreateNewAccount();
        }
    }
コード例 #11
0
    /// If a player account has already been created and saved in PlayerPrefs
    /// log that player in. Otherwise, will create a new account.
    ///
    /// @param chilliConnect
    ///		Instance of the chilliConnect SDK
    ///
    public void Initialise(ChilliConnectSdk chilliConnect)
    {
        m_chilliConnect = chilliConnect;

        if (PlayerPrefs.HasKey("CCId") && PlayerPrefs.HasKey("CCSecret"))
        {
            UnityEngine.Debug.Log("Current ChilliConnectID: " + PlayerPrefs.GetString("CCId"));

            Login(PlayerPrefs.GetString("CCId"), PlayerPrefs.GetString("CCSecret"));
        }
        else
        {
            CreateNewAccount();
        }
    }
コード例 #12
0
    /// Initialised ChilliConnect, create and log in a player.
    ///
    private void Awake()
    {
        // Initialise ChilliConnect. Game token can be found on the game dashboard of ChilliConnect
        m_chilliConnect = new ChilliConnectSdk(GAME_TOKEN, true);

        // Create a new ChilliConnect player with the given display name if we don't have any credentials saved for the local player
        if (PlayerPrefs.HasKey("CCId") == true && PlayerPrefs.HasKey("CCSecret") == true)
        {
            Debug.Log("Player already exists. Logging in");
            m_chilliConnect.PlayerAccounts.LogInUsingChilliConnect(PlayerPrefs.GetString("CCId"), PlayerPrefs.GetString("CCSecret"), (loginRequest) => OnLoggedIn(), (loginRequest, error) => Debug.LogError(error.ErrorDescription));
        }
        else
        {
            Debug.Log("Creating Player");
            var requestDesc = new CreatePlayerRequestDesc();
            requestDesc.DisplayName = "TestyMcTestface";
            m_chilliConnect.PlayerAccounts.CreatePlayer(requestDesc, OnPlayerCreated, (AddEventRequest, error) => Debug.LogError(error.ErrorDescription));
        }
    }
コード例 #13
0
    private void Awake()
    {
        m_chilliConnect = new ChilliConnectSdk(GAME_TOKEN, false);

        m_matchSystem.Initialise(m_chilliConnect);
        m_matchSystem.OnMatchUpdated        += OnMatchUpdated;
        m_matchSystem.OnMatchMakingStarted  += OnMatchMakingStarted;
        m_matchSystem.OnMatchMakingFailed   += OnMatchMakingFailed;
        m_matchSystem.OnMatchMakingSuceeded += OnMatchMakingSuceeded;
        m_matchSystem.OnNewMatchCreated     += OnNewMatchCreated;
        m_matchSystem.OnMatchSavedOnServer  += OnMatchSavedOnServer;

        m_accountSystem.Initialise(m_chilliConnect);
        m_accountSystem.OnPlayerLoggedIn += OnPlayerLoggedIn;

        gameController.ShowChilliInfoPanel(MESSAGE_LOGGING_IN);
        gameController.OnSideSelected    += OnSideSelected;
        gameController.OnTurnEnded       += OnTurnEnded;
        gameController.OnNewGameSelected += OnNewGameSelected;
    }
コード例 #14
0
    private void Awake()
    {
        m_chilliConnect = new ChilliConnectSdk(GAME_TOKEN, false);

        CurrentMatch = new Match();

        m_accountSystem.Initialise(m_chilliConnect);
        m_accountSystem.OnPlayerLoggedIn += OnPlayerLoggedIn;

        photonController.Initialise(m_chilliConnect);

        roomController.Initialise();
        roomController.OnGameStart  += OnGameStart;
        roomController.OnRoomJoin   += OnRoomJoin;
        roomController.OnNextTurn   += OnNextTurn;
        roomController.OnGameEnded  += OnGameEnded;
        roomController.OnPlayerQuit += OnPlayerQuit;

        gameController.ShowChilliInfoPanel(MESSAGE_LOGGING_IN);
        gameController.OnTurnEnded += OnTurnEnded;
    }
コード例 #15
0
 private void Awake()
 {
     m_chilliConnect = new ChilliConnectSdk(GAME_TOKEN, true);
     m_accountSystem.Initialise(m_chilliConnect);
     m_economySystem.Initialise(m_chilliConnect);
 }
コード例 #16
0
 public void Initialise(ChilliConnectSdk chilliConnect)
 {
     m_chilliConnect = chilliConnect;
     Recipes         = new List <Recipe> ();
     Characters      = new List <Character> ();
 }
コード例 #17
0
ファイル: MatchSystem.cs プロジェクト: ErdinyoBarboza/Samples
 public void Initialise(ChilliConnectSdk chilliConnect)
 {
     m_chilliConnect = chilliConnect;
     CurrentMatch    = new Match();
 }
コード例 #18
0
ファイル: MatchSystem.cs プロジェクト: zhangxinyu1120/Samples
 public void Initialise(ChilliConnectSdk chilliConnect)
 {
     m_chilliConnect = chilliConnect;
     CurrentGame     = new GameState();
 }
コード例 #19
0
 ///
 public void Initialise(ChilliConnectSdk chilliConnect)
 {
     m_chilliConnect = chilliConnect;
 }
コード例 #20
0
 /// Fetch the inventory contents from ChilliConnect at the start of the game.
 ///
 /// @param chilliConnect
 ///     SDK instance
 ///
 public void Initialise(ChilliConnectSdk chilliConnect)
 {
     Debug.Log("Fetching inventory");
     chilliConnect.Economy.GetCurrencyBalance(new GetCurrencyBalanceRequestDesc(), OnCurrencyBalanceFetched, (request, error) => Debug.LogError(error.ErrorDescription));
 }