Runnable
How do I use Runnable
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: ResultLayer.cs
Copy
79 private void createGUI()
80 {
81 for (int i = 0; i < 3; i++)
82 {
83 if (i < star)
84 {
85 // stars[i].GetComponent
86 int temp = i;
87 stars[temp].GetComponent
88 new ActionDelay(0.4f + 0.6f * temp),
89 new ActionRunnable(delegate()
90 {
91 stars[temp].GetComponent
92
93 createStars(stars[temp].transform.localPosition, temp);
94 if (temp == star - 1)
95 {
96 showButtons(true);
97 }
98 })
99 ));
100 }
101 else
102 {
103 showButtons(false);
104 }
105 }
106 }
File name: Animal.cs
Copy
82 private void createShadow()
83 {
84 if (animalIndex != 0) return;
85 shadowCreateTime += Time.deltaTime;
86 if (shadowCreateTime >= 0.05f)
87 {
88 shadowCreateTime = 0;
89 GameObject shadowObject = new GameObject("Shadow");
90 shadowObject.transform.parent = gameScreen.shadowLayer.transform;
91 shadowObject.layer = LayerMask.NameToLayer("AnimalStand");
92 shadowObject.transform.localPosition = transform.localPosition + new Vector3(0, 0.3f, 0);
93 shadowObject.AddComponent
94 shadowObject.GetComponent
95 shadowObject.GetComponent
96 shadowObject.AddComponent
97 new ActionColorTo(0, 0, 0, 0, 0.5f),
98 new ActionRunnable(delegate ()
99 {
100 Destroy(shadowObject);
101 })
102 ));
103 }
104 }
File name: GameScreen.cs
Copy
460 public void addScore(int score, Vector3 position)
461 {
462 if (score == 5)
463 {
464 GameObject addScore = new GameObject("Score");
465 addScore.transform.parent = scoreLayer.transform;
466 addScore.transform.localPosition = new Vector3(position.x, position.y, -1);
467 addScore.AddComponent
468 addScore.layer = LayerMask.NameToLayer("Map");
469 addScore.GetComponent
470 addScore.AddComponent
471 Destroy(addScore, 1.5f);
472 }
473 else if (score == 10)
474 {
475 GameObject addScore = new GameObject("Score");
476 addScore.transform.parent = scoreLayer.transform;
477 addScore.transform.localPosition = new Vector3(position.x, position.y, -1);
478 addScore.AddComponent
479 addScore.layer = LayerMask.NameToLayer("Map");
480 addScore.GetComponent
481 addScore.AddComponent
482 new ActionMoveTo(position.x + 2, position.y + 1.5f, 1.5f),
483 new ActionRunnable(delegate() {
484 Destroy(addScore);
485 })
486 ));
487 // Destroy(addScore, 1.5f);
488 }
489 m_score += score;
490 }
File name: GameScreen.cs
Copy
492 public void eatSkillRandom(SkillType type, Vector3 position, int animalIndex)
493 {
494 if (animalIndex == 0)
495 {
496 if (useSkills)
497 {
498 GameObject skillRand = new GameObject("SkilRand");
499 skillRand.transform.parent = scoreLayer.transform;
500 skillRand.transform.localPosition = new Vector3(position.x, position.y, -1);
501 skillRand.AddComponent
502 skillRand.layer = LayerMask.NameToLayer("Map");
503 skillRand.GetComponent
504 skillRand.AddComponent
505 new ActionMoveTo(position.x + 3, position.y + 1.5f, 1.5f),
506 new ActionRunnable(delegate() {
507 Destroy(skillRand);
508 })
509 ));
510 skillRand.transform.localScale = new Vector3(0.5f, 0.5f, skillRand.transform.localScale.z);
511 //Destroy(skillRand, 1.5f);
512
513 buttonSkills.eateSkill(type);
514
515 addScore(5, position);
516 }
517 }
518 else
519 {
520 int ra = Random.Range(1, 100);
521 if(ra <= perSkills[Attr.currentLevel])
522 addSkill(type, animalIndex);
523 }
524 }
File name: LevelClickListener.cs
Copy
21 public override void OnTouchUp()
22 {
23 base.OnTouchUp();
24 Attr.currentLevel = levelIndex;
25 if (boardLevel.GetComponent
26 Destroy(boardLevel.GetComponent
27
28 boardLevel.AddComponent
29 new ActionScaleTo(0, 0, 0.5f, Interpolation.swingIn),
30 new ActionRunnable(new Runnable(delegate() { Application.LoadLevel("ShopScreen"); }))
31 ));
32
33 }
File name: MainMenuAnimals.cs
Copy
11 public void Start()
12 {
13 for (int i = 0; i < 3; i++)
14 animals[i].GetComponent
15
16 gameObject.AddComponent
17 delegate() {
18 SoundManager.LoadBgMusic("Sounds/menu", false);
19 SoundManager.playSound("Sounds/roga");
20 }
21 )));
22
23 float[] aY = new float[] { 0.01f, 0.01f, -0.02f };
24 float[] ds = new float[] { 0.2f, 0.4f, 0.3f };
25 for (int i = 0; i < 3; i++)
26 {
27 animals[i].GetComponent
28 new ActionMoveTo(animals[i].transform.localPosition.x, aY[i] + 0.1f, 1 + ds[i], Interpolation.sine),
29 new ActionMoveTo(animals[i].transform.localPosition.x, aY[i], 1 + ds[i], Interpolation.sine)
30 )));
31 }
32 }
File name: TouchText.cs
Copy
10 public void Start()
11 {
12 Data.InitData();
13 InputController.Enabled = false;
14
15 gameObject.GetComponent
16 new ActionDelay(2),
17 new ActionMoveTo(0, -1.85f, 0.1f, Interpolation.sine),
18 new ActionRunnable(delegate() { enableInput(); })
19 ));
20
21 text.GetComponent
22 new ActionRepeat(ActionRepeat.FOREVER, new ActionSequence(
23 new ActionColorTo(1, 1, 1, 1, 0.1f), new ActionColorTo(1, 1, 1, 0, 0.1f)
24 ))));
25 }
File name: BackShopButtonListener.cs
Copy
39 private void backPressed()
40 {
41 if (shopLayer.transform.localPosition.x == 0)
42 {
43 if (shopLayer.GetComponent
44 Destroy(shopLayer.GetComponent
45 shopLayer.AddComponent
46 new ActionScaleTo(0, 0, 0.5f, Interpolation.swingIn),
47 new ActionRunnable(new Runnable(delegate()
48 {
49 Application.LoadLevel("LevelScreen");
50 }))
51 ));
52 }
53 else if (shopLayer.transform.localPosition.x == -8)
54 {
55 shopLayer.SetActive(true);
56 if (shopLayer.GetComponent
57 Destroy(shopLayer.GetComponent
58 shopLayer.AddComponent
59
60 if (pickSkillLayer.GetComponent
61 Destroy(pickSkillLayer.GetComponent
62 pickSkillLayer.AddComponent
63 new ActionMoveTo(8, 0, 0.3f), new ActionRunnable(delegate() { pickSkillLayer.SetActive(false); })));
64 }
65 }
File name: NextShopButtonListener.cs
Copy
29 public override void OnTouchUp()
30 {
31 if (InputController.Name != InputNames.SHOP) return;
32 base.OnTouchUp();
33 if (shopLayer.GetComponent
34 Destroy(shopLayer.GetComponent
35 shopLayer.AddComponent
36
37 pickSkillLayer.SetActive(true);
38 if (pickSkillLayer.GetComponent
39 Destroy(pickSkillLayer.GetComponent
40 pickSkillLayer.AddComponent
41 }
Download file with original file name:Runnable
Runnable 126 lượt xem
Gõ tìm kiếm nhanh...