void readTouch()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Ray ray = Camera.mainCamera.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(ray, out hit))
            {
                if (hit.collider.gameObject.GetComponent <btnInfo>())
                {
                    touched_btn = hit.collider.gameObject.GetComponent <btnInfo>();

                    switch (touched_btn.type)
                    {
                    case "menu_btn":
                    {
                        _menu.animation.Play(touched_btn._anim.name);



                        break;
                    }

                    case "level_btn":
                    {
                        _level.animation.Play(touched_btn._anim.name);
                        break;
                    }
                    }
                }
            }
        }
    }
Example #2
0
    void get_touch()
    {
        if (Input.touchCount > 0)
        {
            for (int i = 0; i < Input.touchCount; i++)
            {
                Touch t = Input.GetTouch(i);

                if (t.phase == TouchPhase.Began)
                {
                    //limit touch



                    if ((current_power >= 2) && !level.stop)
                    {
                        current_power -= 2;
                        if (!level.stop)
                        {
                            Instantiate(touchEffect, new Vector2(Camera.main.ScreenToWorldPoint(t.position).x, Camera.main.ScreenToWorldPoint(t.position).y), Quaternion.identity);
                        }
                        audio.PlayOneShot(touchEffect_sound);
                    }
                    hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(t.position), Vector2.zero);
                    if (hit.collider != null)
                    {
                        if (hit.collider.gameObject.GetComponent <btnInfo>())
                        {
                            touched_btn = hit.collider.gameObject.GetComponent <btnInfo>();
                            switch (touched_btn.type)
                            {
                            case "menu_btn":
                            {
                                do_act(touched_btn.id);
                                if (touched_btn._anim.name != null)
                                {
                                    _menu.animation.Play(touched_btn._anim.name);
                                }
                                break;
                            }
                            }
                        }
                        else if (hit.collider.tag == "monster")
                        {
                            if (current_power >= 2)
                            {
                                hit.collider.transform.GetComponent <monster_behavior>().add_dammage();
                            }
                        }
                    }
                }
            }
        }
    }
Example #3
0
    void FindFbxFilesInDirectory()
    {
        List <string> fbxFiles = new List <string>();

        if (Application.platform == RuntimePlatform.Android)
        {
            foreach (string file in Directory.GetFiles(Application.persistentDataPath, "*.assetbundle"))
            {
                fbxFiles.Add(file);
            }
        }
        else if (Application.platform == RuntimePlatform.WindowsPlayer)
        {
            foreach (string file in Directory.GetFiles("file://" + Application.persistentDataPath + "/StreamingAssets/", "*.assetbundle"))
            {
                fbxFiles.Add(file);
            }
        }
        else if (Application.platform == RuntimePlatform.WindowsEditor)
        {
            print("here");
            foreach (string file in Directory.GetFiles(Application.streamingAssetsPath, "*.assetbundle"))
            {
                print(file);
                fbxFiles.Add(file);
            }
        }

        for (int i = 0; i < fbxFiles.Count; i++)
        {
            //print ("count is " + fbxFiles.Count);
            btnInfo temp = new btnInfo();
            temp.fileName = fbxFiles[i];
            temp.isLoaded = false;
            itemList.Add(temp);
        }
    }