Ejemplo n.º 1
0
 public void showNPCDesc(NPCParam nPC)
 {
     GameObject.Find("NameNPCDesc").GetComponent <Text>().text = nPC.NPCName;
     GameObject.Find("numNPCDesc").GetComponent <Text>().text  = nPC.numberOf.ToString();
     GameObject.Find("diffNPCDesc").GetComponent <Text>().text = nPC.difficulty.ToString();
     GameObject.Find("AiNPCDesc").GetComponent <Text>().text   = nPC.behaviorGraph.name;
 }
Ejemplo n.º 2
0
        public TerrainChunk(Vector2 coord, int size, Transform parent, Material material,
                            GameObject prefabWaterPlane, BuldingParam bldParam, GameObject prefabBulding,
                            NPCParam npc, GameObject prefabGuard)
        {
            this.prefabWaterPlane = prefabWaterPlane;
            this.prefabBulding    = prefabBulding;
            this.prefabGuard      = prefabGuard;

            position = coord * size;
            Vector3 positionV3 = new Vector3(position.x, 0, position.y);

            meshObject            = new GameObject("Terrain Chunk");
            meshRenderer          = meshObject.AddComponent <MeshRenderer>();
            meshFilter            = meshObject.AddComponent <MeshFilter>();
            meshRenderer.material = material;


            meshObject.transform.position   = positionV3 * scale;
            meshObject.transform.parent     = parent;
            meshObject.transform.localScale = Vector3.one * scale;

            GameObject water = Instantiate(prefabWaterPlane, meshObject.transform);

            water.transform.localScale = Vector3.one * MapGenerator.mapChunkSize / 10;

            CreateMapChunk(mapGenerator.GenerateMapData(position), position, bldParam, npc);
        }
Ejemplo n.º 3
0
    void CreateWorld()
    {
        int mid = Mathf.RoundToInt(numberOfChunk / 2);

        for (int i = 0; i < numberOfChunk; i++)
        {
            for (int j = 0; j < numberOfChunk; j++)
            {
                BuldingParam tmpBld = null;
                NPCParam     tmpNPC = null;
                if (setUp != null)
                {
                    float r = Random.Range(0f, 1f);
                    if (setUp.setOfBulding.buldings.Count > 0 && (r < 0.08 || ((numberOfChunk * numberOfChunk) - (i * numberOfChunk + j)) <= setUp.setOfBulding.buldings.Count))
                    {
                        tmpBld = setUp.setOfBulding.buldings[setUp.setOfBulding.buldings.Count - 1];
                        setUp.setOfBulding.buldings.RemoveAt(setUp.setOfBulding.buldings.Count - 1);

                        if (setUp.setOfNPC.NPCs.Count > 0)
                        {
                            tmpNPC = setUp.setOfNPC.NPCs[setUp.setOfNPC.NPCs.Count - 1];
                            setUp.setOfNPC.NPCs.RemoveAt(setUp.setOfNPC.NPCs.Count - 1);
                        }
                    }
                }
                TerrainChunk tmp = new TerrainChunk(new Vector2(i, j), chunkSize, transform, mapMaterial,
                                                    prefabWaterPlane, tmpBld, prefabBulding, tmpNPC, prefabGuard);
            }
        }
    }
Ejemplo n.º 4
0
 public void NameNPC(string s)
 {
     if (nextNPC == null)
     {
         nextNPC = new NPCParam();
     }
     nextNPC.NPCName = s;
 }
Ejemplo n.º 5
0
 virtual public void Awake()
 {
     // Set Param
     NPCParam     = new NPCParam();
     dialogSystem = new DialogSystem();
     // Instantiate Model
     NPCModel = Instantiate <GameObject>(NPCModelPrefab, gameObject.transform);
     NPCModel.GetComponent <Animator>().runtimeAnimatorController = NPCAnimator;
 }
Ejemplo n.º 6
0
 public void DifficultyNPC(float n)
 {
     if (nextNPC == null)
     {
         nextNPC = new NPCParam();
     }
     nextNPC.difficulty = Mathf.RoundToInt(n);
     GameObject.Find("TextDifficultyNPCSlider").GetComponent <Text>().text = n.ToString();
 }
Ejemplo n.º 7
0
    public void NumberNPC(string s)
    {
        if (nextNPC == null)
        {
            nextNPC = new NPCParam();
        }

        int n = -1;

        try
        {
            n = int.Parse(s, System.Globalization.CultureInfo.InvariantCulture);
        }
        catch (System.Exception)
        {
            n = -1;
        }

        nextNPC.numberOf = n;
    }
Ejemplo n.º 8
0
    public void CustomNPCButton()
    {
        selectedNPC         = new SetOfNPC();
        selectedNPC.setName = "";
        selectedNPC.NPCs    = new List <NPCParam>();
        nextNPC             = new NPCParam();
        NPCAIChoice.ClearOptions();
        List <string> tmp = new List <string>();

        foreach (RuntimeAnimatorController item in defaultNPCAI)
        {
            tmp.Add(item.name);
        }
        NPCAIChoice.AddOptions(tmp);
        GameObject tmpGO = GameObject.Find("AllNPCAIHolder");

        for (int a = tmpGO.transform.childCount - 1; a >= 0; a--)
        {
            Destroy(tmpGO.transform.GetChild(a));
        }
    }
Ejemplo n.º 9
0
        void CreateMapChunk(MapData mapData, Vector2 position, BuldingParam bldParam, NPCParam npc)
        {
            this.mapData = mapData;

            if (bldParam != null && !alreadyMaze)
            {
                alreadyMaze = true;
                GameObject bldGO = Instantiate(prefabBulding);
                bldGO.name = bldParam.buldingName;
                SetBuildingParam(bldGO.GetComponent <Building>(), bldParam);
                bldGO.transform.SetParent(meshObject.transform);
                bldGO.transform.localPosition = new Vector3(-bldParam.width, 2.5f, -bldParam.length);

                int half = MapGenerator.mapChunkSize / 2;
                for (int i = half - bldParam.width - 2; i < half + bldParam.width + 2; i++)
                {
                    for (int j = half - bldParam.length - 2; j < half + bldParam.length + 2; j++)
                    {
                        mapData.heighMap[i, j] = 0.55f;
                        mapData.colourMap[j * MapGenerator.mapChunkSize + i] = Color.grey;
                    }
                }
                if (npc != null)
                {
                    for (int i = 0; i < npc.numberOf; i++)
                    {
                        GameObject tmpNpc = Instantiate(prefabGuard);
                        tmpNpc.name = npc.NPCName;
                        tmpNpc.transform.SetParent(bldGO.transform);
                        tmpNpc.transform.localPosition = new Vector3(Random.Range(0, bldParam.width), 1.2f + 2.5f * Random.Range(0, bldParam.height), Random.Range(0, bldParam.length));
                    }
                }
            }

            Texture2D texture = TextureGenerator.TextureFromColourMap(mapData.colourMap, MapGenerator.mapChunkSize, MapGenerator.mapChunkSize);

            meshRenderer.material.mainTexture = texture;

            MeshData meshData = MeshGenerator.GenerateTerrainMesh(this.mapData.heighMap, mapGenerator.meshHeightMultiplier, mapGenerator.meshHeightCurve);

            meshFilter.mesh         = meshData.CreateMesh();
            meshCollider            = meshObject.AddComponent <MeshCollider>();
            meshCollider.sharedMesh = meshFilter.mesh;
        }