Example #1
0
    /// <summary>
    /// send data to server after mission end
    /// </summary>
    public void Send_data_to_server()
    {
        if (PlayerPrefs.GetString("_id").Length > 2)
        {
            Chilligames_SDK.API_Client.Send_Data_user(new Req_send_data
            {
                _id       = _id,
                Name_app  = "Venomic",
                Data_user = ChilligamesJson.SerializeObject(new Entity_Player
                {
                    Freeze = PlayerPrefs.GetInt("Freeze"),
                    Minus  = PlayerPrefs.GetInt("Minuse"),
                    Chance = PlayerPrefs.GetInt("Chance"),
                    Delete = PlayerPrefs.GetInt("Delete"),
                    Reset  = PlayerPrefs.GetInt("Reset"),
                    Level  = PlayerPrefs.GetInt("Level"),
                })
            }, () => { }, () => { });

            Chilligames_SDK.API_Client.Sync_coin_with_server(new Req_sync_coin_with_server {
                Coin = PlayerPrefs.GetInt("Coin"), _id = _id
            }, () => { }, err => { });
        }
    }
Example #2
0
    public void OnEnable()
    {
        //starter
        // destroy  no net  and recive after recive
        if (Server_fild != null)
        {
            for (int i = 0; i < Server_fild.Length; i++)
            {
                Destroy(Server_fild[i]);
            }
            Server_fild = null;
        }


        /*....online....*/

        if (PlayerPrefs.GetString("_id").Length < 2)
        {
            Chilligames_SDK.API_Client.Quick_register(result =>
            {
                print("register_new_user");
                PlayerPrefs.SetString("_id", result._id);
                SceneManager.LoadScene(0);
            }, ERROR =>
            {
                Offline_mode.SetActive(true);

                for (int i = 0; i < object_hide_offline.Length; i++)
                {
                    object_hide_offline[i].gameObject.SetActive(false);
                }
            });
        }
        else
        {
            Chilligames_SDK.API_Client.Quick_login(new Req_Login {
                _id = PlayerPrefs.GetString("_id")
            }, Result_login =>
            {
                if (Result_login == "1")
                {
                    Send_data();

                    Chilligames_SDK.API_Client.Recive_List_server_user(new Req_recive_list_servers_User {
                        Name_app = "Venomic", _id = _id
                    }, Result_server =>
                    {
                        Server_fild = new GameObject[Result_server.Length];
                        for (int i = 0; i < Result_server.Length; i++)
                        {
                            Server_fild[i] = Instantiate(Raw_model_fild_server_play, Place_server);
                            Server_fild[i].GetComponent <Raw_model_fild_server_play>().Change_value(Result_server[i].ToString(), _id, gameObject);
                        }
                    }, err => { });

                    Chilligames_SDK.API_Client.Recive_info_user(new Req_recive_Info_player {
                        _id = _id
                    }, result =>
                    {
                        Text_nickname.text = result.Nickname;
                    }, err => { });

                    void Send_data()
                    {
                        Chilligames_SDK.API_Client.Recive_Coin_mony(new Req_recive_coin {
                            _id = _id
                        }, result =>
                        {
                            if (result.Coin > PlayerPrefs.GetInt("Coin"))
                            {
                                PlayerPrefs.SetInt("Coin", (int)result.Coin);
                                print("Coin to game ");
                            }
                            else
                            {
                                print("coin to server");

                                Chilligames_SDK.API_Client.Sync_coin_with_server(new Req_sync_coin_with_server {
                                    Coin = PlayerPrefs.GetInt("Coin"), _id = _id
                                }, () => { }, err => { });
                            }
                        }, err => { });


                        Chilligames_SDK.API_Client.Send_Data_user(new Req_send_data
                        {
                            _id       = _id,
                            Name_app  = "Venomic",
                            Data_user = ChilligamesJson.SerializeObject(new Entity_Player
                            {
                                Chance = PlayerPrefs.GetInt("Chance"),
                                Delete = PlayerPrefs.GetInt("Delete"),
                                Freeze = PlayerPrefs.GetInt("Freeze"),
                                Level  = PlayerPrefs.GetInt("Level"),
                                Minus  = PlayerPrefs.GetInt("Minuse"),
                                Reset  = PlayerPrefs.GetInt("Reset")
                            })
                        }, () => { }, () => { });

                        Chilligames_SDK.API_Client.Send_Score_to_leader_board(new Req_send_score {
                            Leader_board_name = "Venomic_Top_Player", Score = PlayerPrefs.GetInt("Level"), _id = _id
                        }, () => { });

                        Chilligames_SDK.API_Client.Recive_rank_postion(new Req_recive_rank_postion {
                            _id = _id, Leader_board_name = "Venomic_Top_Player"
                        }, result =>
                        {
                            if (result == "0")
                            {
                                Text_ranking_number.text = "King";
                            }
                            else
                            {
                                Text_ranking_number.text = result;
                            }
                        }, err => { });

                        Chilligames_SDK.API_Admin.Send_log_user(new Chilligames.SDK.Model_Admin.Req_send_logPlayer {
                            _id = _id
                        });
                    }
                }
                else if (Result_login == "0")
                {
                    print("Code not login here");
                }
            }, ERR =>
            {
                Offline_mode.SetActive(true);

                for (int i = 0; i < object_hide_offline.Length; i++)
                {
                    object_hide_offline[i].gameObject.SetActive(false);
                }
            });
        }
    }
