Effects









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

Featured Snippets


File name: PhotonConverter.cs Copy
160     static void ConvertScripts(List scriptPathList)
161     {
162         bool ignoreWarningIsLogged = false;
163
164         foreach (string script in scriptPathList)
165         {
166             if (script.Contains("PhotonNetwork")) //Don't convert this file (and others)
167             {
168                 if (!ignoreWarningIsLogged)
169                 {
170                     ignoreWarningIsLogged = true;
171                     Debug.LogWarning("Conversion to PUN ignores all files with \"PhotonNetwork\" in their file-path.\nCheck: " + script);
172                 }
173                 continue;
174             }
175             if (script.Contains("Image Effects"))
176             {
177                 continue;
178             }
179
180             ConvertToPhotonAPI(script);
181         }
182
183         foreach (string script in scriptPathList)
184         {
185             AssetDatabase.ImportAsset(script, ImportAssetOptions.ForceUpdate);
186         }
187     }
File name: InstructionsScript.cs Copy
27  void OnGUI() {
28   if (this.gameScript.gameView == "instructions") {
29    GUI.skin = currentGUISkin;
30
31    this.gameScript.mainCamera.transform.eulerAngles = new Vector3 (120, 23, 0);
32
33    GUIStyle labelStyle = new GUIStyle(currentGUISkin.label);
34    labelStyle.alignment = TextAnchor.UpperLeft;
35    GUILayout.Label ("Instructions", "BigLabel");
36
37
38    scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width(Screen.width), GUILayout.Height(Mathf.Ceil(Screen.height * .80f)));
39
40    GUILayout.Label ("Object", "Subheader");
41
42    GUILayout.Label (@"The object of 2048-3D is to"
43                  + " slide numbered blocks in such a way"
44                  + " so that blocks with the same numbers collide"
45                  + " and combine into a new block that is twice"
46                  + " as much as the originals until"
47                  + " the number 2048 is reached.", labelStyle);
48
49    GUILayout.Label ("Moving the Blocks", "Subheader");
50
51    GUILayout.Label (@"You cannot move blocks individually, but must"
52                 + " move all blocks simultaneously in the same direction."
53                 + " Blocks can move forward, backward, up, down, left"
54     + " and right along the green connectors."
55           + " Simply swipe any part of the screen to move up,"
56     + " down, left or right (keyboard: arrow keys). To move the"
57     + " blocks forward and backward use the"
58     + " big red arrow keys at the bottom of the screen (keyboard: a and z keys)."
59     + " When moving, all blocks that can slide in the chosen direction will move."
60     + " Any block moving toward another block with the same number will collide "
61        + " and form a single block with twice the number as the originals", labelStyle);
62
63
64    GUILayout.Label ("New Blocks", "Subheader");
65
66    GUILayout.Label (@"After each move is"
67                 + " made a new block will appear randomly in an empty position."
68                 + " This block will have a number of either 2 or 4."
69        + " For an extra challenge, there is a game option you can"
70        + " set so that zeros can also be assinged to a new block."
71        + " Zeros act like any other number in that they can"
72        + " collide with other zeros to make a block twice as much "
73        + " (which is still zero).", labelStyle);
74
75
76
77    GUILayout.Label ("Scoring and Finishing", "Subheader");
78
79    GUILayout.Label(@"For every block collision that occurs you receive"
80                 + " the number of points of the newly"
81                 + " created block. If after making a move"
82                 + " all positions are filled and no new"
83                 + " moves are possible, the game ends."
84        + " A separate high score / highest block is kept for each"
85        + " distinct combination of game options", labelStyle);
86
87
88    GUILayout.Label ("Game Layout Options", "Subheader");
89
90    GUILayout.Label (@"When I first made this game there"
91            + " was only one game layout, a 3x3x3 cube."
92            + " After testing it a bit, it was way to easy"
93            + " so the zero option was added."
94            + " It was still way to easy "
95            + " (e.g. you could swipe without even looking and get pretty far)."
96            + " Therefore there are now several diffent game layouts that"
97            + " make the game more challenging and fun.", labelStyle);
98
99    GUILayout.Label ("Game Timer Option", "Subheader");
100
101    GUILayout.Label (@"To give yourself even more of a challenge"
102                     + " you can set game options to include a timer."
103                     + " If a timer is chosen you have a specific"
104                     + " amount of time to combined blocks to make the 64 block."
105                     + " If you run out of time the game is over."
106                     + " If you reach your target before the timer runs down you will"
107                     + " receive additional time to reach the next target."
108                     + " The time you received is as follows: \n"
109                     + " 64: option time + 5 seconds (because the first one is the hardest!)\n"
110                     + " 128: option time\n"
111                     + " 256: 2X option time\n"
112                     + " 512: 4X option time \n"
113                     + " 1024: 8X option time \n"
114                     + " you get the idea.", labelStyle);
115
116
117    GUILayout.Label ("Acknowledgements \nand Confessions", "Subheader");
118
119    GUILayout.Label (@"2048-3D is based upon the original" +
120                     " 2048 game designed by Gabriele Cirulli " +
121                     " \n\n" +
122                     " Sound effects by freeSFX http://www.freesfx.co.uk.\n\n" +
123                     " This game was designed using the Unity3D game engine.\n\n" +
124                     " FOR MORE PROJECTS VISIT:" +
125                     " https://code-projects.org/", labelStyle);
126
127
128    foreach (Touch touch in Input.touches) {
129     if (touch.phase == TouchPhase.Moved)
130     {
131      // dragging
132      this.scrollPosition.y += touch.deltaPosition.y;
133     }
134    }
135    GUILayout.EndScrollView();
136
137    if (GUILayout.Button ("Return to Menu")) {
138     this.gameScript.gameView = "menu";
139    }
140   }
141  }
File name: GameScreen.cs Copy
659         public void addSkill(SkillType type, int animalIndex)
660         {
661             switch (type)
662             {
663                 case SkillType.LUA:
664                     {
665                         GameObject bulletObject = (GameObject)Instantiate(Resources.Load("Bullets/LUA"));
666                         bulletObject.name = "Bullet";
667                         bulletObject.layer = LayerMask.NameToLayer("Animal" + (animalIndex + 1));
668                         bulletObject.transform.parent = bulletLayer.transform;
669                         GameObject animal = animals.getAnimal(animalIndex);
670                         bulletObject.transform.localPosition = new Vector3(animal.transform.localPosition.x, animal.transform.localPosition.y + 0.2f, bulletObject.transform.localPosition.z);
671                         Bullet bullet = bulletObject.GetComponent();
672                         bullet.animalIndex = animalIndex;
673                     }
674                     break;
675                 case SkillType.DONGBANG:
676                     {
677                         GameObject bulletObject = (GameObject)Instantiate(Resources.Load("Bullets/DONGBANG"));
678                         bulletObject.name = "Bullet";
679                         bulletObject.layer = LayerMask.NameToLayer("Animal" + (animalIndex + 1));
680                         bulletObject.transform.parent = bulletLayer.transform;
681                         GameObject animal = animals.getAnimal(animalIndex);
682                         bulletObject.transform.localPosition = new Vector3(animal.transform.localPosition.x, animal.transform.localPosition.y + 0.2f, bulletObject.transform.localPosition.z);
683                         Bullet bullet = bulletObject.GetComponent();
684                         bullet.animalIndex = animalIndex;
685                     }
686                     break;
687                 case SkillType.THIENTHACH:
688                     {
689                         for (int i = 0; i < 3; i++)
690                         {
691                             GameObject bulletObject = (GameObject)Instantiate(Resources.Load("Bullets/THIENTHACH"));
692                             bulletObject.name = "Bullet";
693                             bulletObject.layer = LayerMask.NameToLayer("Animal" + (animalIndex + 1));
694                             bulletObject.transform.parent = bulletLayer.transform;
695                             GameObject animal = animals.getAnimal(animalIndex);
696                             bulletObject.transform.localPosition = new Vector3(animal.transform.localPosition.x + 0.2f, animal.transform.localPosition.y + 0.4f, bulletObject.transform.localPosition.z);
697                             Bullet bullet = bulletObject.GetComponent();
698                             bullet.animalIndex = animalIndex;
699                         }
700                     }
701                     break;
702                 case SkillType.SET:
703                     {
704                         GameObject bulletObject = (GameObject)Instantiate(Resources.Load("Bullets/SET"));
705                         bulletObject.name = "Bullet";
706                         bulletObject.layer = LayerMask.NameToLayer("Animal" + (animalIndex + 1));
707                         bulletObject.transform.parent = bulletLayer.transform;
708                         GameObject animal = animals.getAnimal(animalIndex);
709                         bulletObject.transform.localPosition = new Vector3(animal.transform.localPosition.x + 0.2f, animal.transform.localPosition.y + 0.2f, bulletObject.transform.localPosition.z);
710                         Bullet bullet = bulletObject.GetComponent();
711                         bullet.animalIndex = animalIndex;
712                     }
713                     break;
714                 case SkillType.BOM:
715                     {
716                         GameObject bulletObject = (GameObject)Instantiate(Resources.Load("Bullets/BOM"));
717                         bulletObject.name = "Bullet";
718                         bulletObject.layer = LayerMask.NameToLayer("Animal" + (animalIndex + 1));
719                         bulletObject.transform.parent = bulletLayer.transform;
720                         GameObject animal = animals.getAnimal(animalIndex);
721                         bulletObject.transform.localPosition = new Vector3(animal.transform.localPosition.x , animal.transform.localPosition.y + 0.5f , bulletObject.transform.localPosition.z);
722                         Bullet bullet = bulletObject.GetComponent();
723                         bullet.animalIndex = animalIndex;
724                     }
725                     break;
726                 case SkillType.DOICHO:
727                     {
728                         GameObject bulletObject = (GameObject)Instantiate(Resources.Load("Bullets/DOICHO"));
729                         bulletObject.name = "Bullet";
730                         bulletObject.layer = LayerMask.NameToLayer("Animal" + (animalIndex + 1));
731                         bulletObject.transform.parent = bulletLayer.transform;
732                         GameObject animal = animals.getAnimal(animalIndex);
733                         bulletObject.transform.localPosition = new Vector3(animal.transform.localPosition.x + 0.3f, animal.transform.localPosition.y + 0.2f, bulletObject.transform.localPosition.z);
734                         Bullet bullet = bulletObject.GetComponent();
735                         bullet.animalIndex = animalIndex;
736                     }
737                     break;
738                 case SkillType.BAOVE:
739                     {
740                         Animal animal = animals.getAnimal(animalIndex).GetComponent();
741                         if (!animal.IsProtected)
742                         {
743                             GameObject effectObject = (GameObject)Instantiate(Resources.Load("Effects/BAOVE"));
744                             effectObject.name = "Effect";
745                             effectObject.transform.parent = effectLayer.transform;
746                             effectObject.GetComponent().mapObjectTransform = animal.gameObject.transform;
747                             animal.protectedEffect = effectObject.GetComponent();
748                         }
749                         else
750                         {
751                             animal.protectedEffect.stateTime = 5;
752                         }
753                         animals.getAnimal(animalIndex).GetComponent().setProtected();
754                     }
755                     break;
756                 case SkillType.TANGTOC:
757                     {
758                         GameObject effectObject = (GameObject)Instantiate(Resources.Load("Effects/TANGTOC"));
759                         effectObject.name = "Effect";
760                         effectObject.transform.parent = effectLayer.transform;
761                         effectObject.GetComponent().mapObjectTransform = animals.getAnimal(animalIndex).transform;
762                         animals.getAnimal(animalIndex).GetComponent().setSpeedUp();
763                     }
764                     break;
765             }
766         }
File name: GameScreen.cs Copy
809         public void AnimalcollisionWithBullet(GameObject animalObject, GameObject bulletObject)
810         {
811             if (animalObject.GetComponent().isStanding) return;
812             SkillType type = bulletObject.GetComponent().skillType;
813             int animalIndex = animalObject.GetComponent().animalIndex;
814             switch (type)
815             {
816                 case SkillType.LUA:
817                     {
818                         GameObject effectObject = (GameObject)Instantiate(Resources.Load("Effects/LUA"));
819                         effectObject.transform.parent = effectLayer.transform;
820                         effectObject.GetComponent().mapObjectTransform = animalObject.transform;
821                         Destroy(bulletObject);
822                         animalObject.GetComponent().setStand(true, 2, Animal.STATE_FIRE);
823                         animalObject.GetComponent().AddForce(new Vector2(0, -300));
824                         if (animalIndex == 0)
825                         {
826                             showRevivalTask(2, EmotionType.CUOIDEU);
827                         }
828                     }
829                     break;
830                 case SkillType.DONGBANG:
831                     {
832                         GameObject effectObject = (GameObject)Instantiate(Resources.Load("Effects/DONGBANG"));
833                         effectObject.transform.parent = effectLayer.transform;
834                         effectObject.GetComponent().mapObjectTransform = animalObject.transform;
835                         Destroy(bulletObject);
836                         animalObject.GetComponent().setStand(true,2, Animal.STATE_RUN);
837                         animalObject.GetComponent().AddForce(new Vector2(0, -300));
838                         if (animalIndex == 0)
839                         {
840                             showRevivalTask(2, EmotionType.HOAMAT);
841                         }
842                     }
843                     break;
844                 case SkillType.THIENTHACH:
845                     {
846                         {
847                             GameObject effectObject = (GameObject)Instantiate(Resources.Load("Effects/THIENTHACH"));
848                             effectObject.transform.parent = effectLayer.transform;
849                             effectObject.GetComponent().mapObjectTransform = animalObject.transform;
850                         }
851                         {
852                             GameObject effectObject = (GameObject)Instantiate(Resources.Load("Effects/CHOANG"));
853                             effectObject.transform.parent = effectLayer.transform;
854                             effectObject.GetComponent().mapObjectTransform = animalObject.transform;
855                         }
856                         Destroy(bulletObject);
857                         animalObject.GetComponent().setStand(true, 2, Animal.STATE_SHOCK);
858                         animalObject.GetComponent().AddForce(new Vector2(0, -300));
859                         if (animalIndex == 0)
860                         {
861                             showRevivalTask(2, EmotionType.HOAMAT);
862                         }
863                     }
864                     break;
865                 case SkillType.SET:
866                     {
867                         GameObject effectObject = (GameObject)Instantiate(Resources.Load("Effects/SET"));
868                         effectObject.transform.parent = effectLayer.transform;
869                         effectObject.GetComponent().mapObjectTransform = animalObject.transform;
870                         animalObject.GetComponent().setStand(true, 2, Animal.STATE_FIRE);
871                         animalObject.GetComponent().AddForce(new Vector2(0, -300));
872                         if (animalIndex == 0)
873                         {
874                             showRevivalTask(2, EmotionType.HOAMAT);
875                         }
876                     }
877                     break;
878                 case SkillType.BOM:
879                     {
880                         GameObject effectObject = (GameObject)Instantiate(Resources.Load("Effects/LUA"));
881                         effectObject.transform.parent = effectLayer.transform;
882                         effectObject.GetComponent().mapObjectTransform = animalObject.transform;
883                         Destroy(bulletObject);
884                         animalObject.GetComponent().setStand(true, 2, Animal.STATE_FIRE);
885                         animalObject.GetComponent().AddForce(new Vector2(0, -300));
886                     }
887                     break;
888                 case SkillType.DOICHO:
889                     {
890                         GameObject effectObject = (GameObject)Instantiate(Resources.Load("Effects/KHOI"));
891                         effectObject.transform.parent = effectLayer.transform;
892                         effectObject.GetComponent().mapObjectTransform = animalObject.transform;
893                         int animalIndexb = bulletObject.GetComponent().animalIndex;
894                         Destroy(bulletObject);
895                         GameObject animal2 = animals.getAnimal(animalIndexb);
896                         GameObject effectObject2 = (GameObject)Instantiate(Resources.Load("Effects/KHOI"));
897                         effectObject.transform.parent = effectLayer.transform;
898                         effectObject2.GetComponent().mapObjectTransform = animal2.transform;
899                         Vector3 p1 = animalObject.transform.localPosition;
900                         Vector3 p2 = animal2.transform.localPosition;
901                         animal2.transform.localPosition = new Vector3(p1.x, p1.y, p2.z);
902                         animalObject.transform.localPosition = new Vector3(p2.x, p2.y, p1.z);
903                     }
904                     break;
905             }
906         }

Download file with original file name:Effects

Effects 106 lượt xem

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