Ejemplo n.º 1
0
 //! Called by unity engine on start up to initialize variables.
 public void Start()
 {
     stateManager          = FindObjectOfType <StateManager>();
     powerReceiver         = gameObject.AddComponent <PowerReceiver>();
     computerContainerList = new List <InventoryManager>();
     spawnedConnectionList = new List <GameObject>();
     conduitItem           = GetComponentInChildren <ConduitItem>(true);
 }
Ejemplo n.º 2
0
 //! Moves dark matter from the conduit to a storage computer.
 private void OutputToStorageComputer()
 {
     outputID = outputObject.GetComponent <StorageComputer>().ID;
     if (outputObject.GetComponent <StorageComputer>().initialized == true)
     {
         if (storageComputerConduitItem == null)
         {
             GameObject storageComputerItemObject = Instantiate(storageComputerConduitItemObject, outputObject.transform.position, outputObject.transform.rotation);
             storageComputerItemObject.transform.parent = outputObject.transform;
             storageComputerConduitItem = storageComputerItemObject.GetComponent <ConduitItem>();
         }
         if (darkMatterAmount >= speed && connectionFailed == false && speed > 0)
         {
             connectionLine.enabled = true;
             connectionLine.SetPosition(1, outputObject.transform.position);
             bool itemAdded = false;
             foreach (InventoryManager manager in outputObject.GetComponent <StorageComputer>().computerContainers)
             {
                 if (itemAdded == false)
                 {
                     manager.AddItem("Dark Matter", speed);
                     if (manager.itemAdded == true)
                     {
                         itemAdded         = true;
                         darkMatterAmount -= speed;
                         if (storageComputerConduitItem != null)
                         {
                             if (storageComputerConduitItem.textureDictionary != null)
                             {
                                 storageComputerConduitItem.billboard.GetComponent <Renderer>().material.mainTexture = storageComputerConduitItem.textureDictionary["Dark Matter"];
                             }
                             storageComputerConduitItem.target = manager.gameObject;
                         }
                     }
                 }
             }
             if (storageComputerConduitItem != null)
             {
                 storageComputerConduitItem.active = true;
             }
             conduitItem.active                   = true;
             GetComponent <Light>().enabled       = true;
             GetComponent <AudioSource>().enabled = true;
             connectionLine.enabled               = true;
         }
     }
     else
     {
         if (storageComputerConduitItem != null)
         {
             storageComputerConduitItem.active = false;
         }
         conduitItem.active                   = false;
         GetComponent <Light>().enabled       = false;
         GetComponent <AudioSource>().enabled = false;
     }
 }
Ejemplo n.º 3
0
 //! Called by unity engine on start up to initialize variables.
 public void Start()
 {
     powerReceiver             = gameObject.AddComponent <PowerReceiver>();
     connectionLine            = gameObject.AddComponent <LineRenderer>();
     conduitItem               = GetComponentInChildren <ConduitItem>(true);
     stateManager              = FindObjectOfType <StateManager>();
     connectionLine.startWidth = 0.2f;
     connectionLine.endWidth   = 0.2f;
     connectionLine.material   = lineMat;
     connectionLine.loop       = true;
     builtObjects              = GameObject.Find("BuiltObjects");
 }
