Beispiel #1
0
    public override String ToString()
    {
        string pop      = String.Format("\nPopulation:    {0:N0}", Population.Pop);
        string wealth   = String.Format("\nWealth:        ${0:N2}", Wealth.RegionWealth);
        string income   = String.Format("\nIncome:        ${0:N2}", Income);
        string distance = String.Format("\nDistFrmCntr:   {0:f6}", DistanceFromCenter);

        string printstr = "Region Information:" +
                          pop +
                          wealth +
                          income +
                          "\nAmiability:    " + Amiability.AmiabilityLevel +
                          "\nTechLevel:     " + TechLevel +
                          //"\nWorldCulture:  " + WorldCulture +
                          distance +
                          "\nNclrWstlnd:    " + NuclearWasteland +
                          "\n" + RaceMakeup.ToString() +
                          "\n" + Weather.ToString() +
                          "\n" + Flora.ToString() +
                          "\n" + Fauna.ToString();

        return(printstr);
    }
Beispiel #2
0
 public void RemovePlant()
 {
     Destroy(flora.gameObject);
     flora = null;
 }
Beispiel #3
0
 void Start()
 {
     flora = null;
 }
Beispiel #4
0
 public AddEditFloraViewModel() : base(-1)
 {
     ValidInanimateTemplates = TemplateCache.GetAll <IInanimateTemplate>();
     ValidMaterials          = TemplateCache.GetAll <IMaterial>();
     DataObject = new Flora();
 }
Beispiel #5
0
 public void UpdateFlora(Flora f)
 {
     context.Entry(f).State = EntityState.Modified;
     context.SaveChanges();
 }
Beispiel #6
0
 public void AddFlora(Flora f)
 {
     context.Floras.Add(f);
     context.SaveChanges();
 }
Beispiel #7
0
 public void AddFlora(Flora f)
 {
     floras.Add(f);
 }
Beispiel #8
0
    static void Init()
    {
        Flora window = (Flora)EditorWindow.GetWindow(typeof(Flora));

        window.Show();
    }
Beispiel #9
0
    public void GenerateWorld()
    {
        globalGalaxyList = (GalaxyList)Resources.Load("Databases/GalaxyDatabase");


        // Initialisation des variables et de la grid
        Initialisation();

        if (planet.savedMapHeight.GetLength(0) == 0 || planet.savedMapMatrix == null)
        {
            planet.savedMapHeight     = new int[planet.horizontalSize + sizeInterpolation];
            planet.savedMapMatrix     = new int[planet.horizontalSize + sizeInterpolation, maximalHeight];
            planet.playerLastPosition = new Vector3(0, 0, 0);

            // Generation des vecteurs ainsi que de leur type de tile
            GenerateTileSettings();

            planet.tilesType = new List <TileBase> ();
            planet.tilesType.Insert(0, (TileBase)null);
            planet.tilesType.Add(planet.planetType.ruleTile);
            planet.tilesType.Add(planet.planetType.unbreakableTile);

            unbreakableTileID = 2;

            // Ajout des tiles indestructibles
            for (int i = 0; i < planet.savedMapMatrix.GetLength(0); i++)
            {
                planet.savedMapMatrix [i, 0] = unbreakableTileID;
            }

            Vector2[] octaveOffsets = new Vector2[3];

            InitVarCaves(ref octaveOffsets, planet.seedCave, 3, new Vector2(5f, 5f));

            float maxNoiseHeight = float.MinValue;
            float minNoiseHeight = float.MaxValue;

            float halfWidth  = 400 / 2f;
            float halfHeight = 100 / 2f;

            // Ajout des grottes
            AddPerlinNoiseCave(halfWidth, halfHeight, 20f, 3, 0.289f, 3f, octaveOffsets, maxNoiseHeight, minNoiseHeight, 0.0f, 0.30f, 0, planet.verticalSize / 2, Mathf.RoundToInt(planet.verticalSize * 0.05f));
            AddPerlinNoiseCave(halfWidth, halfHeight, planet.caveWidth, 3, 0.439f, 3f, octaveOffsets, maxNoiseHeight, minNoiseHeight, 0.23f, planet.caveQuantity, 0, 1, planet.verticalSize / 2);

            // Ajout des minerais
            foreach (Ore ore in planet.oreList)
            {
                octaveOffsets = new Vector2[3];
                InitVarCaves(ref octaveOffsets, ore.seedDeposit, 3, new Vector2(5f, 5f));
                planet.tilesType.Add(ore.tile);
                AddPerlinNoiseArea(halfWidth, halfHeight, ore.depositWidth, 3, 0.0f, 3f, octaveOffsets, maxNoiseHeight, minNoiseHeight, 0.0f, ore.depositRarity / 10f, planet.tilesType.Count - 1, ore.area);
            }

            planet.tilesType.Add(planet.planetType.chestSprite);

            int  nbTourDeBoucle = 0;
            int  startingPos;
            bool chestPosFounded;
            bool restart;

            // Ajout des coffres
            int numChest = 0;
            while (numChest < planet.numberOfChest)
            {
                startingPos = Mathf.RoundToInt(UnityEngine.Random.Range(0, planet.savedMapMatrix.GetLength(0) - 1));

                chestPosFounded = false;
                restart         = false;
                for (int i = startingPos; i < planet.savedMapMatrix.GetLength(0) && !chestPosFounded && !restart; i++)
                {
                    for (int j = 0; j < planet.savedMapHeight [i] && !chestPosFounded && !restart; j++)
                    {
                        if (planet.savedMapMatrix [i, j] == planet.tilesType.Count - 1)
                        {
                            restart = true;
                        }
                        else if (planet.savedMapMatrix [i, j] == 0)
                        {
                            planet.savedMapMatrix [i, j] = planet.tilesType.Count - 1;
                            chestPosFounded = true;
                            //print ("Chest placed !, [x,y] = ["+i+","+j+"]");
                        }
                    }
                }
                nbTourDeBoucle++;
                if (!restart)
                {
                    numChest++;
                }
            }

            // Ajout de la végétation
            List <int> allDifferentTreeSize = new List <int>();

            // Ajout à tilesType et sauvegarde des différentes tailles d'arbres
            for (int i = 0; i < planet.planetType.treeList.Count; i++)
            {
                Flora tree = planet.planetType.treeList [i];
                planet.tilesType.Add(tree.tree);
                if (!allDifferentTreeSize.Contains(tree.sizeX))
                {
                    AddSorted(allDifferentTreeSize, tree.sizeX);
                }
            }
            if (allDifferentTreeSize.Count > 0)
            {
                int largestTreeSize = allDifferentTreeSize[allDifferentTreeSize.Count - 1];

                // Calculer toutes les positions possibles
                for (int i = 0; i < planet.savedMapMatrix.GetLength(0) - largestTreeSize; i++)
                {
                    bool hasSpace = true;

                    int randomTreeSize = UnityEngine.Random.Range(0, allDifferentTreeSize.Count);

                    for (int k = 0; k < allDifferentTreeSize[randomTreeSize]; k++)
                    {
                        if (planet.savedMapMatrix [i + k, planet.savedMapHeight [i]] != 0 || planet.savedMapMatrix [i + k, planet.savedMapHeight [i] - 1] == 0)
                        {
                            hasSpace = false;
                            break;
                        }
                    }

                    if (hasSpace)
                    {
                        int randomStartNumber = UnityEngine.Random.Range(0, planet.planetType.treeList.Count);
                        int valueInArray      = randomStartNumber;
                        for (int j = 0; j < planet.planetType.treeList.Count; j++)
                        {
                            valueInArray = mod(j + valueInArray, planet.planetType.treeList.Count);
                            if (planet.planetType.treeList [valueInArray].sizeX == allDifferentTreeSize [randomTreeSize])
                            {
                                break;
                            }
                        }
                        planet.savedMapMatrix [i, planet.savedMapHeight [i]] = 100 + planet.tilesType.Count - planet.planetType.treeList.Count + valueInArray;
                        i += allDifferentTreeSize[randomTreeSize];
                    }
                }
            }

            float xPos = (planet.savedMapMatrix.GetLength(0) * frontGround.cellSize.x) / 2;
            int   numeroXdanslaliste = frontGround.WorldToCell(new Vector3(xPos, 0f, 0f)).x;
            int   numeroYdanslaliste = planet.savedMapHeight [numeroXdanslaliste];
            float yPos = numeroYdanslaliste * frontGround.cellSize.y;
            mainCharacter.transform.position = new Vector3(xPos, yPos + 0.9f, 0f);
        }
        else
        {
            mainCharacter.transform.position = new Vector3(planet.playerLastPosition.x, planet.playerLastPosition.y + 0.9f, planet.playerLastPosition.z);
        }

        /*
         * for (int i = 0; i < planet.savedMapMatrix.GetLength (0); i++)
         *      for (int j = planet.savedMapHeight [i] - 1; j >= planet.savedMapHeight [i] - fieldOfRender.y - 5; j--) {
         *              frontGround.SetTile (new Vector3Int (i, j, 0), planet.tilesType [planet.savedMapMatrix [i, j]]);
         *              frontGround.SetColliderType (new Vector3Int (i, j, 0), ColliderCheckNeighboor(i,j));
         *              if (j < planet.savedMapHeight [i] - 1)
         *                      backGround.SetTile (new Vector3Int (i, j, 0), planet.planetType.backgroundTile);
         *      }
         */
        currentPos = frontGround.WorldToCell(mainCharacter.transform.position);
    }
Beispiel #10
0
 public void UpdateFlora(Flora f)
 {
     floraRepository.UpdateFlora(f);
 }
Beispiel #11
0
 public void AddFlora(Flora f)
 {
     floraRepository.AddFlora(f);
 }