Advertisement
shadowplaycoding

P030_FleetManager

Jul 20th, 2018
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.19 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5.  
  6. public class FleetManager : MonoBehaviour {
  7.  
  8.     public List<Fleet> fleetList;
  9.  
  10.     public Dictionary<Fleet, GameObject> fleetToObjectMap;
  11.  
  12.     int shipCount;
  13.  
  14.     // Use this for initialization
  15.     void Start () {
  16.         fleetList = new List<Fleet>();
  17.         fleetToObjectMap = new Dictionary<Fleet, GameObject>();
  18.     }
  19.  
  20.     public void CreateShip()
  21.     {
  22.         if (PlayerManager.PlayerManagerInstance.playerResources.credits >= 10
  23.         &&
  24.         PlayerManager.PlayerManagerInstance.playerResources.minerals >= 10)
  25.         {
  26.             // Subtract 10 Credits
  27.             PlayerManager.PlayerManagerInstance.playerResources.SubtractResource(1, 10);
  28.  
  29.             // Subtract 10 Minerals
  30.             PlayerManager.PlayerManagerInstance.playerResources.SubtractResource(2, 10);
  31.  
  32.             Debug.Log("You now have: " + PlayerManager.PlayerManagerInstance.playerResources.credits
  33.                 + " Credits and " + PlayerManager.PlayerManagerInstance.playerResources.minerals + " Minerals");
  34.  
  35.             Ship ship = new Ship("Ship " + shipCount, 10, 10);
  36.             SolarSystem.SolarSystemInstance.currentPlanet.starBase.buildCue.Add(ship);
  37.  
  38.             GUIManagementScript.GUIManagerInstance.UpdateShipProductionUI();
  39.         }
  40.         else
  41.         {
  42.             Debug.Log("Not Enough Resourses!");
  43.         }
  44.     }
  45.  
  46.  
  47.     public void BuildShip(Ship ship)
  48.     {
  49.         Fleet fleet = new Fleet("Fleet " + (fleetList.Count + 1), ship);
  50.  
  51.         fleetList.Add(fleet);
  52.  
  53.         GameObject shipObject = GameObject.CreatePrimitive(PrimitiveType.Cube);
  54.         shipObject.transform.position = PositionMath.RandomPosition(-50, 50);
  55.         shipObject.transform.localScale = new Vector3(0.2f,0.2f,0.2f);
  56.         shipObject.transform.parent = this.transform;
  57.  
  58.         fleetToObjectMap.Add(fleet, shipObject);
  59.     }
  60.  
  61.     public void DestroyShip()
  62.     {
  63.  
  64.     }
  65.  
  66.     public void DisableFleets()
  67.     {
  68.         this.gameObject.SetActive(false);
  69.     }
  70.  
  71.     public void EnableFleets()
  72.     {
  73.         this.gameObject.SetActive(true);
  74.     }
  75.  
  76.     /*
  77.     Copyright Shadowplay Coding 2017 - see www.shadowplaycoding.com for licensing details
  78.     Removing this comment forfits any rights given to the user under licensing.
  79.     */
  80.  
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement