/// <summary> /// Will declare an entity in a container with a specific name and visibility /// </summary> /// <param name="to_declare">Type of the entity to declare</param> /// <param name="containerID">Identifier of the container in which declare the entity</param> /// <param name="name">Name of the declared entity</param> /// <param name="visibility">Visibility of the declared entity</param> /// <returns>Identifier of the freshly declared entity</returns> public UInt32 Declare(ENTITY to_declare, UInt32 containerID, string name, VISIBILITY visibility) { if (declarators.ContainsKey(to_declare)) { return(declarators[to_declare].Invoke(this, containerID, name, visibility)); } throw new KeyNotFoundException("No such declarator for ENTITY: " + to_declare.ToString()); }
//move off screen public void hide() { //not everything slides off the screen gracefully - here's the case for submenu items if (orientation == ORIENTATION.NONE) { position.X = -1000; position.Y = -1000; updateClickBox(); state = VISIBILITY.HIDDEN; return; } state = VISIBILITY.HIDING; if (orientation == ORIENTATION.TOP) { if (position.Y == (origin.Y - size.Y)) { state = VISIBILITY.HIDDEN; return; } //move 1 pixel up position.Y -= 1; } else if (orientation == ORIENTATION.RIGHT) { if (position.X == (origin.X + size.X)) { state = VISIBILITY.HIDDEN; return; } //move 1 pixel right position.X += 1; } else if (orientation == ORIENTATION.BOTTOM) { if (position.Y == (origin.Y + size.Y)) { state = VISIBILITY.HIDDEN; return; } //move 1 pixel down position.Y += 1; } else if (orientation == ORIENTATION.LEFT) { if (position.X == (origin.X - size.X)) { state = VISIBILITY.HIDDEN; return; } //move 1 pixel left position.X -= 1; } updateClickBox(); return; }
public HudElement() { name = ""; position = new Vector2(0, 0); origin = position; size = position; state = VISIBILITY.SHOWN; orientation = ORIENTATION.TOP; action = null; }
public HudText(Vector2 pos, Vector2 siz, VISIBILITY vis, ORIENTATION ort, SpriteFont fnt, string txt, Action a) { position = pos; origin = pos; size = siz; state = vis; orientation = ort; font = fnt; text = txt; action = a; }
//move on screen public void show() { //not everything slides onto the screen gracefully, here's the case for that... if (orientation == ORIENTATION.NONE) { position.X = origin.X; position.Y = origin.Y; updateClickBox(); state = VISIBILITY.SHOWN; return; } state = VISIBILITY.SHOWING; if (orientation == ORIENTATION.TOP) { if (position.Y == origin.Y) { state = VISIBILITY.SHOWN; return; } //move 1 pixel down position.Y += 1; } else if (orientation == ORIENTATION.RIGHT) { if (position.X == origin.X) { state = VISIBILITY.SHOWN; return; } //move 1 pixel left position.X -= 1; } else if (orientation == ORIENTATION.BOTTOM) { if (position.Y == origin.Y) { state = VISIBILITY.SHOWN; return; } //move 1 pixel up position.Y -= 1; } else if (orientation == ORIENTATION.LEFT) { if (position.X == origin.X) { state = VISIBILITY.SHOWN; return; } //move 1 pixel right position.X += 1; } updateClickBox(); }
public HudGraphic(string n, Vector2 pos, Vector2 siz, VISIBILITY vis, ORIENTATION ort, Texture2D tex, Action a) { name = n; position = pos; origin = pos; size = siz; state = vis; orientation = ort; texture = tex; action = a; //always not clicked on creation... clicked = false; //set up clickbox Point Pos = new Point((int)pos.X, (int)pos.Y); Point Size = new Point((int)size.X, (int)size.Y); clickBox = new Rectangle(Pos, Size); }
/// <summary> /// Change an entity visibility in a specific declarator /// </summary> /// <typeparam name="T">Type of the entity used in the declarator</typeparam> /// <param name="containerID">Identifier of the declarator in which change entity visibility</param> /// <param name="name">Name of the entity to which change visibility</param> /// <param name="newVisi">New visibility to set</param> public void ChangeVisibility(UInt32 containerID, string name, VISIBILITY newVisi) { GetDeclarator(containerID).ChangeVisibility(name, (CorePackage.Global.AccessMode)newVisi); }
public void setState(VISIBILITY newState) { state = newState; }