Ejemplo n.º 4
0
 //!Retrieves items from storage computers.
 private void RetrieveFromStorageComputer()
 {
     inputID = inputObject.GetComponent <StorageComputer>().ID;
     if (outputObject != null && inputObject.GetComponent <StorageComputer>().initialized == true)
     {
         if (outputObject.GetComponent <UniversalConduit>() != null)
         {
             outputID = outputObject.GetComponent <UniversalConduit>().ID;
             outputObject.GetComponent <UniversalConduit>().inputID = ID;
             outputObject.GetComponent <UniversalConduit>().speed   = speed;
             if (outputObject.GetComponent <UniversalConduit>().amount < 1)
             {
                 type.Clear();
                 int count = 0;
                 retrievingIce = false;
                 foreach (InventorySlot slot in GetComponent <InventoryManager>().inventory)
                 {
                     if (slot.amountInSlot > 0 && !type.Contains(slot.typeInSlot) && !type.Equals("") && !type.Equals("nothing") && retrievingIce == false)
                     {
                         if (slot.typeInSlot.Equals("Ice"))
                         {
                             type.Clear();
                             type.Add(slot.typeInSlot);
                             count++;
                             retrievingIce = true;
                         }
                         else
                         {
                             type.Add(slot.typeInSlot);
                             count++;
                             retrievingIce = false;
                         }
                     }
                 }
             }
             foreach (InventorySlot slot in GetComponent <InventoryManager>().inventory)
             {
                 if (slot.amountInSlot > 0 && !type.Contains(slot.typeInSlot) && !type.Equals("") && !type.Equals("nothing"))
                 {
                     type.Clear();
                 }
             }
             if (type.Count > 0)
             {
                 if (Vector3.Distance(transform.position, inputObject.transform.position) < 20)
                 {
                     inputLine.enabled = true;
                     inputLine.SetPosition(1, inputObject.transform.position);
                     bool foundItems  = false;
                     int  currentSlot = 0;
                     int  slotToUse   = 0;
                     if (foundItems == false)
                     {
                         foreach (InventoryManager manager in inputObject.GetComponent <StorageComputer>().computerContainers)
                         {
                             currentSlot = 0;
                             foreach (InventorySlot slot in manager.inventory)
                             {
                                 if (slot.typeInSlot.Equals(type[multipleItemIteration]))
                                 {
                                     if (slot.amountInSlot >= speed)
                                     {
                                         foundItems = true;
                                         storageComputerInventoryManager = manager;
                                         slotToUse = currentSlot;
                                     }
                                     else
                                     {
                                         outputObject.GetComponent <UniversalConduit>().speed = (int)outputObject.GetComponent <UniversalConduit>().amount;
                                     }
                                 }
                                 currentSlot++;
                             }
                         }
                     }
                     if (foundItems == true)
                     {
                         outputObject.GetComponent <UniversalConduit>().type = type[multipleItemIteration];
                         currentType = type[multipleItemIteration];
                         if (storageComputerInventoryManager.inventory[slotToUse].amountInSlot >= speed)
                         {
                             PlayerController player = GameObject.Find("Player").GetComponent <PlayerController>();
                             if (player.storageInventory != storageComputerInventoryManager || player.draggingItem == false)
                             {
                                 outputObject.GetComponent <UniversalConduit>().amount             += speed - heat;
                                 storageComputerInventoryManager.inventory[slotToUse].amountInSlot -= speed - heat;
                                 if (storageComputerInventoryManager.inventory[slotToUse].amountInSlot < 1)
                                 {
                                     storageComputerInventoryManager.inventory[slotToUse].typeInSlot = "nothing";
                                 }
                             }
                             if (storageComputerConduitItem == null)
                             {
                                 GameObject storageComputerItemObject = Instantiate(storageComputerConduitItemObject, outputObject.transform.position, outputObject.transform.rotation);
                                 storageComputerItemObject.transform.parent = outputObject.transform;
                                 storageComputerConduitItem = storageComputerItemObject.GetComponent <ConduitItem>();
                             }
                             else
                             {
                                 storageComputerConduitItem.startPosition = storageComputerInventoryManager.gameObject.transform.position;
                                 storageComputerConduitItem.target        = inputObject;
                                 if (storageComputerConduitItem.textureDictionary != null)
                                 {
                                     storageComputerConduitItem.billboard.GetComponent <Renderer>().material.mainTexture = storageComputerConduitItem.textureDictionary[type[multipleItemIteration]];
                                 }
                                 storageComputerConduitItem.active = true;
                             }
                             conduitItem.active             = true;
                             GetComponent <Light>().enabled = true;
                         }
                     }
                     else if (outputObject.GetComponent <UniversalConduit>().amount < 1)
                     {
                         multipleItemIteration += 1;
                         if (multipleItemIteration >= type.Count)
                         {
                             multipleItemIteration = 0;
                         }
                     }
                 }
                 else
                 {
                     inputLine.enabled = false;
                     if (storageComputerConduitItem != null)
                     {
                         storageComputerConduitItem.active = false;
                     }
                     conduitItem.active             = false;
                     GetComponent <Light>().enabled = false;
                 }
             }
             else
             {
                 if (storageComputerConduitItem != null)
                 {
                     storageComputerConduitItem.active = false;
                 }
                 conduitItem.active             = false;
                 GetComponent <Light>().enabled = false;
             }
         }
     }
     else
     {
         if (storageComputerConduitItem != null)
         {
             storageComputerConduitItem.active = false;
         }
         conduitItem.active             = false;
         GetComponent <Light>().enabled = false;
     }
 }