shadowplaycoding

P003_Star

Sep 26th, 2019 (edited)
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Star
  6. {
  7.     public string Name {get; protected set;}
  8.     public int NumberOfPlanets {get; protected set;}
  9.  
  10.     public List<Planet> PlanetList;
  11.  
  12.     public Star(string name, int numberOfPlanets){
  13.         this.Name = name;
  14.         this.NumberOfPlanets = numberOfPlanets;
  15.        
  16.         this.PlanetList = new List<Planet>();
  17.         GenerateRandomPlanets();
  18.     }
  19.  
  20.     void GenerateRandomPlanets(){
  21.         for(int i=0; i < NumberOfPlanets; i++){
  22.            
  23.             string name = this.Name + " " + (i + 1);
  24.  
  25.             int random = Random.Range(1, 100);
  26.  
  27.             Planet planet = new Planet(name);
  28.             planet.SetPlanetType(random);
  29.             this.PlanetList.Add(planet);
  30.             Debug.Log("Planet: " + PlanetList[i].Name + " " + PlanetList[i].Type);
  31.  
  32.         }
  33.     }
  34. }
  35.  
  36. /*
  37. Copyright Shadowplay Coding 2021 - see www.shadowplaycoding.com for licensing details
  38. Removing this comment forfits any rights given to the user under licensing.
  39. */
Add Comment
Please, Sign In to add comment