shadowplaycoding

P003_Planet

Sep 26th, 2019 (edited)
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.86 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public enum PlanetType
  6. {
  7.     Barren,
  8.     GasGiant,
  9.     Terran
  10. }
  11.  
  12. public class Planet
  13. {
  14.     public string Name {get; protected set;}
  15.  
  16.     public PlanetType Type;
  17.    
  18.     public Planet(string name, PlanetType type = PlanetType.Barren){
  19.         this.Name = name;
  20.         this.Type = type;
  21.     }
  22.  
  23.     public void SetPlanetType(int number){
  24.  
  25.         if(number <= 20){
  26.             this.Type = PlanetType.Terran;
  27.         }
  28.         else if (number > 20 && number <= 60){
  29.             this.Type = PlanetType.Barren;
  30.         }
  31.         else {
  32.             this.Type = PlanetType.GasGiant;
  33.         }
  34.     }
  35. }
  36.  
  37. /*
  38. Copyright Shadowplay Coding 2021 - see www.shadowplaycoding.com for licensing details
  39. Removing this comment forfits any rights given to the user under licensing.
  40. */
Add Comment
Please, Sign In to add comment