Advertisement
shadowplaycoding

P021_FleetManager

Jun 12th, 2017
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.08 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 BuildShip()
  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.             Fleet fleet = new Fleet("Fleet " + (fleetList.Count + 1), ship);
  37.  
  38.             fleetList.Add(fleet);
  39.  
  40.             GameObject shipObject = GameObject.CreatePrimitive(PrimitiveType.Cube);
  41.             shipObject.transform.position = PositionMath.RandomPosition(-50, 50);
  42.             shipObject.transform.parent = this.transform;
  43.  
  44.             fleetToObjectMap.Add(fleet, shipObject);
  45.  
  46.         }
  47.         else
  48.         {
  49.             Debug.Log("Not Enough Resourses!");
  50.         }
  51.  
  52.  
  53.     }
  54.  
  55.     public void DestroyShip()
  56.     {
  57.  
  58.     }
  59.  
  60.     public void DisableFleets()
  61.     {
  62.         this.gameObject.SetActive(false);
  63.     }
  64.  
  65.     public void EnableFleets()
  66.     {
  67.         this.gameObject.SetActive(true);
  68.     }
  69.  
  70.     /*
  71.     Copyright Shadowplay Coding 2017 - see www.shadowplaycoding.com for licensing details
  72.     Removing this comment forfits any rights given to the user under licensing.
  73.     */
  74.  
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement