Beispiel #1
0
    private void Awake()
    {
        if (GameSingleton.Instance != null)
        {
            string enemyUID = GameSingleton.Instance.GetFishingEnemy();
            if (enemyUID == null)
            {
                gameObject.SetActive(false);
                return;
            }
            Time.timeScale = 0;

            GameSingleton.Instance.SetUIState(GameSingleton.UIState.GET_FISH);
            enemy = enemyPrefabController.ActiveUID(enemyUID);
            enemy.SetActive(true);
            enemy.GetComponent <Animator>().SetTrigger("Run");
            Enemy       enemyData  = DataSingleton.Instance.GetEnemy(enemyUID);
            EnemyDetail detailData = DataSingleton.Instance.EnemyDetailDataFromEnemy(enemyUID);

            coin.text     = enemyData.cost.ToString() + " UC";
            nameData.text = enemyData.name;

            if (detailData.gotPlayer)
            {
                newFind.SetActive(false);
            }
            else
            {
                newFind.SetActive(true);
            }
        }
    }
Beispiel #2
0
    public IEnumerator EnemyBornCorotine(EnemyBornMsg bornMsg, int bornPathID)
    {
        yield return(new WaitForSeconds(bornMsg.waitTime));

//                StartCoroutine(EachEnemyWave(bornMsg, bornPoint.pointId, bornPoint.pathId));


        if (bornMsg.enemys.Count < 1)
        {
            yield break;
        }
        if (bornMsg.enemys.Count == 1)
        {
            GameObject enemy     = AssestManager.Instance.LoadEnemy(bornMsg.enemys[0].type);
            BaseEnemy  baseEnemy = enemy.GetComponent <BaseEnemy>();
            baseEnemy.PathID = bornPathID;
            for (int i = 0; i < bornMsg.enemys[0].num; i++)
            {
                InstantiateEnemy(bornMsg.enemys[0].type, bornPathID);

                Debug.Log($"1  intervalTime {bornMsg.intervalTime}");
                yield return(new WaitForSeconds(bornMsg.intervalTime));
            }
        }
        else
        {
            for (int i = 0; i < bornMsg.enemys.Count; i++)
            {
                EnemyDetail enemy = bornMsg.enemys[i];
                StartCoroutine(YieldInstantiateEnemy(enemy.type, enemy.num, bornPathID));
                Debug.Log($"2  intervalTime {bornMsg.intervalTime}");
                yield return(new WaitForSeconds(bornMsg.intervalTime));
            }
        }
    }
 public void Initialize(EnemyDetail detailData, Enemy enemy)
 {
     UIDCODE           = detailData.UIDCODE;
     enemyID           = detailData.enemyID;
     enemyImage.sprite = Resources.Load <Sprite>(enemy.imagePath);
     enemyName.GetComponent <Text>().text   = enemy.name;
     enemyDetail.GetComponent <Text>().text = detailData.data;
 }
Beispiel #4
0
    private void CreateEnemyListener(EventData data)
    {
        EnemyDetail ed  = data.Param as EnemyDetail;
        Produce     pos = (Produce)Enum.Parse(typeof(Produce), ed.pos);
        Enemy       e   = BattleManager.Instance.GenerateEnemy(ed.characterId, pos);

        //初始化脚本
        e.Init(ed.characterId);
    }
Beispiel #5
0
    void OnGUI()
    {
        if (isFirstTime)
        {
            isFirstTime = false;
            prefabs     = Resources.LoadAll <GameObject>("Prefabs");

            Array.Resize(ref textureList, prefabs.Length);

            stageNum stageNum = stageNum.stage1;

            for (int i = 0; i < prefabs.Length; i++)
            {
                if (prefabs [i].GetComponent <SpriteRenderer> ())
                {
                    textureList [i] = prefabs [i].GetComponent <SpriteRenderer> ().sprite.texture;
                }
                else if (prefabs [i].GetComponentInChildren <SpriteRenderer> ())
                {
                    textureList [i] = prefabs [i].GetComponentInChildren <SpriteRenderer> ().sprite.texture;
                }
                else
                {
                    textureList [i] = null;
                }
            }

            foreach (GameObject obj in UnityEngine.Object.FindObjectsOfType(typeof(GameObject)))
            {
                if (obj.name == "gameStage1")
                {
                    stages [0] = obj;
                }
                if (obj.name == "gameStage2")
                {
                    stages [1] = obj;
                }
                if (obj.name == "gameStage3")
                {
                    stages [2] = obj;
                }
            }
        }
        if (EditorApplication.isPlaying)
        {
            isFirstTime = true;
        }
        if (!EditorApplication.isPlaying)
        {
            int mod    = textureList.Length % 5;
            int length = (textureList.Length - mod) / 5;

            GameObject   obj;
            GameObject[] sel = { null };

            // EditorGUILayoutの使用例.
            EditorGUILayout.LabelField("createEnemy");
            for (int j = 0; j < length; j++)
            {
                for (int i = 0; i < 5; i++)
                {
                    if (textureList [i + j * 5])
                    {
                        if (GUI.Button(new Rect(20.0f + i * 55.0f, 20.0f + j * 55.0f, 50.0f, 50.0f), textureList [i + j * 5]))
                        {
                            Debug.Log(prefabs [i + j * 5].name);
                            obj = GameObject.Instantiate(prefabs [i + j * 5].gameObject);
                            obj.transform.parent   = stages [stageIndex].transform;
                            obj.transform.position = stages [stageIndex].transform.position;
                            obj.name          = prefabs [i + j * 5].name;
                            sel [0]           = obj;
                            Selection.objects = sel;

                            currentSerchObject = obj;

                            SceneView.onSceneGUIDelegate += sceneView;

                            Undo.RegisterCreatedObjectUndo(obj, "object create");
                        }
                    }
                    else
                    {
                        if (GUI.Button(new Rect(20.0f + i * 55.0f, 20.0f + j * 55.0f, 50.0f, 50.0f), prefabs [i + j * 5].name))
                        {
                            Debug.Log(prefabs [i + j * 5].name);
                            obj = GameObject.Instantiate(prefabs [i + j * 5].gameObject);
                            obj.transform.parent   = stages [stageIndex].transform;
                            obj.transform.position = stages [stageIndex].transform.position;
                            obj.name          = prefabs [i + j * 5].name;
                            sel [0]           = obj;
                            Selection.objects = sel;

                            currentSerchObject = obj;

                            SceneView.onSceneGUIDelegate += sceneView;

                            Undo.RegisterCreatedObjectUndo(obj, "object create");
                        }
                    }
                }
            }
            for (int i = 0; i < mod; i++)
            {
                if (textureList [i + length * 5])
                {
                    if (GUI.Button(new Rect(20.0f + i * 55.0f, 20.0f + length * 55.0f, 50.0f, 50.0f), textureList [i + length * 5]))
                    {
                        Debug.Log(prefabs [i + length * 5].name);
                        obj = GameObject.Instantiate(prefabs [i + length * 5].gameObject);
                        obj.transform.parent   = stages [stageIndex].transform;
                        obj.transform.position = stages [stageIndex].transform.position;
                        obj.name          = prefabs [i + length * 5].name;
                        sel [0]           = obj;
                        Selection.objects = sel;

                        currentSerchObject = obj;

                        SceneView.onSceneGUIDelegate += sceneView;

                        Undo.RegisterCreatedObjectUndo(obj, "object create");
                    }
                }
                else
                {
                    if (GUI.Button(new Rect(20.0f + i * 55.0f, 20.0f + length * 55.0f, 50.0f, 50.0f), prefabs [i + length * 5].name))
                    {
                        Debug.Log(prefabs [i + length * 5].name);
                        obj = GameObject.Instantiate(prefabs [i + length * 5].gameObject);
                        obj.transform.parent   = stages [stageIndex].transform;
                        obj.transform.position = stages [stageIndex].transform.position;
                        sel [0]           = obj;
                        Selection.objects = sel;

                        currentSerchObject = obj;

                        SceneView.onSceneGUIDelegate += sceneView;

                        Undo.RegisterCreatedObjectUndo(obj, "object create");
                    }
                }
            }

            numtoint   = (stageNum)EditorGUI.EnumPopup(new Rect(20.0f, 20.0f + (1 + length) * 55.0f, 270.0f, 10.0f), "create on stage index", numtoint);
            stageIndex = (int)numtoint;

            createAreaIndex = EditorGUI.IntField(new Rect(20.0f, 20.0f + (1 + length) * 62.0f, 270.0f, 15.0f), "createAreaIndex", createAreaIndex);

            if (GUI.Button(new Rect(20.0f, 20.0f + (1 + length) * 69.0f, 270.0f, 50.0f), "SaveDataExport"))
            {
                stageData sd = new stageData {
                };
                sd.entryEnemy = new List <EnemyDetail> ();
                for (int i = 0; i < 3; i++)
                {
                    foreach (Transform child in stages[i].transform)
                    {
                        if (child.name != "defaultObject")
                        {
                            EnemyDetail ed = new EnemyDetail();
                            ed.prefabName = child.name;
                            ed.stageIndex = i;
                            ed.enemy_pos  = child.position;
                            ed.enemy_rot  = child.rotation;
                            ed.enemy_scl  = child.localScale;
                            sd.entryEnemy.Add(ed);
                        }
                    }
                }
                if (Resources.Load("stageData/stage" + createAreaIndex.ToString()))
                {
                    string a = "Resources/stageData/stage" + createAreaIndex.ToString();
                    AssetDatabase.DeleteAsset(a);
                }
                saveStageData.CreateAsset(sd, createAreaIndex);
                AssetDatabase.Refresh();
            }
        }
    }