public static void AddItem(List<Baggrid> bgList, Baggrid bg) { bool have = false; if (bg.Item.ct == Item.CommonType.EQUIPMENT || bg.Item.ct == Item.CommonType.MERCENARY) { for (int i=0; i<bg.Num; i++) { bgList.Add (new Baggrid (bg.Item, 1)); } } else { for (int i=0; i<bgList.Count; i++) { if (bgList [i].Item.name.Equals (bg.Item.name)) { if (bgList [i].Num == 99) { continue; } bgList [i].Num += bg.Num; if (bgList [i].Num > 99) { bg.Num = bgList [i].Num - 99; bgList [i].Num = 99; } else { have = true; } } } if (!have) { bgList.Add (new Baggrid (bg.Item, bg.Num)); } } }
public void Login() { if (username.text.Trim ().Equals ("")) { ShowHint.Hint (StringCollection.NEEDUSERNAME); return; } if (password.text.Trim ().Equals ("")) { ShowHint.Hint (StringCollection.NEEDPASSWORD); return; } bool vali = false; //去服务器验证 vali = true; //如果成功 if (vali) { bool haveInfo = true; if (haveInfo) { //如果有玩家信息,加载并跳转城市场景 //从服务器端获取玩家数据初始化 gData.isPlayer = false; //初始的时候总是佣兵模式,玩家在线后与其他玩家组队,才会变成联机模式 gData.characterList = new List<Character> (); Equipment e = new Equipment (1, 2, 0, 0, Equipment.EquipPos.BODY, "2", "学者的思考", 1, 200); List<Equipment> eList = new List<Equipment> (); eList.Add (e); Character c = new Character (2000, 30, 100, 0, 0, "zhouhui", true, 50, 0, ProFactory.getPro ("Geomancer", "1"), 10, 0, eList, -1); HealthItem item = new HealthItem (Item.RangeType.SINGLE, 10, "1", "单体治疗药剂", 50); List<Baggrid> bgList = new List<Baggrid> (); Baggrid bg = new Baggrid (item, 2); bgList.Add (bg); // Equipment e2 = new Equipment(2,3,Equipment.EquipPos.BODY,"3","学者的幻想",1,500); // Baggrid bg2 = new Baggrid (e2, 1); // bgList.Add (bg2); c.BgList = bgList; gData.characterList.Add (c); Character c2 = new Character (0, 40, 100, 0, 0, "unity", false, 100, 100, ProFactory.getPro ("Settler", "1"), 1, 0, null, -1); gData.characterList.Add (c2); Application.LoadLevel ("city"); } else { //如果没有,跳转角色创建场景 Application.LoadLevel ("create"); } } else { ShowHint.Hint (StringCollection.INVALIDACCOUNT); } }
void ItemFall(string key) { //掉落****************************************************************************************** List<FallItem> itemList = fallList [key]; string itemGet = ""; for (int i=0; i<itemList.Count; i++) { if (GameUtil.RandomHappen (itemList [i].probability, 101)) { int num = Random.Range (itemList [i].minNum, itemList [i].maxNum + 1); itemGet = itemGet + " " + itemList [i].item.name + "x" + num; Baggrid baggrid = new Baggrid (itemList [i].item, num); //加入背包(如果是雇佣兵模式,道具由玩家获得,如果是玩家最对模式,道具将roll获取) bool get = false; if (gData.isPlayer) { //弹出面板,roll //服务器返回队内其他玩家的roll值,判定 //如果roll 到 get设置为true } else { get = true; } if (get) { BagUtil.AddItem (gData.characterList [0].BgList, baggrid); } } } if (itemGet.Equals ("")) { ShowHint.Hint (StringCollection.DIGNOTHING); } else { ShowHint.Hint (StringCollection.ITEMGET + ":" + itemGet); } //*********************************************************************************************** }
public void InitBag(string shopType) { if (!init) { //init all grid for (int i=0; i<gridRow; i++) { for (int j=0; j<gridCol; j++) { GameObject gridO = Instantiate (grid, new Vector3 (firstX + j * (border + gridSize), firstY - i * (border + gridSize), 0), Quaternion.identity) as GameObject; gridO.transform.SetParent (transform); grids.Add (gridO); } } init = true; } for (int i=0; i<grids.Count; i++) { if (grids [i].transform.childCount > 0) Destroy (grids [i].transform.GetChild (0).gameObject); } List<Baggrid> bgList = new List<Baggrid> (); //获得商店物品列表 switch (shopType) { case "item": HealthItem item = new HealthItem (Item.RangeType.SINGLE, 10, "1", "单体治疗药剂", 50); Baggrid bg = new Baggrid (item, 0); bgList.Add (bg); Equipment e2 = new Equipment (2, 3, 0, 0, Equipment.EquipPos.BODY, "3", "学者的幻想", 1, 500); Baggrid bg2 = new Baggrid (e2, 0); bgList.Add (bg2); break; case "mercenary": Character c = new Character (0, 500, 500, 0, 0, "潘子", false, 500, 500, ProFactory.getPro ("Settler", "100"), 1, 0, null, -1); Mercenary m = new Mercenary (c); Baggrid bg3 = new Baggrid (m, 0); bgList.Add (bg3); break; } for (int i=0; i<bgList.Count; i++) { Baggrid bg = bgList [i]; GameObject itemO = Instantiate (itemPrefab, new Vector3 (grids [i].transform.position.x, grids [i].transform.position.y, 0), Quaternion.identity) as GameObject; itemO.GetComponent<Image> ().sprite = Resources.Load <Sprite> (bg.Item.prefabName); itemO.GetComponent<UI_Item> ().Bg = bg; itemO.GetComponent<UI_Item> ().fromShop = true; string num = bg.Num.ToString (); if (num.Equals ("0")) { num = ""; } itemO.transform.FindChild ("Num").GetComponent<Text> ().text = num; itemO.transform.SetParent (grids [i].transform); } }
public BattleOp(GameObject from, List<GameObject> to, Baggrid bg) { this.from = from; this.to = to; this.bg = bg; }
public Action(UI_Battle.Op op, Baggrid bg) { this.op = op; this.bg = bg; }