Example #3
0
    void Start()
    {
        BazaarIAB.init("MIHNMA0GCSqGSIb3DQEBAQUAA4G7ADCBtwKBrwCsKayLopsdltsho45vsaVhWeamm89xS62xwub2QU8DF9AOndmaLr3yP+lP53tdwNc5V4wVEyb6/EIZWMEZdWAYH2oNOhLNkK2MBSaQ0fHWnXnVTnAoJUnzVJxzCVPOpXAtOK5SVZiDMjlx3q16eYZe6y1ams6+mIcTDpCogHBeQlKT3jWzhTIdyGsz+d7MhwYa5rNU/CzRN09L70XNWctFdF0VCXZkCCFhIgszExUCAwEAAQ==");

        BTN_close.onClick.AddListener(() =>
        {
            BazaarIAB.unbindService();
            Destroy(gameObject);
        });


        BTN_buy_800.onClick.AddListener(() =>
        {
            BazaarIAB.purchaseProduct("CH-V-C");
        });

        BTN_buy_1600.onClick.AddListener(() =>
        {
            BazaarIAB.purchaseProduct("CH-V-C-1");
        });

        BTN_buy_38000.onClick.AddListener(() =>
        {
            BazaarIAB.purchaseProduct("CH-V-C-2");
        });
        BTN_buy_72000.onClick.AddListener(() =>
        {
            BazaarIAB.purchaseProduct("72000");
        });
        BTN_buy_120000.onClick.AddListener(() =>
        {
            BazaarIAB.purchaseProduct("120000");
        });
        BTN_buy_205000.onClick.AddListener(() =>
        {
            BazaarIAB.purchaseProduct("205000");
        });
        BTN_buy_233000.onClick.AddListener(() =>
        {
            BazaarIAB.purchaseProduct("23300");
        });
        BTN_buy_280000.onClick.AddListener(() =>
        {
            BazaarIAB.purchaseProduct("280000");
        });


        //event manager bazaar

        IABEventManager.purchaseFailedEvent    += Event_faild;
        IABEventManager.purchaseSucceededEvent += Even_success;

        void Event_faild(string faild)
        {
            Instantiate(Raw_model_message_notifaction).GetComponent <Raw_model_massage_notifaction>().Change_value("Payment failed", $"{faild}", Raw_model_massage_notifaction.Type.ERRoR, Raw_model_massage_notifaction.Theme.Night);
        }

        void Even_success(BazaarPurchase success)
        {
            //control product
            switch (success.ProductId)
            {
            case "CH-V-C":
            {
                inject_coin_to_server(75);
                BazaarIAB.consumeProduct("CH-V-C");
                Instantiate(Raw_model_message_notifaction).GetComponent <Raw_model_massage_notifaction>().Change_value("Payment Successful", "75 coins have been added to your account\n" + "Thank you for your purchase", Raw_model_massage_notifaction.Type.Success, Raw_model_massage_notifaction.Theme.Night);
            }
            break;

            case "CH-V-C-1":
            {
                inject_coin_to_server(150);
                BazaarIAB.consumeProduct("CH-V-C-1");
                Instantiate(Raw_model_message_notifaction).GetComponent <Raw_model_massage_notifaction>().Change_value("Payment Successful", "800 coins have been added to your account\n" + "Thank you for your purchase", Raw_model_massage_notifaction.Type.Success, Raw_model_massage_notifaction.Theme.Night);
            }
            break;

            case "CH-V-C-2":
            {
                inject_coin_to_server(350);
                BazaarIAB.consumeProduct("CH-V-C-2");
                Instantiate(Raw_model_message_notifaction).GetComponent <Raw_model_massage_notifaction>().Change_value("Payment Successful", "350 coins have been added to your account\n" + "Thank you for your purchase", Raw_model_massage_notifaction.Type.Success, Raw_model_massage_notifaction.Theme.Night);
            }
            break;

            case "72000":
            {
                inject_coin_to_server(1500);
                BazaarIAB.consumeProduct("72000");
                Instantiate(Raw_model_message_notifaction).GetComponent <Raw_model_massage_notifaction>().Change_value("Payment Successful", "1500 coins have been added to your account\n" + "Thank you for your purchase", Raw_model_massage_notifaction.Type.Success, Raw_model_massage_notifaction.Theme.Night);
            }
            break;

            case "120000":
            {
                inject_coin_to_server(1550);
                BazaarIAB.consumeProduct("120000");
                Instantiate(Raw_model_message_notifaction).GetComponent <Raw_model_massage_notifaction>().Change_value("Payment Successful", "1550 coins have been added to your account\n" + "Thank you for your purchase", Raw_model_massage_notifaction.Type.Success, Raw_model_massage_notifaction.Theme.Night);
            }
            break;

            case "205000":
            {
                inject_coin_to_server(2700);
                BazaarIAB.consumeProduct("205000");
                Instantiate(Raw_model_message_notifaction).GetComponent <Raw_model_massage_notifaction>().Change_value("Payment Successful", "2700 coins have been added to your account\n" + "Thank you for your purchase", Raw_model_massage_notifaction.Type.Success, Raw_model_massage_notifaction.Theme.Night);
            }
            break;

            case "23300":
            {
                inject_coin_to_server(6000);
                BazaarIAB.consumeProduct("23300");
                Instantiate(Raw_model_message_notifaction).GetComponent <Raw_model_massage_notifaction>().Change_value("Payment Successful", "6000 coins have been added to your account\n" + "Thank you for your purchase", Raw_model_massage_notifaction.Type.Success, Raw_model_massage_notifaction.Theme.Night);
            }
            break;

            case "280000":
            {
                inject_coin_to_server(10000);
                BazaarIAB.consumeProduct("280000");
                Instantiate(Raw_model_message_notifaction).GetComponent <Raw_model_massage_notifaction>().Change_value("Payment Successful", "10000 coins have been added to your account\n" + "Thank you for your purchase", Raw_model_massage_notifaction.Type.Success, Raw_model_massage_notifaction.Theme.Night);
            }
            break;
            }

            //update coin panel shop
            Text_coin_panel_shop.text = PlayerPrefs.GetInt("Coin").ToString();

            //add history to server
            Data_buy data_purchase = new Data_buy
            {
                developerid          = success.DeveloperPayload,
                Orderid              = success.OrderId,
                orginal_Json         = success.OriginalJson,
                Purchasses_pakage    = success.PackageName,
                Purchasses_productid = success.ProductId,
                Purchasses_state     = success.PurchaseState.ToString(),
                Purchasses_time      = success.PurchaseTime.ToString(),
                Purchasses_token     = success.PurchaseToken,
                Signuture            = success.Signature,
                Type = success.Type,
            };

            Chilligames_SDK.API_Client.Add_purchasses_history(new Req_add_purchasses_history {
                _id = _id, data_purchass = ChilligamesJson.SerializeObject(data_purchase), Name_app = "Venomic"
            }, () => { }, err => { });
        }
    }
