Choose









How do I use Choose
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: GameScreen.cs Copy
62         public void Start()
63         {
64             InputController.Name = InputNames.DIALOG;
65
66             string[] mapNames = new string[] {"jungle","southpole","desert","volcano"};
67             int[] lvs = new int[] { 1, 2, 3, 2, 3, 4, 3, 4, 5, 1, 2, 4, 3, 4, 5 };
68
69             Debug.Log("WorldIndex : " + Attr.currentWorld + ", LevelIndex : " + Attr.currentLevel);
70
71             mapObject = (GameObject)Instantiate(Resources.Load("Maps/" + mapNames[Attr.currentWorld] + lvs[Attr.currentLevel]), new Vector3(-4, 2.5f, 0), Quaternion.identity);
72             mapObject.transform.localScale = new Vector3(0.01f, 0.01f, mapObject.transform.localScale.z);
73
74             revivalPositions = new List();
75
76             getSkillChoosed();
77
78             setupMap(mapObject);
79
80             int mapLayer = LayerMask.NameToLayer("Map");
81             mapObject.layer = mapLayer;
82
83             Transform[] transforms = mapObject.GetComponentsInChildren(true);
84             for (int i = 0; i < transforms.Length; i++)
85             {
86                 transforms[i].gameObject.layer = mapLayer;
87             }
88
89             shopFont = new BitmapFont("Fonts/shop_font", "Fonts/shop_font_xml", null);
90
91             BitmapFont comboFont = new BitmapFont("Fonts/font_combo", "Fonts/font_combo_xml", null);
92             combo1.setFont(comboFont);
93             combo2.setFont(comboFont);
94
95             createDialog();
96
97             m_gold = 0;
98             m_time = 0;
99             m_score = 0;
100
101             perSkills = new int[] { 30, 30, 35, 35, 40, 40, 45, 45, 50, 55, 60, 60, 65, 65, 70 };
102
103             isRunning = true;
104             //prepareGame();//khong goi o day vi co the chua chay het cac ham Start
105             isPrepare = true;
106         }
File name: GameScreen.cs Copy
108         private void getSkillChoosed()
109         {
110             List sks = new List();
111             for (int i = 0; i < 3; i++)
112             {
113                 if (Attr.currentSkills[i] != -1)
114                 {
115                     sks.Add(Attr.currentSkills[i]);
116                 }
117             }
118             if (sks.Count > 0)//neu co chon skill
119             {
120                 useSkills = true;
121                 skills = new int[sks.Count];
122                 for (int i = 0; i < sks.Count; i++)
123                 {
124                     skills[i] = sks[i];
125                 }
126             }
127             else//neu khong chon skill thi lay tu cac skill unlock
128             {
129                 int[] unlockStars = new int[] { 0, 0, 35, 135, 15, 55, 75, 95 };
130
131                 int totalStar = 0;
132                 for (int i = 0; i < 60; i++)
133                     totalStar += Data.getData(Data.KEY_STAR + i);
134
135                 for (int i = 0; i < 8; i++)
136                 {
137                     if (totalStar >= unlockStars[i])
138                     {
139                         sks.Add(i);
140                     }
141                 }
142                 skills = new int[sks.Count];
143                 for (int i = 0; i < sks.Count; i++)
144                 {
145                     skills[i] = sks[i];
146                 }
147             }
148         }
File name: BoosterSpringsListener.cs Copy
26     public override void OnTouchUp()
27     {
28         if (InputController.Name != InputNames.SHOP) return;
29         chooseObject.transform.localPosition = new Vector3(gameObject.transform.localPosition.x, gameObject.transform.localPosition.y + 0.01f, chooseObject.transform.localPosition.z);
30         upgradeLayer.UpdateUI(itemIndex);
31     }
File name: BoosterSpringsListener.cs Copy
33  public void Start () {
34         if (chooseObject.GetComponent() == null)
35             chooseObject.AddComponent().addAction(new ActionRepeat(ActionRepeat.FOREVER, new ActionSequence(
36                 new ActionScaleTo(0.95f, 0.95f, 0.2f, Interpolation.swingOut),
37                 new ActionScaleTo(1, 1, 0.2f, Interpolation.swingOut)
38                 )));
39  }
File name: CirclesChoosed.cs Copy
16     public void choosedSkill(GameObject skillObject, int skillIndex, int starUnlock)
17     {
18         if (starUnlock > -1)
19             return;
20         SkillClickListener skillClick = skillObject.GetComponent();
21         if (skillClick.picked)//Neu da chon roi
22         {
23             skillClick.picked = false;
24             skillClick.transform.localPosition = skillClick.oldPosition;
25             skills[skillClick.cirlceIndex] = -1;
26         }
27         else//Neu chua chon
28         {
29             for (int i = 0; i < 3; i++)
30             {
31                 if (skills[i] == -1)
32                 {
33                     skillObject.transform.localPosition = new Vector3(circles[i].localPosition.x, circles[i].localPosition.y + 0.005f, skillObject.transform.localPosition.z);
34                     skills[i] = skillIndex;
35                     skillClick.picked = true;
36                     skillClick.cirlceIndex = i;
37                     break;
38                 }
39             }
40         }
41     }
File name: CirclesChoosed.cs Copy
43     public int[] getSkillChoosed()
44     {
45         return skills;
46     }
File name: PickLayer.cs Copy
55     private void addSkillClickListener(GameObject skillObject, int skillIndex, SkillDescription skillDes, Descriptions descriptions, int starUnlock)
56     {
57         skillObject.AddComponent();
58         SkillClickListener skillClickListemer = skillObject.AddComponent();
59         skillClickListemer.skillIndex = skillIndex;
60         skillClickListemer.skillDescription = skillDes;
61         skillClickListemer.descriptions = descriptions;
62         skillClickListemer.starUnlock = starUnlock;
63         skillClickListemer.circleChoosed = circleChoosed;
64     }
File name: PickPlayButton.cs Copy
71     public override void OnTouchUp()
72     {
73         if (InputController.Name != InputNames.SHOP) return;
74         base.OnTouchUp();
75
76         int[] skillChoosed = circleChoosed.getSkillChoosed();
77         bool hasSkill = false;
78         for (int i = 0; i < skillChoosed.Length; i++)
79         {
80             if (skillChoosed[i] > -1)
81             {
82                 hasSkill = true;
83                 break;
84             }
85         }
86
87         Attr.currentSkills = skillChoosed;
88         if (hasSkill)
89         {
90             SoundManager.stopMusic();
91             Application.LoadLevel("GameScreen");
92         }
93         else
94         {
95             dialog.GetComponent().showDialog();
96             InputController.Name = InputNames.DIALOG;
97         }
98     }
File name: ShopScreen.cs Copy
128     public void updateUI()
129     {
130         upgradeLayer.resetChooseItem();
131         buyLayer.setParams(upgradeInfo.getSpeed(Attr.currentAnimal), upgradeInfo.getJump(Attr.currentAnimal),
132             starCosts[Attr.currentAnimal], goldCosts[Attr.currentAnimal]);
133
134
135
136     }
File name: ShopScreen.cs Copy
144     {
145         int gold = Data.getData(Data.KEY_COIN);
146         Data.saveData(Data.KEY_COIN, gold - goldCosts[Attr.currentAnimal]);
147         Data.saveData(Data.KEY_ANIMAL_UNLOCK + Attr.currentAnimal, 1);
148         updateAnimalName();
149         updateUI();
150         upgradeLayer.resetChooseItem();
151     }

Download file with original file name:Choose

Choose 174 lượt xem

Gõ tìm kiếm nhanh...