public void GenerateLoot(GameObject holder) { Holder chipHolder = holder.GetComponent <Holder>(); chipHolder.ClearChips(); //Easiest to get stats chips, medium to get attack chips, hard to get UI chips int StatsChipWeightage = ChipLibraryStats.Count * 3; int AttackChipsWeightage = ChipLibraryAttacks.Count * 2; //For this demo set Attack Chip Weightage to 0 int UIChipWeightage = ChipLibraryUI.Count * 1 * 0; //For this demo set UI Chip Weightage to 0 int MaxWeightage = StatsChipWeightage + AttackChipsWeightage + UIChipWeightage; int NumberOfChips = Random.Range(1, 4); for (int i = 0; i < NumberOfChips; ++i) { int ID = 0; int ChipWeightage = Random.Range(0, MaxWeightage); if (ChipWeightage >= StatsChipWeightage) { ChipWeightage -= StatsChipWeightage; ++ID; if (ChipWeightage >= UIChipWeightage) { ChipWeightage -= UIChipWeightage; ++ID; } } //Debug.Log("CHIP WEIGHTAGE" + ChipWeightage); //Debug.Log("TYPE" + ID); Chip newChip = new Chip(); switch (ID) { //Stats Chip case 0: newChip.CopyChip(ChipLibraryStats[ChipWeightage / 3]); break; case 1: newChip.CopyChip(ChipLibraryUI[ChipWeightage / 1]); break; case 2: newChip.CopyChip(ChipLibraryAttacks[ChipWeightage / 2]); break; default: break; } chipHolder.AddChip(newChip); } //chipHolder.AddChip(ChipLibraryStats[0]); //chipHolder.AddChip(ChipLibraryStats[1]); LootChips = chipHolder.Chips; }
public bool AddChip(Chip newChip) { if (CurChipSize + newChip.ChipSize > MaxChipSize) { return(false); } AttachedChips.Add(newChip); CurChipSize += newChip.ChipSize; SortChips(); DisplayChips(); return(true); }
/// <summary> /// 初始化 /// </summary> void Awake() { ins = this; Application.runInBackground = true; UserName.GetComponent <UILabel>().text = LoginInfo.Instance().mylogindata.username; // StartCoroutine(ShowImage()); for (int i = 0; i < ChipNumberBtn.Length; i++) { //ChipNumberBtn[i].transform.GetComponent<B>().onClick.add UIEventListener.Get(ChipNumberBtn[i]).onClick = OnClick; } for (int i = 0; i < btns.Length; i++) { UIEventListener.Get(btns[i].gameObject).onClick = OnChipClick; } // SetSprite(false); }
void CreateDefaultChips() { Chip newChip; foreach (Chip c in ChipLibraryUI) { //AddChip is not used here cause SortChips and DisplayChips will be called multiple times. This will be handled manually newChip = new Chip(); newChip.CopyChip(c); AttachedChips.Add(newChip); CurChipSize += newChip.ChipSize; } /* foreach (Chip c in ChipLibraryAttacks) * { * newChip = new Chip(); * newChip.CopyChip(c); * AttachedChips.Add(newChip); * } */ UpdateUIChips(); SortChips(); DisplayChips(); }
public void AddChip(Chip newChip) { Chips.Add(newChip); }
void TransferChip() { if (SelectedChipInventory != -1) { Chip newChip = new Chip(); newChip.CopyChip(AttachedChips[SelectedChipInventory]); CurChipSize -= newChip.ChipSize; LastDeadboi.GetComponent <ChipHolder>().Chips.Add(newChip); AttachedChips.RemoveAt(SelectedChipInventory); if (newChip.ChipType == Chip.CType.STAT) { UpdateStatsChips(); } else if (newChip.ChipType == Chip.CType.UI) { UpdateUIChips(); } DisplayChips(); DisplayLoot(LastDeadboi); SelectedChipInventory = -1; SelectedChipLoot = -1; } else if (SelectedChipLoot != -1) { //Chip chip = LootChips[selectedChip]; Chip chip = LastDeadboi.GetComponent <ChipHolder>().Chips[SelectedChipLoot]; //Debug.Log(selectedChip); bool success = AddChip(LootChips[SelectedChipLoot]); if (!success) { return; } if (chip.ChipType == Chip.CType.UI) { UpdateUIChips(); } else if (chip.ChipType == Chip.CType.STAT) { UpdateStatsChips(); } //instance.GetComponent<ChipHolder>().Chips.RemoveAt(selectedChip); LastDeadboi.GetComponent <ChipHolder>().Chips.RemoveAt(SelectedChipLoot); //LootChips.RemoveAt(selectedChip); foreach (Chip c in LastDeadboi.GetComponent <ChipHolder>().Chips) { if (c.ChipPosition > SelectedChipLoot) { --c.ChipPosition; } } DisplayLoot(LastDeadboi); SelectedChipInventory = -1; SelectedChipLoot = -1; } }