Example #4
0
    private void Start()
    {
        //step1
        StartCoroutine(Destroy_offer());
        BTN_reject.onClick.AddListener(() =>
        {
            anim = 1;
        });

        BTN_accept.onClick.AddListener(() =>
        {
            anim = 2;
            StopAllCoroutines();
        });


        //step_2
        BTN_close_step_2.onClick.AddListener(() =>
        {
            anim = 3;
        });

        BTN_pluse_freeze.onClick.AddListener(() =>
        {
            if (PlayerPrefs.GetInt("Coin") >= 4)
            {
                PlayerPrefs.SetInt("Freeze", PlayerPrefs.GetInt("Freeze") + 1);
                PlayerPrefs.SetInt("Coin", PlayerPrefs.GetInt("Coin") - 4);
            }
            else
            {
                anim = 4;
            }
        });
        BTN_pluse_minuse.onClick.AddListener(() =>
        {
            if (PlayerPrefs.GetInt("Coin") >= 2)
            {
                PlayerPrefs.SetInt("Minuse", PlayerPrefs.GetInt("Minuse") + 1);
                PlayerPrefs.SetInt("Coin", PlayerPrefs.GetInt("Coin") - 2);
            }
            else
            {
                anim = 4;
            }
        });
        BTN_pluse_delete.onClick.AddListener(() =>
        {
            if (PlayerPrefs.GetInt("Coin") >= 3)
            {
                PlayerPrefs.SetInt("Delete", PlayerPrefs.GetInt("Delete") + 1);
                PlayerPrefs.SetInt("Coin", PlayerPrefs.GetInt("Coin") - 3);
            }
            else
            {
                anim = 4;
            }
        });
        BTN_pluse_chance.onClick.AddListener(() =>
        {
            if (PlayerPrefs.GetInt("Coin") >= 2)
            {
                PlayerPrefs.SetInt("Chance", PlayerPrefs.GetInt("Chance") + 1);
                PlayerPrefs.SetInt("Coin", PlayerPrefs.GetInt("Coin") - 2);
            }
            else
            {
                anim = 4;
            }
        });
        BTN_pluse_reset.onClick.AddListener(() =>
        {
            if (PlayerPrefs.GetInt("Coin") >= 4)
            {
                PlayerPrefs.SetInt("Reset", PlayerPrefs.GetInt("Reset") + 1);
                PlayerPrefs.SetInt("Coin", PlayerPrefs.GetInt("Coin") - 4);
            }
            else
            {
                anim = 4;
            }
        });


        //step_3

        BazaarIAB.init("MIHNMA0GCSqGSIb3DQEBAQUAA4G7ADCBtwKBrwCsKayLopsdltsho45vsaVhWeamm89xS62xwub2QU8DF9AOndmaLr3yP+lP53tdwNc5V4wVEyb6/EIZWMEZdWAYH2oNOhLNkK2MBSaQ0fHWnXnVTnAoJUnzVJxzCVPOpXAtOK5SVZiDMjlx3q16eYZe6y1ams6+mIcTDpCogHBeQlKT3jWzhTIdyGsz+d7MhwYa5rNU/CzRN09L70XNWctFdF0VCXZkCCFhIgszExUCAwEAAQ==");
        BTN_close.onClick.AddListener(() =>
        {
            anim = 5;
        });

        BTN_buy_800.onClick.AddListener(() =>
        {
            BazaarIAB.purchaseProduct("CH-V-C");
        });
        BTN_buy_1600.onClick.AddListener(() =>
        {
            BazaarIAB.purchaseProduct("CH-V-C-1");
        });
        BTN_buy_38000.onClick.AddListener(() =>
        {
            BazaarIAB.purchaseProduct("CH-V-C-2");
        });
        BTN_buy_72000.onClick.AddListener(() =>
        {
            BazaarIAB.purchaseProduct("72000");
        });
        BTN_buy_120000.onClick.AddListener(() =>
        {
            BazaarIAB.purchaseProduct("120000");
        });
        BTN_buy_205000.onClick.AddListener(() =>
        {
            BazaarIAB.purchaseProduct("205000");
        });
        BTN_buy_233000.onClick.AddListener(() =>
        {
            BazaarIAB.purchaseProduct("23300");
        });
        BTN_buy_280000.onClick.AddListener(() =>
        {
            BazaarIAB.purchaseProduct("280000");
        });


        //bazaar event
        IABEventManager.purchaseSucceededEvent +=
            Success =>
        {
            switch (Success.ProductId)
            {
            case "CH-V-C":
            {
                inject_coin(75);
                BazaarIAB.consumeProduct("CH-V-C");
                Instantiate(Raw_model_message_notifaction).GetComponent <Raw_model_massage_notifaction>().Change_value("Payment Successful", "75 coins have been added to your account\n" + "Thank you for your purchase", Raw_model_massage_notifaction.Type.Success, Raw_model_massage_notifaction.Theme.Night);
            }
            break;

            case "CH-V-C-1":
            {
                inject_coin(150);
                BazaarIAB.consumeProduct("CH-V-C-1");
                Instantiate(Raw_model_message_notifaction).GetComponent <Raw_model_massage_notifaction>().Change_value("Payment Successful", "150 coins have been added to your account\n" + "Thank you for your purchase", Raw_model_massage_notifaction.Type.Success, Raw_model_massage_notifaction.Theme.Night);
            }
            break;

            case "CH-V-C-2":
            {
                inject_coin(350);
                BazaarIAB.consumeProduct("CH-V-C-2");
                Instantiate(Raw_model_message_notifaction).GetComponent <Raw_model_massage_notifaction>().Change_value("Payment Successful", "350 coins have been added to your account\n" + "Thank you for your purchase", Raw_model_massage_notifaction.Type.Success, Raw_model_massage_notifaction.Theme.Night);
            }
            break;

            case "72000":
            {
                inject_coin(1500);
                BazaarIAB.consumeProduct("72000");
                Instantiate(Raw_model_message_notifaction).GetComponent <Raw_model_massage_notifaction>().Change_value("Payment Successful", "1500 coins have been added to your account\n" + "Thank you for your purchase", Raw_model_massage_notifaction.Type.Success, Raw_model_massage_notifaction.Theme.Night);
            }
            break;

            case "120000":
            {
                inject_coin(1550);
                BazaarIAB.consumeProduct("120000");
                Instantiate(Raw_model_message_notifaction).GetComponent <Raw_model_massage_notifaction>().Change_value("Payment Successful", "1550 coins have been added to your account\n" + "Thank you for your purchase", Raw_model_massage_notifaction.Type.Success, Raw_model_massage_notifaction.Theme.Night);
            }
            break;

            case "205000":
            {
                inject_coin(2700);
                BazaarIAB.consumeProduct("205000");
                Instantiate(Raw_model_message_notifaction).GetComponent <Raw_model_massage_notifaction>().Change_value("Payment Successful", "2700 coins have been added to your account\n" + "Thank you for your purchase", Raw_model_massage_notifaction.Type.Success, Raw_model_massage_notifaction.Theme.Night);
            }
            break;

            case "23300":
            {
                inject_coin(6000);
                BazaarIAB.consumeProduct("23300");

                Instantiate(Raw_model_message_notifaction).GetComponent <Raw_model_massage_notifaction>().Change_value("Payment Successful", "6000coins have been added to your account\n" + "Thank you for your purchase", Raw_model_massage_notifaction.Type.Success, Raw_model_massage_notifaction.Theme.Night);
            }
            break;

            case "280000":
            {
                inject_coin(10000);
                BazaarIAB.consumeProduct("280000");
                Instantiate(Raw_model_message_notifaction).GetComponent <Raw_model_massage_notifaction>().Change_value("Payment Successful", "10000 coins have been added to your account\n" + "Thank you for your purchase", Raw_model_massage_notifaction.Type.Success, Raw_model_massage_notifaction.Theme.Night);
            }
            break;
            }

            Data_buy data_Buy = new Data_buy
            {
                developerid          = Success.DeveloperPayload,
                Orderid              = Success.OrderId,
                orginal_Json         = Success.OriginalJson,
                Purchasses_pakage    = Success.PackageName,
                Purchasses_productid = Success.ProductId,
                Purchasses_state     = Success.PurchaseState.ToString(),
                Purchasses_time      = Success.PurchaseTime.ToString(),
                Purchasses_token     = Success.PurchaseToken,
                Signuture            = Success.Signature,
                Type = Success.Type
            };

            Chilligames_SDK.API_Client.Add_purchasses_history(new Chilligames.SDK.Model_Client.Req_add_purchasses_history {
                data_purchass = ChilligamesJson.SerializeObject(data_Buy), _id = _id, Name_app = "Venomic"
            }, () => { }, err => { });;
        };

        IABEventManager.purchaseFailedEvent +=
            faild =>
        {
            Instantiate(Raw_model_message_notifaction).GetComponent <Raw_model_massage_notifaction>().Change_value("Payment failed", $"{faild}", Raw_model_massage_notifaction.Type.ERRoR, Raw_model_massage_notifaction.Theme.Night);
        };


        //inject to server and game
        void inject_coin(int Coin_count)
        {
            PlayerPrefs.SetInt("Coin", PlayerPrefs.GetInt("Coin") + Coin_count);

            Chilligames_SDK.API_Client.Coin_Insert(new Chilligames.SDK.Model_Client.Req_Insert_coin {
            }, () => { }, err => { });
        }
    }