Example #1
0
        public static void Initialize()
        {
            if (_instance == null)
            {
                /*
                 * GameObject gameController = GameObject.FindWithTag("GameController");
                 * _instance = gameController.AddComponent<PloppableTool>();
                 * _instance.name = "PloppableTool";
                 * _instance.DrawPloppablePanel();
                 * _instance.PopulateAssets();
                 * _instance.enabled = false;
                 * //GameObject.FindObjectOfType<ToolController>().Tools[0].enabled = true;
                 */
                try
                {
                    // Destroy the UI if already exists
                    //_gameObject = GameObject.Find("PloppableTool");
                    //Destroy();

                    // Creating our own gameObect, helps finding the UI in ModTools
                    _gameObject = new GameObject("PloppableTool");
                    _gameObject.transform.parent = UIView.GetAView().transform;
                    _instance = _gameObject.AddComponent <PloppableTool>();
                    //_instance.name = "PloppableTool";
                    _instance.DrawPloppablePanel();
                    _instance.PopulateAssets();
                    //_instance.enabled = false;
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                }
            }
        }
        /// <summary>
        /// Initializes the Ploppable Tool (including panel).
        /// </summary>
        internal static void Initialize()
        {
            // Don't do anything if we're already setup.
            if (_instance == null)
            {
                try
                {
                    // Creating our own gameObect helps finding the UI in ModTools.
                    _gameObject = new GameObject("PloppableTool");
                    _gameObject.transform.parent = UIView.GetAView().transform;

                    // Add tool and panel.
                    _instance = _gameObject.AddComponent <PloppableTool>();
                    _instance.DrawPloppablePanel();

                    // Deactivate to start with if we're speed boosting.
                    if (ModSettings.speedBoost)
                    {
                        _gameObject.SetActive(false);
                    }

                    // Initialise construction time dictionary.
                    _instance.constructionTimes = new Dictionary <BuildingInfo, int>();
                }
                catch (Exception e)
                {
                    Logging.LogException(e, "exception initializing ploppable tool");
                }
            }
        }
Example #3
0
 public static void Initialize()
 {
     if (_instance == null)
     {
         GameObject gameController = GameObject.FindWithTag("GameController");
         _instance      = gameController.AddComponent <PloppableTool>();
         _instance.name = "PloppableTool";
         _instance.DrawPloppablePanel();
         _instance.PopulateAssets();
         _instance.enabled = false;
         GameObject.FindObjectOfType <ToolController>().Tools[0].enabled = true;
     }
 }
 /// <summary>
 /// Initializes the Ploppable Tool (including panel).
 /// </summary>
 internal static void Initialize()
 {
     // Don't do anything if we're already setup.
     if (_instance == null)
     {
         try
         {
             // Creating our own gameObect helps finding the UI in ModTools.
             _gameObject = new GameObject("PloppableTool");
             _gameObject.transform.parent = UIView.GetAView().transform;
             _instance = _gameObject.AddComponent <PloppableTool>();
             _instance.DrawPloppablePanel();
             _instance.PopulateButtons();
         }
         catch (Exception e)
         {
             Debug.LogException(e);
         }
     }
 }