/// <summary> /// Creates the specified button. /// </summary> /// <param name="button">Button.</param> protected bool button(DrawString button) { if (checkMouseOver (button.x, button.y, button.width, button.height)) { //make button red button.SetColor (255, 0, 0); if (Input.GetMouseButtonDown (0)) { return true; } } else { //make button white button.SetColor (255, 255, 255); } return false; }
public LevelSelect() : base() { //Set the menu background Sprite background = new Sprite ("Sprites/bg.png"); AddChild (background); //render the game logo Sprite logo = new Sprite ("Sprites/logo.png"); logo.SetOrigin ((logo.width / 2), (logo.height / 2)); logo.SetXY (244, 130); AddChild (logo); //list of the level names _levelList = new LevelLister (); //list of level buttons _levelButtons = new List<DrawString> (); Console.WriteLine ("LevelSelect"); //add the menubuttons to the list int i = 275; foreach (string levelName in _levelList.GetLevels()) { _levelButtons.Add (new DrawString (levelName, 244, i, _font, _defaultColor)); i += 60; } //add menu buttons to an array _levelButtonsArray = _levelButtons.ToArray (); for (int k = 0; k < _levelButtonsArray.Length; k++) { AddChild (_levelButtonsArray [k]); } //draw the back button _backButton = new DrawString ("Back", 244, 615, _font, _defaultColor); AddChild (_backButton); }
void Start() { lines = GameObject.Find("LineRenderManager").GetComponent<LineRenderManager>(); strings = GetComponent<UnitBase>().lines.GetComponent<DrawString>(); currentMode = Modes.ATTACK; targets = new List<UnitBase>(); }
void Update() { currentId = 0; if(lines == null){ lines = GameObject.Find("LineRenderManager").GetComponent<LineRenderManager>(); strings = lines.GetComponent<DrawString>(); } // reset the start position penPosition = new Vector2(padding, Camera.main.pixelHeight-padding); }
void Awake() { DontDestroyOnLoad(gameObject); // setup the string art and the line art penPosition = new Vector2(0, Camera.main.pixelHeight); if(!GameObject.Find("LineRenderManager")){ Debug.LogError("Add a line renderer to the scene"); } penTransform = new GameObject().transform; DontDestroyOnLoad(penTransform); lines = GameObject.Find("LineRenderManager").GetComponent<LineRenderManager>(); strings = lines.GetComponent<DrawString>(); }
public Vector2 GetMeasurements(SpriteFont font) { Vector2 stringSize = DrawString.GetMeasurements(font); return(new Vector2(Selector.Size.X + stringSize.X + SpaceSelectorToString, Math.Max(Selector.Size.Y, stringSize.Y))); }
public Vector2 StringPosition(SpriteFont font) { return(new Vector2(Selector.Size.X + SpaceSelectorToString, (GetMeasurements(font).Y - DrawString.GetMeasurements(font).Y) / 2)); }