コード例 #1
0
        void Awake()
        {
            if (instance != null)
            {
                Debug.Log("There can only be one...");
            }

            else
            {
                instance = this;
            }
        }
コード例 #2
0
 void initializeValues()
 {
     energyTransferRate          = 1f; //processors have a base eTR speed on one pulse per second
     energyCreationRate          = 2f; //processor have a base eCR of one energy every 2 seconds
     timeUntilNextPulse          = 0f; //start this at 0 so processor can imediatly lunch a pulse
     timeUntilNextEnergyCreation = 1f; //start this at one so there is a slight delay on the fist energy added
     targetCurrent = null;             //can't be too carful
     targetLast    = null;             //can't be too carful
     energyLineOne = null;
     attacker      = null;
     gameMaster    = gameMaster_Script.instance;           //singleton patter, making sure all objects referance the same instance gameMaster script
     underAttack   = false;
     rend          = gameObject.GetComponent <Renderer>(); //render attached to the processor used to set colour and material.
     startColor    = rend.material.color;                  //Setting the starting color to what ever the color the object starts
     Instantiate(processorUICanvasPrefab, transform);      //The UI element that displays the processor Energy
 }