Advertisement
shadowplaycoding

P022_FleetManager

Jun 29th, 2017
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.15 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.localScale = new Vector3(0.2f,0.2f,0.2f);
  43.             shipObject.transform.parent = this.transform;
  44.  
  45.             fleetToObjectMap.Add(fleet, shipObject);
  46.  
  47.         }
  48.         else
  49.         {
  50.             Debug.Log("Not Enough Resourses!");
  51.         }
  52.     }
  53.  
  54.     public void DestroyShip()
  55.     {
  56.  
  57.     }
  58.  
  59.     public void DisableFleets()
  60.     {
  61.         this.gameObject.SetActive(false);
  62.     }
  63.  
  64.     public void EnableFleets()
  65.     {
  66.         this.gameObject.SetActive(true);
  67.     }
  68.  
  69.     /*
  70.     Copyright Shadowplay Coding 2017 - see www.shadowplaycoding.com for licensing details
  71.     Removing this comment forfits any rights given to the user under licensing.
  72.     */
  73.  
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement