Exemplo n.º 1
0
    // Update is called once per frame
    void FixedUpdate()
    {
        timeUntilRadar -= Time.deltaTime;
        if (timeUntilRadar <= 0)
        {
            timeUntilRadar = maxTimeBetweenRadar;
            for (int iStatIndex = 0; iStatIndex < levelGen.islandStats.Count; iStatIndex++)
            {
                IslandStats iStat = levelGen.islandStats[iStatIndex];

                for (int iIndex = 0; iIndex < iStat.islands.Count; iIndex++)
                {
                    IslandGen i = iStat.islands[iIndex];
                    if (Vector3.Distance(transform.position, i.transform.position) >= maxDistance)
                    {
                        i.SetFar(true);
                    }
                    else
                    {
                        i.SetFar(false);
                    }
                }
            }
        }
    }
Exemplo n.º 2
0
    public void GenerateIsland(int rings, float radius, float A, IslandStats i)
    {
        GameObject tempObject = (GameObject)GameObject.Instantiate(islandPrefab);

        tempObject.transform.parent = this.transform;

        IslandGen tempIsland = tempObject.GetComponent <IslandGen>();

        tempIsland.rings              = rings;
        tempIsland.size               = rings * 2 - 1;
        tempIsland.radius             = radius;
        tempIsland.bringInTime        = tempIsland.maxBringInTime;
        tempIsland.transform.rotation = Quaternion.Euler(new Vector3(Random.Range(0, 360), Random.Range(0, 360), Random.Range(0, 360)));
        //tempIsland.iStats = i;
        tempIsland.iStatsIndex = islandStats.IndexOf(i);
        //tempIsland.SetBaseHeight (i.baseLayerHeight);
        i.islands.Add(tempIsland);
        allIslands.Add(tempIsland);
        i.areaUsed           += A;
        tempIsland.randomSeed = (int)System.DateTime.Now.Ticks;


        NetworkServer.Spawn(tempIsland.gameObject);
    }
Exemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        Random.InitState(randomSeed);

        parentGen = GameObject.Find("Main").GetComponent <LevelGen>();
        iStats    = parentGen.islandStats[iStatsIndex];
        SetBaseHeight(iStats.baseLayerHeight);


        islandUpdater = GetComponent <IslandUpdater>();

        transform.position = Random.onUnitSphere;
        farHolder          = transform.Find("Far");
        closeHolder        = transform.Find("Close");

        cloudHolder            = transform.Find("CloudHolder");
        cloudHolder.localScale = Vector3.one * radius / 2;
        cloudCover             = cloudHolder.GetComponentInChildren <ParticleSystem>();
        cloudHolder.gameObject.SetActive(false); //TODO Re enable if this ever works well enough

        ParticleSystem.MainModule cloudCoverMain = cloudCover.main;
        cloudCoverMain.startSizeMultiplier *= radius;

        spin       = Random.Range(0.0f, 360.0f);
        spinSpeed  = Random.Range(-maxSpinSpeed, maxSpinSpeed);
        timeRecalc = Random.Range(0, parentGen.islandMoveIntervals);

        foreach (PerlinLayer layer in iStats.layerStats)
        {
            layer.Set(); //TODO maybe save seperatley incase we need to reaccess this (it will get overwritten by the next island)
        }

        GenerateLowQuality();
        tiles = new HexType[iStats.layerStats.Count + iStats.cityLayerStats.Count, size, size];
        GenerateBaseHexes();
        //TODO put in a loop
        if (iStats.cityLayerStats.Count != 0)
        {
            for (int index = 0; index < iStats.cityLayerStats.Count; index++)
            {
                iStats.cityLayerStats[index].GenerateHuts(iStats.layerStats.Count + index, tiles);
                iStats.cityLayerStats[index].GenerateConnections(iStats.layerStats.Count + index, tiles);
                iStats.cityLayerStats[index].RemoveSingleHuts(iStats.layerStats.Count + index, tiles);
                iStats.cityLayerStats[index].FillHoles(iStats.layerStats.Count + index, tiles);
                iStats.cityLayerStats[index].RemoveIfNoBottom(iStats.layerStats.Count + index, tiles);
                if (index != 0)
                {
                    iStats.cityLayerStats[index - 1].GenerateStairs(iStats.layerStats.Count + index - 1, tiles);
                }
                //iStats.cityLayerStats [index].RemoveSingleHuts (iStats.layerStats.Count + index, tiles);
            }
        }
        DrawBaseHexes();
        if (iStats.cityLayerStats.Count != 0)
        {
            DrawCityHexes();
        }

        CapsuleCollider cTemp = gameObject.GetComponent <CapsuleCollider>();

        cTemp.radius = radius + 5;
        cTemp.height = cTemp.radius * 2f;

        OcclusionArea oTemp = gameObject.GetComponent <OcclusionArea>();

        oTemp.size = Vector3.one * (radius + 1) * 2;

        islandUpdater.SetExpectedNumOfWeapons();

        //TODO Fix to allow more or less islands added.
        if (!isServer)
        {
            parentGen.islandStats[iStatsIndex].islands.Add(this);
            parentGen.AddOneIsland(this);
        }

        SetFar(true);

        Random.InitState((int)System.DateTime.Now.Ticks);

        if (isServer)
        {
            UpdateToSpherePosition(true);
        }
    }