ANIMALS
How do I use A N I M A L S
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: Animal.cs
Copy
77 public void setAnimalName(string animalName)
78 {
79 shadowSprite = Resources.Load
80 }
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: Animal.cs
Copy
453 public void setStand(bool isStand, float standTime, string state_key)
454 {
455 this.isStanding = isStand;
456 this.standTime = standTime;
457 changeToState(state_key);
458 if (isStand)
459 {
460 gameObject.layer = LayerMask.NameToLayer("AnimalStand");
461 //gameObject.GetComponent
462 }
463 else
464 {
465 gameObject.layer = LayerMask.NameToLayer("Animal" + (animalIndex + 1));
466 //gameObject.GetComponent
467 }
468 }
File name: Animals.cs
Copy
14 public void Start()
15 {
16 string[] names = new string[] { "dog", "monkey", "pig", "fox", "giraffe", "panda", "rhino", "tiger", "elephant", "lion" };
17
18 animals = new List
19 int animalIndex = 0;
20
21 UpgradeInfo upgradeInfo = new UpgradeInfo();
22
23 GameObject animalPlayer = (GameObject)Instantiate(Resources.Load
24 animalPlayer.transform.parent = gameObject.transform;
25 animalPlayer.transform.localPosition = new Vector3(-3.5f + 0.7f * animalIndex, -0.9f, 0);
26 setSortingLayer(animalPlayer, "Animal8");
27 Animal player = animalPlayer.AddComponent
28 player.setAnimalName(names[Attr.currentAnimal]);
29 player.animalIndex = animalIndex;
30 player.gameScreen = gameScreen;
31 float speedPlayer = upgradeInfo.getItem(Attr.currentAnimal, 0, false);
32 float jumpPlayer = upgradeInfo.getItem(Attr.currentAnimal, 1, false);
33 player.setAnimalProperties(speedPlayer, jumpPlayer);
34 animalPlayer.layer = LayerMask.NameToLayer("Animal1");
35
36 animals.Add(animalPlayer);
37 animalIndex++;
38
39 animalPlayer.GetComponent
40 //animalPlayer.GetComponent
41
42 TextAsset xml = Resources.Load
43 XmlDocument xmlDoc = new XmlDocument();
44 xmlDoc.Load(new StringReader(xml.text));
45
46 XmlNodeList xmlNodeList = xmlDoc.DocumentElement.ChildNodes;
47 XmlNodeList levelNodeList = xmlNodeList.Item(Attr.currentLevel).ChildNodes;
48 for (int i = 0; i < levelNodeList.Count; i++)
49 {
50 int numberAnimal = int.Parse(levelNodeList.Item(i).Attributes.Item(0).Value);
51 string animalName = levelNodeList.Item(i).Attributes.Item(1).Value.ToLower();
52
53 for (int k = 0; k < numberAnimal; k++)
54 {
55 GameObject animalObject = (GameObject)Instantiate(Resources.Load
56 animalObject.transform.parent = gameObject.transform;
57 animalObject.transform.localPosition = new Vector3(-3.5f + 0.7f*animalIndex, -0.9f, 0);
58 setSortingLayer(animalObject, "Animal" + animalIndex);
59 Animal animal = animalObject.AddComponent
60 animal.setAnimalName(animalName.ToLower() + "_blue");
61 animal.animalIndex = animalIndex;
62 animal.gameScreen = gameScreen;
63 float speed = upgradeInfo.getSpeed(i);
64 float jump = upgradeInfo.getJump(i);
65 animal.setAnimalProperties(speed, jump);
66 animalObject.layer = LayerMask.NameToLayer("Animal" + (animalIndex + 1));
67 animals.Add(animalObject);
68 animalIndex++;
69
70 animalObject.GetComponent
71
72 //animalObject.GetComponent
73 }
74 }
75 }
File name: Animals.cs
Copy
87 public GameObject getAnimal(int animalIndex)
88 {
89 return animals[animalIndex];
90 }
File name: Animals.cs
Copy
92 public void setRunning(bool isRunning)
93 {
94 for (int i = 0; i < animals.Count; i++)
95 {
96 animals[i].GetComponent
97 }
98 }
File name: CameraController.cs
Copy
19 void Update()
20 {
21 if(animalPlayer == null){
22 animalPlayer = animals.getAnimal(0);
23 return;
24 }
25
26 if (animalPlayer.transform.localPosition.x >= -1)
27 transform.localPosition = new Vector3(animalPlayer.transform.localPosition.x + 1, 0, transform.localPosition.z);
28 }
File name: Dots.cs
Copy
16 public void Update()
17 {
18 GameObject player = animals.getAnimal(0);
19 dots[0].transform.localPosition = new Vector3(player.transform.localPosition.x * 4.2f / 225 - 2.9f, dots[0].transform.localPosition.y, dots[0].transform.localPosition.z);
20
21 animalX = player.transform.localPosition.x;
22 rankTemp = 8;
23
24 for (int i = 1; i < 8; i++)
25 {
26 GameObject animal = animals.getAnimal(i);
27 dots[i].transform.localPosition = new Vector3(animal.transform.localPosition.x * 4.2f / 225 - 2.9f, dots[i].transform.localPosition.y, dots[i].transform.localPosition.z);
28 if (animalX >= animal.transform.localPosition.x)
29 {
30 rankTemp--;
31 }
32 }
33 rankPlayer = rankTemp;
34 }
File name: GameScreen.cs
Copy
379 public void LateUpdate()
380 {
381 if (Input.GetMouseButtonDown(0) || Input.GetKeyDown(KeyCode.Space))
382 {
383 if (InputController.Name == InputNames.GAMESCREEN)
384 {
385 if (InputController.IsScreen)
386 {
387 if(Time.timeScale != 0)
388 animals.getAnimal(0).GetComponent
389 //createBuiTien(-1.2f, 1f);
390 }
391 }
392 }
393 else if (Input.GetMouseButtonUp(0))
394 {
395 InputController.IsScreen = true;
396 }
397 if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Backspace))
398 {
399 if (!isPrepare)
400 {
401 if (dialog != null && dialog.activeSelf && InputController.Name == InputNames.DIALOG)
402 {
403 dialog.GetComponent
404 pauseLayer.SetActive(true);
405 }else if (InputController.Name == InputNames.GAMESCREEN)
406 {
407 pauseGame();
408 dialog.GetComponent
409 pauseLayer.SetActive(false);
410 }
411 else if (pauseLayer.activeSelf)
412 {
413 resumeGame();
414 }
415 }
416 }
417 if (isPrepare)
418 {
419 isPrepare = false;
420
421 buttonSkills.setFonts(shopFont);
422 prepareGame();
423 }
424 }
File name: GameScreen.cs
Copy
526 public void pauseGame()
527 {
528 animals.setRunning(false);
529 background.setRuning(false);
530 InputController.Name = InputNames.DIALOG;
531 pauseLayer.SetActive(true);
532 isRunning = false;
533 revivalTask.setRunning(false);
534 setAnimationRunning(false);
535 setBulletRunning(false);
536 SoundManager.PauseMusic();
537 }
Download file with original file name:ANIMALS
ANIMALS 114 lượt xem
Gõ tìm kiếm nhanh...