void Win() { GameInfo.GetComponent <GameInfo> ().WinGame(); GameResult.SetActive(false); GetGold.SetActive(true); int GoldReword = GameInfo.GetComponent <GameInfo> ().StageList[GameInfo.GetComponent <GameInfo> ().StageLevel - 1].GoldReword; GetGold.GetComponent <Text> ().text = "获得" + GoldReword.ToString() + "金币\n请选择一张牌添加到牌库中"; string[] t = { "攻击", "防御", "技能" }; int point = Random.Range(1, AddCardLevel + 1); string type = t [Random.Range(0, 3)]; AddCardList.Add(new CardInfo(point, "剪", type)); point = Random.Range(1, AddCardLevel + 1); type = t [Random.Range(0, 3)]; AddCardList.Add(new CardInfo(point, "石", type)); point = Random.Range(1, AddCardLevel + 1); type = t [Random.Range(0, 3)]; AddCardList.Add(new CardInfo(point, "布", type)); Vector3 CPUCardPosition = new Vector3(-10, 0, 0); for (int i = 0; i < AddCardList.Count; i++) { GameObject CardObject_tmp = Instantiate(Card_Prefab, CPUCardPosition, Quaternion.identity); CardObject_tmp.GetComponent <Card> ().Init(AddCardList[i], true, "CPU", "AddCard"); AddCardObjectList.Add(CardObject_tmp); CPUCardPosition += new Vector3(10, 0, 0); } CancelAddCardButton.SetActive(true); }
void Start() { GameInfo = GameObject.Find("GameInfo"); if (GameInfo == null) { GameInfo = new GameObject("GameInfo"); GameInfo.AddComponent <GameInfo>(); Invoke("Start", 0.5f); return; } GameStage = "Init"; Player_Health = GameInfo.GetComponent <GameInfo> ().Player_MaxHealth; CPU_Health = GameInfo.GetComponent <GameInfo> ().CPU_MaxHealth; AddCardLevel = GameInfo.GetComponent <GameInfo> ().AddCardLevel; SkillList = GameInfo.GetComponent <GameInfo> ().SkillList; Player_Skill = SkillList[GameInfo.GetComponent <GameInfo> ().Player_SKill_Used]; PlayerSkillcard.GetComponent <SkillCard> ().Init(Player_Skill.Name, Player_Skill.Description); CPU_Skill = GameInfo.GetComponent <GameInfo> ().CPU_SKill_Used; CPUSkillcard.GetComponent <SkillCard> ().Init(CPU_Skill.Name, CPU_Skill.Description); Player_Armor = 0; CPU_Armor = 0; GameResult.SetActive(false); GetGold.SetActive(false); CancelAddCardButton.SetActive(false); for (int i = 0; i < GameInfo.GetComponent <GameInfo> ().Player_CardList.Count; i++) { Player_CardList.Add(GameInfo.GetComponent <GameInfo> ().Player_CardList [i]); } CPU_CardList = GameInfo.GetComponent <GameInfo> ().CPU_CardList; for (int i = 0; i < 5; i++) { int j = Random.Range(0, Player_CardList.Count); Player_CardListInGame.Add(Player_CardList [j]); Player_CardList.Remove(Player_CardList [j]); } for (int i = 0; i < 7; i++) { int j = Random.Range(0, CPU_CardList.Count); CPU_CardListInGame.Add(CPU_CardList [j]); CPU_CardList.Remove(CPU_CardList [j]); } CardInfo tmp; for (int i = 0; i < Player_CardListInGame.Count - 1; i++) { for (int j = Player_CardListInGame.Count - 1; j > i; j--) { if (Player_CardListInGame [j].Comparer(Player_CardListInGame [j - 1]) < 0) { tmp = Player_CardListInGame [j]; Player_CardListInGame [j] = Player_CardListInGame [j - 1]; Player_CardListInGame [j - 1] = tmp; } } } for (int i = 0; i < CPU_CardListInGame.Count - 1; i++) { for (int j = CPU_CardListInGame.Count - 1; j > i; j--) { if (CPU_CardListInGame [j].Comparer(CPU_CardListInGame [j - 1]) < 0) { tmp = CPU_CardListInGame [j]; CPU_CardListInGame [j] = CPU_CardListInGame [j - 1]; CPU_CardListInGame [j - 1] = tmp; } } } Bust_player = 0; Bust_player_last = 0; Bust_CPU = 0; Bust_CPU_last = 0; UpdateUI(); StartBP(); }