From 178934547d835d28b628ccc884e20a5b23b437d4 Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 9 Aug 2021 20:00:32 +0800 Subject: =?UTF-8?q?+=E7=89=B9=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Hit & Slashes Vol.3/Demo Scene/GameManager.cs | 71 ++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 Assets/Art/Vfx/Hit & Slashes Vol.3/Demo Scene/GameManager.cs (limited to 'Assets/Art/Vfx/Hit & Slashes Vol.3/Demo Scene/GameManager.cs') diff --git a/Assets/Art/Vfx/Hit & Slashes Vol.3/Demo Scene/GameManager.cs b/Assets/Art/Vfx/Hit & Slashes Vol.3/Demo Scene/GameManager.cs new file mode 100644 index 00000000..80260507 --- /dev/null +++ b/Assets/Art/Vfx/Hit & Slashes Vol.3/Demo Scene/GameManager.cs @@ -0,0 +1,71 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class GameManager : MonoBehaviour { + public TextMesh text_fx_name; + public GameObject[] fx_prefabs; + public int index_fx = 0; + private Ray ray; + private RaycastHit2D ray_cast_hit; + + void Start () + { + text_fx_name.text = "[" + (index_fx + 1) + "] " + fx_prefabs[ index_fx ].name; + } + + void Update () + { + if (Input.GetMouseButtonDown (0)) + { + ray = Camera.main.ScreenPointToRay(Input.mousePosition); + ray_cast_hit = Physics2D.Raycast(new Vector2(ray.origin.x, ray.origin.y), new Vector2(0,0)); + if (ray_cast_hit) + { + switch(ray_cast_hit.transform.name){ + case "BG": + Instantiate(fx_prefabs[ index_fx ], new Vector3(ray.origin.x, ray.origin.y, 0), Quaternion.identity); + break; + case "UI-arrow-right": + ray_cast_hit.transform.SendMessage("Go"); + index_fx++; + if(index_fx >= fx_prefabs.Length) + index_fx = 0; + text_fx_name.text = "[" + (index_fx + 1) + "] " + fx_prefabs[ index_fx ].name; + break; + case "UI-arrow-left": + ray_cast_hit.transform.SendMessage("Go"); + index_fx--; + if(index_fx <= -1) + index_fx = fx_prefabs.Length - 1; + text_fx_name.text = "[" + (index_fx + 1) + "] " + fx_prefabs[ index_fx ].name; + break; + case "Instructions": + Destroy(ray_cast_hit.transform.gameObject); + break; + } + } + } + //Change-FX keyboard.. + if ( Input.GetKeyDown("z") || Input.GetKeyDown("left") ){ + GameObject.Find("UI-arrow-left").SendMessage("Go"); + index_fx--; + if(index_fx <= -1) + index_fx = fx_prefabs.Length - 1; + text_fx_name.text = "[" + (index_fx + 1) + "] " + fx_prefabs[ index_fx ].name; + } + + if ( Input.GetKeyDown("x") || Input.GetKeyDown("right")){ + GameObject.Find("UI-arrow-right").SendMessage("Go"); + index_fx++; + if(index_fx >= fx_prefabs.Length) + index_fx = 0; + text_fx_name.text = "[" + (index_fx + 1) + "] " + fx_prefabs[ index_fx ].name; + } + + if ( Input.GetKeyDown("space") ){ + Instantiate(fx_prefabs[ index_fx ], new Vector3(0, 0, 0), Quaternion.identity); + } + } + +} -- cgit v1.1-26-g67d0