コード例 #1
0
ファイル: Spawner.cs プロジェクト: Diik/pkmn-world
 public bool spawn(float lat, float lng)
 {
     map.Monster monster = getMonster(lat, lng);
     if (monster == null)
     {
         return(false);
     }
     GameObject.FindObjectOfType <Map>().Spawn(monster, lat, lng);
     return(true);
 }
コード例 #2
0
ファイル: Spawner.cs プロジェクト: Diik/pkmn-world
    private map.Monster getMonster(float lat, float lng)
    {
        MonsterInfo      info       = MonsterInfo.getMonsterInfo();
        List <string>    landuses   = landuseManager.getLanduse(lat, lng);
        List <string>    monsterIds = new List <string>();
        WeatherControler weatherCon = WeatherControler.getWeatherControler();
        string           time       = weatherCon.getTime();
        string           weather    = weatherCon.getWeather(lat, lng);

        if (weather == null || landuses == null)
        {
            return(null);
        }
        foreach (string landuse in landuses) //add monster that spawn cause of landuse
        {
            for (int i = 0; i < info.spawns[0][landuse][time][weather].Count; i++)
            {
                monsterIds.Add(info.spawns[0][landuse][time][weather][i]);
            }
        }
        int count = monsterIds.Count;

        for (int i = 0; i < info.spawns[1][time][weather].Count && monsterIds.Count < 3; i++) //if not enough variety, add some more
        {
            monsterIds.Add(info.spawns[1][time][weather][Random.Range(0, info.spawns[1][time][weather].Count)]);
        }
        for (int i = 0; i < count; i++)//prefer monster that spawned cause of landuse
        {
            for (int j = 0; j < System.Int32.Parse(MonsterInfo.getMonsterInfo().spawnData[monsterIds[i]]["rarity"].ToString().Replace("\"", "")); j++)
            {
                monsterIds.Add(monsterIds[i]);
            }
        }

        GameObject.Find("MonsterDex").transform.FindChild("Text").GetComponent <UnityEngine.UI.Text>().text = "wow";
        GameObject obj = GameObject.CreatePrimitive(PrimitiveType.Sphere);

        GameObject.Find("MonsterDex").transform.FindChild("Text").GetComponent <UnityEngine.UI.Text>().text = "SPHERE SUCKSSSSSSS";
        obj.AddComponent <Animation>();
        obj.AddComponent <MeshCollider>();
        map.Monster monster = obj.AddComponent <map.Monster>();
        monster.initiate(monsterIds[(int)Random.Range(0, monsterIds.Count)]);
        obj.GetComponent <Renderer>().material.color = monster.color;

        return(monster);
    }
コード例 #3
0
ファイル: Map.cs プロジェクト: Diik/pkmn-world
    /*
     * Spawns a monster on the map. It will add the monster as a child
     * to the Tile it tries to spawn on.
     */
    public void Spawn(map.Monster monster, float latitude, float longitude)
    {
        Vector2 tileCoords = Map.WorldToTileCoords(latitude, longitude);

        // Don't spawn if the tile is not in our active set
        if (!TileSet.ContainsKey(tileCoords))
        {
            return;
        }
        // Get the tile from our tileset
        Tile tile = TileSet[tileCoords].GetComponent <Tile>();

        // Attach our monster to the tile
        monster.transform.parent = tile.transform;
        Vector2 position = tile.BoundingBox.Interpolate(latitude, longitude);

        position.x = -position.x;
        monster.transform.position = new Vector3(position.x - tile.WorldPosition.x, 2.0f, position.y + tile.WorldPosition.z);
    }