예제 #1
0
    public void _PutTroop()
    {
        if (BattleController.isFighting == false)
        {
            return;
        }

        if (chosenTroop >= 0 && chosenTroop <= listTroopLeft.Length - 1)
        {
            if (listTroopLeft[chosenTroop] > 0)
            {
                Troop troop = null;
                if (chosenTroop == 0)
                {
                    troop = new ARM_1(1);
                }
                else if (chosenTroop == 1)
                {
                    troop = new ARM_2(1);
                }
                TroopManager.instance.listTroop.Add(troop);
                troop._SetPosition(_WorldToCell(Camera.main.ScreenToWorldPoint(Input.mousePosition)));
                troop._FindTarget();

                // Update number of left troop
                listTroopLeft[chosenTroop]--;
                _UpdateChosenTroop();
            }
        }
    }
예제 #2
0
        public IEnumerator _GetUserTrooper(int userID, Action <bool> callBack)
        {
            string url = string.Format(API.LOAD_USER_TROOPER, userID);

            yield return(null);

            _instance.StartCoroutine(APIRequest.Instance.doGet(url, (rp) =>
            {
                if (rp != null)
                {
                    if (rp.StatusCode == API.SUCCES_CODE)
                    {
                        for (int i = 0; i < rp.Response.AsArray.Count; i++)
                        {
                            int id = rp.Response.AsArray[i]["trooper"]["id"].AsInt;

                            if (id == 1)
                            {
                                int num = rp.Response.AsArray[i]["count"].AsInt;
                                for (int j = 0; j < num; j++)
                                {
                                    Troop troop = new ARM_1(i * 1000 + j, false);
                                    TroopManager.instance.listTroop.Add(troop);
                                }
                            }
                            else
                            {
                                int num = rp.Response.AsArray[i]["count"].AsInt;
                                for (int j = 0; j < num; j++)
                                {
                                    Troop troop = new ARM_2(i * 1000 + j, false);
                                    TroopManager.instance.listTroop.Add(troop);
                                }
                            }

                            // //Lấy số lượng lính
                            // Debug.Log(rp.Response.AsArray[i]["count"].AsInt);

                            // //Lấy thông tin lính
                            // Debug.Log(rp.Response.AsArray[i]["trooper"]["id"].AsInt);
                            // Debug.Log(rp.Response.AsArray[i]["trooper"]["name"].Value);
                            // Debug.Log(rp.Response.AsArray[i]["trooper"]["dame"].AsDouble);
                            // Debug.Log(rp.Response.AsArray[i]["trooper"]["speed"].AsDouble);
                            // Debug.Log(rp.Response.AsArray[i]["trooper"]["price"].AsInt);
                            // Debug.Log(rp.Response.AsArray[i]["trooper"]["spornTime"].AsDouble);
                            // Debug.Log(rp.Response.AsArray[i]["trooper"]["type"].AsInt);
                            // Debug.Log(rp.Response.AsArray[i]["trooper"]["rangeAttack"].AsDouble);
                            // Debug.Log(rp.Response.AsArray[i]["trooper"]["speedAttack"].AsDouble);
                            // Debug.Log(rp.Response.AsArray[i]["trooper"]["hp"].AsInt);
                        }
                        callBack(true);
                    }
                    else
                    {
                        callBack(false);
                    }
                }
            }));

            yield return(null);
        }