//constructor public UIPeaceMakerActor(UIToolkit toolkit, string actorName, string fileName) { //todo make this scalable _height = 50; //background image size _width = 50; _touchFrame = new Rect ( position.x, -position.y, _width, _height ); //background image is always the same _actorBackground = toolkit.addSprite("actorBG.png", 0, 0); _actorBackground.parentUIObject = this; _actorBackground.positionFromTopLeft (0f, 0f); //gradient is always the same _actorGradient = toolkit.addSprite ("actor_gradient_white.png", 0, 0); _actorGradient.parentUIObject = this; _actorGradient.positionFromTopLeft (0f, 0f); //image and button _theButton = UIButton.create (toolkit, fileName, fileName, 0, 0); _theButton.parentUIObject = this; _theButton.onTouchUpInside += ( sender ) => randomAttitudeTest (); //up/down arrow is always the same _actorArrow = toolkit.addSprite ("up_arrow_anim_00.png", 0, 0); _actorArrow.parentUIObject = this; _actorArrow.positionFromTopRight (0f, 0f); _arrowUpAnim = _actorArrow.addSpriteAnimation ("arrowUpAnim", 0.1f, "up_arrow_anim_00.png", "up_arrow_anim_01.png", "up_arrow_anim_02.png", "up_arrow_anim_03.png", "up_arrow_anim_04.png", "up_arrow_anim_05.png", "up_arrow_anim_06.png", "up_arrow_anim_07.png", "up_arrow_anim_08.png", "up_arrow_anim_09.png"); _arrowDownAnim = _actorArrow.addSpriteAnimation ("arrowDownAnim", 0.1f, "down_arrow_anim_00.png", "down_arrow_anim_01.png", "down_arrow_anim_02.png", "down_arrow_anim_03.png", "down_arrow_anim_04.png", "down_arrow_anim_05.png", "down_arrow_anim_06.png", "down_arrow_anim_07.png", "down_arrow_anim_08.png", "down_arrow_anim_09.png"); _arrowUpAnim.loopReverse = true; _arrowDownAnim.loopReverse = true; hideAttitudeIndicators (); }
/// <summary> /// Initializes a new instance of the <see cref="UISlice9"/> class. /// </summary> /// <param name='manager'> /// Manager. /// </param> /// <param name='frame'> /// Frame. /// </param> /// <param name='depth'> /// Depth. /// </param> /// <param name='uvFrame'> /// Uv frame. /// </param> /// <param name='width'> /// Final width /// </param> /// <param name='height'> /// Final height /// </param> /// <param name='sTP'> /// Top Margin /// </param> /// <param name='sRT'> /// Right Margin /// </param> /// <param name='sBT'> /// Bottom Margin /// </param> /// <param name='sLT'> /// Left Margin /// </param> public UISlice9(UIToolkit manager, Rect frame, int depth, UIUVRect uvFrame, int width, int height, int sTP, int sRT, int sBT, int sLT) : base(frame, depth, uvFrame) { int stretchedWidth = width - (sLT + sRT); int stretchedHeight = height - (sTP + sBT); this.manager = manager; manager.addSprite(this); // Top Left spriteSlices[0] = new UISprite(new Rect(frame.x, frame.y, sLT, sTP), depth, new UIUVRect(uvFrame.frame.x, uvFrame.frame.y, sLT, sTP, manager.textureSize)); manager.addSprite(spriteSlices[0]); spriteSlices[0].parentUIObject = this; // Top Middle spriteSlices[1] = new UISprite(new Rect(frame.x + sLT, frame.y, stretchedWidth, sTP), depth, new UIUVRect(uvFrame.frame.x + sLT, uvFrame.frame.y, uvFrame.frame.width - (sRT + sLT), sTP, manager.textureSize)); manager.addSprite(spriteSlices[1]); spriteSlices[1].parentUIObject = this; // Top Right spriteSlices[2] = new UISprite(new Rect(frame.x + sLT + stretchedWidth, frame.y, sRT, sTP), depth, new UIUVRect(uvFrame.frame.x + sLT + (uvFrame.frame.width - (sRT + sLT)), uvFrame.frame.y, sRT, sTP, manager.textureSize)); manager.addSprite(spriteSlices[2]); spriteSlices[2].parentUIObject = this; // Middle Left spriteSlices[3] = new UISprite(new Rect(frame.x, frame.y + sTP, sLT, stretchedHeight), depth, new UIUVRect(uvFrame.frame.x, uvFrame.frame.y + sTP, sLT, uvFrame.frame.height - (sTP + sBT), manager.textureSize)); manager.addSprite(spriteSlices[3]); spriteSlices[3].parentUIObject = this; // Middle Middle spriteSlices[4] = new UISprite(new Rect(frame.x + sLT, frame.y + sTP, stretchedWidth, stretchedHeight), depth, new UIUVRect(uvFrame.frame.x + sLT, uvFrame.frame.y + sTP, uvFrame.frame.width - (sLT + sRT), uvFrame.frame.height - (sBT + sTP), manager.textureSize)); manager.addSprite(spriteSlices[4]); spriteSlices[4].parentUIObject = this; // Middle Right spriteSlices[5] = new UISprite(new Rect(frame.x + sLT + stretchedWidth, frame.y + sTP, sRT, stretchedHeight), depth, new UIUVRect(uvFrame.frame.x + (uvFrame.frame.width - sRT), uvFrame.frame.y + sTP, sRT, uvFrame.frame.height - (sBT + sTP), manager.textureSize)); manager.addSprite(spriteSlices[5]); spriteSlices[5].parentUIObject = this; // Bottom Left spriteSlices[6] = new UISprite(new Rect(frame.x, frame.y + sTP + stretchedHeight, sLT, sBT), depth, new UIUVRect(uvFrame.frame.x, uvFrame.frame.y + (uvFrame.frame.height - sBT), sLT, sBT, manager.textureSize)); manager.addSprite(spriteSlices[6]); spriteSlices[6].parentUIObject = this; // Bottom Middle spriteSlices[7] = new UISprite(new Rect(frame.x + sLT, frame.y + sTP + stretchedHeight, stretchedWidth, sBT), depth, new UIUVRect(uvFrame.frame.x + sLT, uvFrame.frame.y + (uvFrame.frame.height - sBT), uvFrame.frame.width - (sLT + sRT), sBT, manager.textureSize)); manager.addSprite(spriteSlices[7]); spriteSlices[7].parentUIObject = this; // Bottom Right spriteSlices[8] = new UISprite(new Rect(frame.x + sLT + stretchedWidth, frame.y + sTP + stretchedHeight, sRT, sBT), depth, new UIUVRect(uvFrame.frame.x + sLT + (uvFrame.frame.width - (sRT + sLT)), uvFrame.frame.y + (uvFrame.frame.height - sBT), sRT, sBT, manager.textureSize)); manager.addSprite(spriteSlices[8]); spriteSlices[8].parentUIObject = this; this.setSize(width, height); }
public UITexture( UIToolkit manager, Rect frame, int depth, UIUVRect uvFrame) : base(frame, depth, uvFrame) { _normalUVframe = uvFrame; manager.addSprite( this ); }
/// <summary> /// Convenience method to configure and optionally instantiate a new UISprite for a font character. /// </summary> private UISprite configureSpriteForCharId(UISprite sprite, int charId, float xPos, float yPos, float scale, int depth) { var uvRect = new UIUVRect((int)_textureOffset.x + _fontDetails[charId].posX, (int)_textureOffset.y + _fontDetails[charId].posY, _fontDetails[charId].w, _fontDetails[charId].h, _manager.textureSize); // NOTE: This contains a bugfix from the previous version where offsetx was being used // in the wrong spot according to the angelcode spec. xadvance is the complete character width // and offsetx is supposed to be used only during character rendering, not during cursor advance. // Please note that yPos already has offsety built in. var rect = new Rect(xPos + _fontDetails[charId].offsetx * scale, yPos, _fontDetails[charId].w, _fontDetails[charId].h); if (sprite == null) { sprite = new UISprite(rect, depth, uvRect, false); _manager.addSprite(sprite); } else { sprite.uvFrame = uvRect; sprite.position = new Vector3(rect.x, -rect.y, depth); sprite.setSize(rect.width, rect.height); } // We scale the sprite this way so it will work with the container clipping sprite.autoRefreshPositionOnScaling = false; sprite.scale = new Vector3(scale, scale, 1); return(sprite); }
public static UIGhostJoystick create(UIToolkit manager, string joystickFilename, Rect hitArea) { // create the joystrick sprite var joystick = manager.addSprite(joystickFilename, 0, 0, 1, true); return(new UIGhostJoystick(manager, hitArea, 1, joystick)); }
// public static UIJoystick create( UIToolkit manager, string joystickFilename, Rect hitAreaFrame, float xPos, float yPos ) { // create the joystrick sprite var joystick = manager.addSprite( joystickFilename, 0, 0, 1, true ); return new UIJoystick( manager, hitAreaFrame, 1, joystick, xPos, yPos ); }
public static UIGhostJoystick create( UIToolkit manager, string joystickFilename, Rect hitArea ) { // create the joystrick sprite var joystick = manager.addSprite( joystickFilename, 0, 0, 1, true ); return new UIGhostJoystick( manager, hitArea, 1, joystick); }
// public static UIJoystick create(UIToolkit manager, string joystickFilename, Rect hitAreaFrame, float xPos, float yPos) { // create the joystrick sprite var joystick = manager.addSprite(joystickFilename, 0, 0, 1, true); return(new UIJoystick(manager, hitAreaFrame, 1, joystick, xPos, yPos)); }
public void addBackgroundSprite(string filename) { var track = _manager.addSprite(filename, 0, 0, 2, true); track.parentUIObject = this; track.localPosition = new Vector3(_joystickOffset.x, _joystickOffset.y, 2); }
public UIProgressBar( UIToolkit manager, Rect frame, int depth, UIUVRect uvFrame, UISprite bar, bool rotated ) : base(frame, depth, uvFrame, rotated) { // Save the bar and make it a child of the container/border for organization purposes _bar = bar; _bar.parentUIObject = this; _barOriginalWidth = _bar.width; _barOriginalHeight = _bar.height; /* // Save the bars original size if (rotated) { _barOriginalWidth = _bar.width; _barOriginalHeight = _bar.height; } else { _barOriginalWidth = _bar.width; _barOriginalHeight = _bar.height; } */ /*if (!_rotated) normalFrame = new Rect( clientTransform.position.x, -clientTransform.position.y, width * touchesScale.x, height * touchesScale.y); else normalFrame = new Rect( clientTransform.position.x, -clientTransform.position.y - (width * touchesScale.y), height * touchesScale.x, width * touchesScale.y); */ _barOriginalUVframe = _bar.uvFrame; manager.addSprite( this ); }
public UIVerticalPanel( UIToolkit manager, string topFilename, string middleFilename, string bottomFilename ) : base( UILayoutType.Vertical ) { var texInfo = manager.textureInfoForFilename( topFilename ); _topStrip = manager.addSprite( topFilename, 0, 0, 5 ); _topStrip.parentUIObject = this; _topStripHeight = (int)texInfo.frame.height; _width = texInfo.frame.width; // we overlap the topStrip 1 pixel to ensure we get a good blend here _middleStrip = manager.addSprite( middleFilename, 0, _topStripHeight , 5 ); _middleStrip.parentUIObject = this; texInfo = manager.textureInfoForFilename( middleFilename ); _bottomStrip = manager.addSprite( bottomFilename, 0, 0, 5 ); _bottomStrip.parentUIObject = this; _bottomStripHeight = (int)texInfo.frame.height; }
// the bars x/y coordinates should be relative to the borders public static UIProgressBar create(UIToolkit manager, string barFilename, string borderFilename, int barxPos, int baryPos, int borderxPos, int borderyPos) { var bar = manager.addSprite(barFilename, borderxPos + barxPos, borderyPos + baryPos, 2); var borderTI = manager.textureInfoForFilename(borderFilename); var borderFrame = new Rect(borderxPos, borderyPos, borderTI.size.x, borderTI.size.y); return(new UIProgressBar(manager, borderFrame, 1, borderTI.uvRect, bar)); }
public UIBackgroundLayout( UIToolkit manager, string filename ) : base( UILayoutType.BackgroundLayout ) { background = manager.addSprite( filename, 0, 0, 2 ); addChild( background ); // set dimensions of container based on background texture dimensions _width = background.width; _height = background.height; }
public UIVerticalPanel(UIToolkit manager, string topFilename, string middleFilename, string bottomFilename) : base(UILayoutType.Vertical) { var texInfo = manager.textureInfoForFilename(topFilename); _topStrip = manager.addSprite(topFilename, 0, 0, 5); _topStrip.parentUIObject = this; _topStripHeight = (int)texInfo.frame.height; _width = texInfo.frame.width; // we overlap the topStrip 1 pixel to ensure we get a good blend here _middleStrip = manager.addSprite(middleFilename, 0, _topStripHeight, 5); _middleStrip.parentUIObject = this; texInfo = manager.textureInfoForFilename(middleFilename); _bottomStrip = manager.addSprite(bottomFilename, 0, 0, 5); _bottomStrip.parentUIObject = this; _bottomStripHeight = (int)texInfo.frame.height; }
public UIBackgroundLayout(UIToolkit manager, string filename) : base(UILayoutType.BackgroundLayout) { background = manager.addSprite(filename, 0, 0, 2); addChild(background); // set dimensions of container based on background texture dimensions _width = background.width; _height = background.height; }
// draw text on screen, create each quad and send it to the manager private int drawText(string text, float xPos, float yPos, float scale, int depth, Color color) { float dx = xPos; float dy = 0; float textWidth; float offsetY; int fontLineSkip = 0; int charId = 0; UISprite[] sprites = null; int length = text.Length; sprites = new UISprite[length]; for (var i = 0; i < text.Length; i++) { charId = System.Convert.ToInt32(text[i]); // "10" is the new line char if (charId == 10) { // calculate the size to center text on Y axis, based on its scale // 77 is the "M" char usually big enough to get a proper spaced // lineskip, use any other char if you want fontLineSkip += (int)(_fontDetails[77].h * scale * lineSpacing); dx = xPos; } else { // calculate the size to center text on Y axis, based on its scale offsetY = _fontDetails[charId].offsety * scale; dy = yPos + offsetY + fontLineSkip; } // add quads for each char var uvRect = new UIUVRect((int)_textureOffset.x + _fontDetails[charId].posX, (int)_textureOffset.y + _fontDetails[charId].posY, _fontDetails[charId].w, _fontDetails[charId].h, _manager.textureSize); sprites[i] = new UISprite(new Rect(dx, dy, _fontDetails[charId].w * scale, _fontDetails[charId].h * scale), depth, uvRect, false); _manager.addSprite(sprites[i]); sprites[i].color = color; // calculate the size to advance, based on its scale textWidth = _fontDetails[charId].xadvance * scale; // advance the position to draw the next letter dx += textWidth + _fontDetails[charId].offsetx; } // add all sprites at once to the array, we use this later to delete the strings _textSprites.Add(sprites); return(_textSprites.Count - 1); }
public UIProgressBar(UIToolkit manager, Rect frame, int depth, UIUVRect uvFrame, UISprite bar) : base(frame, depth, uvFrame) { // Save the bar and make it a child of the container/border for organization purposes _bar = bar; _bar.parentUIObject = this; // Save the bars original size _barOriginalWidth = _bar.width; _barOriginalUVframe = _bar.uvFrame; manager.addSprite(this); }
public UIVerticalPanel(UIToolkit manager, string topFilename, string middleFilename, string bottomFilename) : base(UILayoutType.Vertical) { var texInfo = manager.textureInfoForFilename(topFilename); _topStrip = manager.addSprite(topFilename, 0, 0, 5); _topStrip.parentUIObject = this; _topStripHeight = (int)texInfo.frame.height; _width = texInfo.frame.width; // we overlap the topStrip 1 pixel to ensure we get a good blend here _middleStrip = manager.addSprite(middleFilename, 0, _topStripHeight, 5); _middleStrip.parentUIObject = this; texInfo = manager.textureInfoForFilename(middleFilename); _bottomStrip = manager.addSprite(bottomFilename, 0, 0, 5); _bottomStrip.parentUIObject = this; _bottomStripHeight = (int)texInfo.frame.height; // HACK: Gabo edit. Adding the sprites uiChildArray so they can be deleted addUIChild(_topStrip, _middleStrip, _bottomStrip); }
public static UISlider create(UIToolkit manager, string knobFilename, string trackFilename, int trackxPos, int trackyPos, UISliderLayout layout, int depth = 2, bool knobInFront = true) { // create the track first so we can use its dimensions to position the knob var trackTI = manager.textureInfoForFilename(trackFilename); var trackFrame = new Rect(trackxPos, trackyPos, trackTI.frame.width, trackTI.frame.height); // create a knob using our cacluated position var knobDepth = knobInFront ? depth - 1 : depth + 1; var knob = manager.addSprite(knobFilename, trackxPos, trackyPos, knobDepth, true); return(new UISlider(manager, trackFrame, depth, trackTI.uvRect, knob, layout)); }
public static UISlider create( UIToolkit manager, string knobFilename, string trackFilename, int trackxPos, int trackyPos, UISliderLayout layout, int depth = 2, bool knobInFront = true ) { // create the track first so we can use its dimensions to position the knob var trackTI = manager.textureInfoForFilename( trackFilename ); var trackFrame = new Rect( trackxPos, trackyPos, trackTI.frame.width, trackTI.frame.height ); // create a knob using our cacluated position var knobDepth = knobInFront ? depth - 1 : depth + 1; var knob = manager.addSprite( knobFilename, trackxPos, trackyPos, knobDepth, true ); return new UISlider( manager, trackFrame, depth, trackTI.uvRect, knob, layout ); }
public UIVerticalPanel( UIToolkit manager, string topFilename, string middleFilename, string bottomFilename ) : base(UILayoutType.Vertical) { var texInfo = manager.textureInfoForFilename( topFilename ); _topStrip = manager.addSprite( topFilename, 0, 0, 5 ); _topStrip.parentUIObject = this; _topStripHeight = (int)texInfo.frame.height; _width = texInfo.frame.width; // we overlap the topStrip 1 pixel to ensure we get a good blend here _middleStrip = manager.addSprite( middleFilename, 0, _topStripHeight , 5 ); _middleStrip.parentUIObject = this; texInfo = manager.textureInfoForFilename( middleFilename ); _bottomStrip = manager.addSprite( bottomFilename, 0, 0, 5 ); _bottomStrip.parentUIObject = this; _bottomStripHeight = (int)texInfo.frame.height; // HACK: Gabo edit. Adding the sprites uiChildArray so they can be deleted addUIChild( _topStrip, _middleStrip, _bottomStrip ); }
private void createLandingScreen() { stadiumBG = uiTools.addSprite("stadiumBG.png", 0, 0, 20); UISprite titleSprite = uiTools.addSprite("title.png", 0, 0, 20); titleSprite.pixelsFromTop(28); int buttonsBottomOffset = 130; // Start Button UIButton startButton = UIButton.create(uiTools, "dieButtonLarge.png", "dieButtonLargeDown.png", 0, 0, 10); startButton.pixelsFromBottomLeft(buttonsBottomOffset, 13); UITextInstance startText = graph26.addTextInstance(" START ", 0, 0); startText.parentUIObject = startButton; startText.pixelsFromTopRight(52, 0); // Options Button UIButton optionsButton = UIButton.create(uiTools, "dieButtonLarge.png", "dieButtonLargeDown.png", 0, 0, 10); optionsButton.pixelsFromBottomRight(buttonsBottomOffset, 50); UITextInstance optionsText = graph20.addTextInstance("OPTIONS", 0, 0); optionsText.parentUIObject = optionsButton; optionsText.pixelsFromTopRight(56, 5); // Parent everything to the landingParent for moving UIObject[] objects = { titleSprite, startButton, startText, optionsButton, optionsText }; foreach (UIObject item in objects) { item.parentUIObject = landingParent; } // Set button actions startButton.onTouchUpInside += (sender) => showStartScreen(); }
//constructor public UIPeaceMakerActor(UIToolkit toolkit, string actorName, string fileName) { //todo make this scalable _height = 50; //background image size _width = 50; _touchFrame = new Rect(position.x, -position.y, _width, _height); //background image is always the same _actorBackground = toolkit.addSprite("actorBG.png", 0, 0); _actorBackground.parentUIObject = this; _actorBackground.positionFromTopLeft(0f, 0f); //gradient is always the same _actorGradient = toolkit.addSprite("actor_gradient_white.png", 0, 0); _actorGradient.parentUIObject = this; _actorGradient.positionFromTopLeft(0f, 0f); //image and button _theButton = UIButton.create(toolkit, fileName, fileName, 0, 0); _theButton.parentUIObject = this; _theButton.onTouchUpInside += (sender) => randomAttitudeTest(); //up/down arrow is always the same _actorArrow = toolkit.addSprite("up_arrow_anim_00.png", 0, 0); _actorArrow.parentUIObject = this; _actorArrow.positionFromTopRight(0f, 0f); _arrowUpAnim = _actorArrow.addSpriteAnimation("arrowUpAnim", 0.1f, "up_arrow_anim_00.png", "up_arrow_anim_01.png", "up_arrow_anim_02.png", "up_arrow_anim_03.png", "up_arrow_anim_04.png", "up_arrow_anim_05.png", "up_arrow_anim_06.png", "up_arrow_anim_07.png", "up_arrow_anim_08.png", "up_arrow_anim_09.png"); _arrowDownAnim = _actorArrow.addSpriteAnimation("arrowDownAnim", 0.1f, "down_arrow_anim_00.png", "down_arrow_anim_01.png", "down_arrow_anim_02.png", "down_arrow_anim_03.png", "down_arrow_anim_04.png", "down_arrow_anim_05.png", "down_arrow_anim_06.png", "down_arrow_anim_07.png", "down_arrow_anim_08.png", "down_arrow_anim_09.png"); _arrowUpAnim.loopReverse = true; _arrowDownAnim.loopReverse = true; hideAttitudeIndicators(); }
public UIProgressBar( UIToolkit manager, Rect frame, int depth, UIUVRect uvFrame, UISprite bar ) : base(frame, depth, uvFrame) { // Save the bar and make it a child of the container/border for organization purposes _bar = bar; _bar.parentUIObject = this; // Save the bars original size _barOriginalWidth = _bar.width; _barOriginalUVframe = _bar.uvFrame; manager.addSprite( this ); }
// the bars x/y coordinates should be relative to the borders public static UIProgressBar create(UIToolkit manager, string barFilename, string borderFilename, int barxPos, int baryPos, int borderxPos, int borderyPos, bool rightToLeft) { var borderTI = manager.textureInfoForFilename(borderFilename); var borderFrame = new Rect(borderxPos, borderyPos, borderTI.frame.width, borderTI.frame.height); UISprite bar; if (rightToLeft) { bar = manager.addSprite(barFilename, borderxPos - barxPos + ((int)borderTI.frame.width), borderyPos + baryPos, 2); } else { bar = manager.addSprite(barFilename, borderxPos + barxPos, borderyPos + baryPos, 2); } var progressBar = new UIProgressBar(manager, borderFrame, 1, borderTI.uvRect, bar); progressBar.rightToLeft = rightToLeft; return(progressBar); }
public UIProgressBar( UIToolkit manager, Rect frame, int depth, UIUVRect uvFrame, bool rightToLeft ):base( frame, depth, uvFrame ) { manager.addSprite( this ); // Save the bars original size _barOriginalWidth = frame.width; _barOriginalUVframe = uvFrame; this.rightToLeft = rightToLeft; // Update the bar size based on the value if( rightToLeft ) setSize( _value * -_barOriginalWidth, frame.height ); else setSize( _value * _barOriginalWidth, frame.height ); }
public static UISlider create( UIToolkit manager, string knobFilename, string trackFilename, int trackxPos, int trackyPos, UISliderLayout layout ) { // create the track first so we can use its dimensions to position the knob var trackTI = manager.textureInfoForFilename( trackFilename ); var trackFrame = new Rect( trackxPos, trackyPos, trackTI.frame.width, trackTI.frame.height ); // position the knob based on the knobs size, layout and the track size if( layout == UISliderLayout.Horizontal ) trackyPos += (int)trackTI.frame.height / 2; else trackxPos += (int)trackTI.frame.width / 2; // create a knob using our cacluated position var knob = manager.addSprite( knobFilename, trackxPos, trackyPos, 1, true ); return new UISlider( manager, trackFrame, 2, trackTI.uvRect, knob, layout, trackTI.rotated ); }
public UIProgressBar(UIToolkit manager, Rect frame, int depth, UIUVRect uvFrame, bool rightToLeft) : base(frame, depth, uvFrame) { manager.addSprite(this); // Save the bars original size _barOriginalWidth = frame.width; _barOriginalUVframe = uvFrame; this.rightToLeft = rightToLeft; // Update the bar size based on the value if (rightToLeft) { setSize(_value * -_barOriginalWidth, frame.height); } else { setSize(_value * _barOriginalWidth, frame.height); } }
public UIProgressBar( UIToolkit manager, Rect frame, int depth, UIUVRect uvFrame, UISprite bar ) : base(frame, depth, uvFrame) { // Save the bar and make it a child of the container/border for organization purposes _bar = bar; _bar.parentUIObject = this; // Save the bars original size _barOriginalWidth = _bar.width; _barOriginalUVframe = _bar.uvFrame; // Update the bar size based on the value if (rightToLeft) _bar.setSize(_value * -_barOriginalWidth, _bar.height); else _bar.setSize(_value * _barOriginalWidth, _bar.height); manager.addSprite( this ); }
public static UISprite createTextWrapper(UIToolkit uiTools, UITextInstance text, UIAbstractContainer layout) { // Get the right wrapping for the text setTextLayoutWrap(layout, text); // Create the wrapper and scale it // TODO: Check if empty.png exists if not then throw a clear error. UISprite textWrapper = uiTools.addSprite("empty.png", 0, 0); textWrapperScale(layout, textWrapper, text); // Make the text a child of the wrapper text.parentUIObject = textWrapper; textWrapper.userData = text; textPositionInWrapper(text); // Return the wrapper return(textWrapper); }
// the knobs x/y coordinates should be relative to the tracks and it is measured from the center of the knob public static UISlider create(UIToolkit manager, string knobFilename, string trackFilename, int trackxPos, int trackyPos, UISliderLayout layout) { // create the track first so we can use its dimensions to position the knob var trackTI = manager.textureInfoForFilename(trackFilename); var trackFrame = new Rect(trackxPos, trackyPos, trackTI.size.x, trackTI.size.y); // position the knob based on the knobs size, layout and the track size if (layout == UISliderLayout.Horizontal) { trackyPos += (int)trackTI.size.y / 2; } else { trackxPos += (int)trackTI.size.x / 2; } // create a knob using our cacluated position var knob = manager.addSprite(knobFilename, trackxPos, trackyPos, 1, true); return(new UISlider(manager, trackFrame, 2, trackTI.uvRect, knob, layout)); }
/// <summary> /// Initializes a new instance of the <see cref="UISlice9"/> class. /// </summary> /// <param name='manager'> /// Manager. /// </param> /// <param name='frame'> /// Frame. /// </param> /// <param name='depth'> /// Depth. /// </param> /// <param name='uvFrame'> /// Uv frame. /// </param> /// <param name='highlightedUVframe'> /// Highlighted U vframe. /// </param> /// <param name='width'> /// Final width /// </param> /// <param name='height'> /// Final height /// </param> /// <param name='sTP'> /// Top Margin /// </param> /// <param name='sRT'> /// Right Margin /// </param> /// <param name='sBT'> /// Bottom Margin /// </param> /// <param name='sLT'> /// Left Margin /// </param> public UISlice9(UIToolkit manager, Rect frame, int depth, UIUVRect uvFrame, UIUVRect highlightedUVframe, int width, int height, int sTP, int sRT, int sBT, int sLT) : base(frame, depth, uvFrame) { // If a highlighted frame has not yet been set use the normalUVframe if (highlightedUVframe == UIUVRect.zero) { highlightedUVframe = uvFrame; } this.highlightedUVframe = highlightedUVframe; int stretchedWidth = width - (sLT + sRT); int stretchedHeight = height - (sTP + sBT); this.manager = manager; // Top Left spriteSlices[0] = new UISprite(new Rect(frame.x, frame.y, sLT, sTP), depth, new UIUVRect(uvFrame.frame.x, uvFrame.frame.y, sLT, sTP, manager.textureSize)); spriteSlices[0].client.transform.parent = this.client.transform; manager.addSprite(spriteSlices[0]); // Top Middle spriteSlices[1] = new UISprite(new Rect(frame.x + sLT, frame.y, stretchedWidth, sTP), depth, new UIUVRect(uvFrame.frame.x + sLT, uvFrame.frame.y, uvFrame.frame.width - (sRT + sLT), sTP, manager.textureSize)); spriteSlices[1].client.transform.parent = this.client.transform; manager.addSprite(spriteSlices[1]); // Top Right spriteSlices[2] = new UISprite(new Rect(frame.x + sLT + stretchedWidth, frame.y, sRT, sTP), depth, new UIUVRect(uvFrame.frame.x + sLT + (uvFrame.frame.width - (sRT + sLT)), uvFrame.frame.y, sRT, sTP, manager.textureSize)); spriteSlices[2].client.transform.parent = this.client.transform; manager.addSprite(spriteSlices[2]); // Middle Left spriteSlices[3] = new UISprite(new Rect(frame.x, frame.y + sTP, sLT, stretchedHeight), depth, new UIUVRect(uvFrame.frame.x, uvFrame.frame.y + sTP, sLT, uvFrame.frame.height - (sTP + sBT), manager.textureSize)); spriteSlices[3].client.transform.parent = this.client.transform; manager.addSprite(spriteSlices[3]); // Middle Middle spriteSlices[4] = new UISprite(new Rect(frame.x + sLT, frame.y + sTP, stretchedWidth, stretchedHeight), depth, new UIUVRect(uvFrame.frame.x + sLT, uvFrame.frame.y + sTP, uvFrame.frame.height - (sTP + sBT), (int)frame.width - (sLT + sRT), manager.textureSize)); spriteSlices[4].client.transform.parent = this.client.transform; manager.addSprite(spriteSlices[4]); // Middle Right spriteSlices[5] = new UISprite(new Rect(frame.x + sLT + stretchedWidth, frame.y + sTP, sRT, stretchedHeight), depth, new UIUVRect(uvFrame.frame.x + (uvFrame.frame.width - sRT), uvFrame.frame.y + sTP, sRT, uvFrame.frame.height - (sBT + sTP), manager.textureSize)); spriteSlices[5].client.transform.parent = this.client.transform; manager.addSprite(spriteSlices[5]); // Bottom Left spriteSlices[6] = new UISprite(new Rect(frame.x, frame.y + sTP + stretchedHeight, sLT, sBT), depth, new UIUVRect(uvFrame.frame.x, uvFrame.frame.y + (uvFrame.frame.height - sBT), sLT, sBT, manager.textureSize)); spriteSlices[6].client.transform.parent = this.client.transform; manager.addSprite(spriteSlices[6]); // Bottom Middle spriteSlices[7] = new UISprite(new Rect(frame.x + sLT, frame.y + sTP + stretchedHeight, stretchedWidth, sBT), depth, new UIUVRect(uvFrame.frame.x + sLT, uvFrame.frame.y + (uvFrame.frame.height - sBT), uvFrame.frame.width - (sLT + sRT), sBT, manager.textureSize)); spriteSlices[7].client.transform.parent = this.client.transform; manager.addSprite(spriteSlices[7]); // Bottom Right spriteSlices[8] = new UISprite(new Rect(frame.x + sLT + stretchedWidth, frame.y + sTP + stretchedHeight, sRT, sBT), depth, new UIUVRect(uvFrame.frame.x + sLT + (uvFrame.frame.width - (sRT + sLT)), uvFrame.frame.y + (uvFrame.frame.height - sBT), sRT, sBT, manager.textureSize)); spriteSlices[8].client.transform.parent = this.client.transform; manager.addSprite(spriteSlices[8]); this.setSize(width, height); manager.addTouchableSprite(this); }
// public static UIJoystick create( UIToolkit manager, string joystickFilename, Rect hitAreaFrame, float xPos, float yPos ) { // create the joystrick sprite var joystick = manager.addSprite( joystickFilename, 0, 0, 1, true ); //check if HD is available or not //using HD we should increase the hit area by 2, because the double pixel size //of the iphone4, also of course the xpos and ypos also should be updated as well if (UI.instance.isHD) { Rect t = new Rect (hitAreaFrame.x, hitAreaFrame.y, hitAreaFrame.width * 2, hitAreaFrame.height * 2); return new UIJoystick( manager, t, 1, joystick, xPos * 2, yPos * 2); } else { return new UIJoystick( manager, hitAreaFrame, 1, joystick, xPos, yPos ); } }
/// <summary> /// Initializes a new instance of the <see cref="UISlice9"/> class. /// </summary> /// <param name='manager'> /// Manager. /// </param> /// <param name='frame'> /// Frame. /// </param> /// <param name='depth'> /// Depth. /// </param> /// <param name='uvFrame'> /// Uv frame. /// </param> /// <param name='highlightedUVframe'> /// Highlighted U vframe. /// </param> /// <param name='width'> /// Final width /// </param> /// <param name='height'> /// Final height /// </param> /// <param name='sTP'> /// Top Margin /// </param> /// <param name='sRT'> /// Right Margin /// </param> /// <param name='sBT'> /// Bottom Margin /// </param> /// <param name='sLT'> /// Left Margin /// </param> public UISlice9( UIToolkit manager, Rect frame, int depth, UIUVRect uvFrame, UIUVRect highlightedUVframe, int width, int height, int sTP, int sRT, int sBT, int sLT ):base( frame, depth, uvFrame ) { // If a highlighted frame has not yet been set use the normalUVframe if( highlightedUVframe == UIUVRect.zero ) highlightedUVframe = uvFrame; this.highlightedUVframe = highlightedUVframe; int stretchedWidth = width - ( sLT + sRT ); int stretchedHeight = height - ( sTP + sBT ); this.manager = manager; // Top Left spriteSlices[0] = new UISprite( new Rect( frame.x, frame.y, sLT, sTP ), depth, new UIUVRect( uvFrame.frame.x, uvFrame.frame.y, sLT, sTP, manager.textureSize ) ); spriteSlices[0].client.transform.parent = this.client.transform; manager.addSprite( spriteSlices[0] ); // Top Middle spriteSlices[1] = new UISprite( new Rect( frame.x + sLT, frame.y, stretchedWidth, sTP ), depth, new UIUVRect( uvFrame.frame.x + sLT, uvFrame.frame.y, uvFrame.frame.width - ( sRT + sLT ), sTP, manager.textureSize ) ); spriteSlices[1].client.transform.parent = this.client.transform; manager.addSprite( spriteSlices[1] ); // Top Right spriteSlices[2] = new UISprite( new Rect( frame.x + sLT + stretchedWidth, frame.y, sRT, sTP ), depth, new UIUVRect( uvFrame.frame.x + sLT + ( uvFrame.frame.width - ( sRT + sLT ) ), uvFrame.frame.y, sRT, sTP, manager.textureSize ) ); spriteSlices[2].client.transform.parent = this.client.transform; manager.addSprite( spriteSlices[2] ); // Middle Left spriteSlices[3] = new UISprite( new Rect( frame.x, frame.y + sTP, sLT, stretchedHeight ), depth, new UIUVRect( uvFrame.frame.x, uvFrame.frame.y + sTP, sLT, uvFrame.frame.height - ( sTP + sBT ), manager.textureSize ) ); spriteSlices[3].client.transform.parent = this.client.transform; manager.addSprite( spriteSlices[3] ); // Middle Middle spriteSlices[4] = new UISprite( new Rect( frame.x + sLT, frame.y + sTP, stretchedWidth, stretchedHeight ), depth, new UIUVRect( uvFrame.frame.x + sLT, uvFrame.frame.y + sTP, uvFrame.frame.height - ( sTP + sBT ), (int)frame.width - ( sLT + sRT ), manager.textureSize ) ); spriteSlices[4].client.transform.parent = this.client.transform; manager.addSprite( spriteSlices[4] ); // Middle Right spriteSlices[5] = new UISprite( new Rect( frame.x + sLT + stretchedWidth, frame.y + sTP, sRT, stretchedHeight ), depth, new UIUVRect( uvFrame.frame.x + ( uvFrame.frame.width - sRT ), uvFrame.frame.y + sTP, sRT, uvFrame.frame.height - ( sBT + sTP ), manager.textureSize ) ); spriteSlices[5].client.transform.parent = this.client.transform; manager.addSprite( spriteSlices[5] ); // Bottom Left spriteSlices[6] = new UISprite( new Rect( frame.x, frame.y + sTP + stretchedHeight, sLT, sBT ), depth, new UIUVRect( uvFrame.frame.x, uvFrame.frame.y + ( uvFrame.frame.height - sBT ), sLT, sBT, manager.textureSize ) ); spriteSlices[6].client.transform.parent = this.client.transform; manager.addSprite( spriteSlices[6] ); // Bottom Middle spriteSlices[7] = new UISprite( new Rect( frame.x + sLT, frame.y + sTP + stretchedHeight, stretchedWidth, sBT ), depth, new UIUVRect( uvFrame.frame.x + sLT, uvFrame.frame.y + ( uvFrame.frame.height - sBT ), uvFrame.frame.width - ( sLT + sRT ), sBT, manager.textureSize ) ); spriteSlices[7].client.transform.parent = this.client.transform; manager.addSprite( spriteSlices[7] ); // Bottom Right spriteSlices[8] = new UISprite( new Rect( frame.x + sLT + stretchedWidth, frame.y + sTP + stretchedHeight, sRT, sBT ), depth, new UIUVRect( uvFrame.frame.x + sLT + ( uvFrame.frame.width - ( sRT + sLT ) ), uvFrame.frame.y + ( uvFrame.frame.height - sBT ), sRT, sBT, manager.textureSize ) ); spriteSlices[8].client.transform.parent = this.client.transform; manager.addSprite( spriteSlices[8] ); this.setSize( width, height ); manager.addTouchableSprite( this ); }
public UIStateSprite(UIToolkit manager, Rect frame, int depth, UIUVRect uvFrame) : base(frame, depth, uvFrame) { manager.addSprite(this); }
// the bars x/y coordinates should be relative to the borders public static UIProgressBar create( UIToolkit manager, string barFilename, string borderFilename, int barxPos, int baryPos, int borderxPos, int borderyPos ) { var bar = manager.addSprite( barFilename, borderxPos + barxPos, borderyPos + baryPos, 2 ); var borderTI = manager.textureInfoForFilename( borderFilename ); var borderFrame = new Rect( borderxPos, borderyPos, borderTI.frame.width, borderTI.frame.height ); return new UIProgressBar( manager, borderFrame, 1, borderTI.uvRect, bar ); }
// the bars x/y coordinates should be relative to the borders public static UIProgressBar create( UIToolkit manager, string barFilename, string borderFilename, int barxPos, int baryPos, int borderxPos, int borderyPos, bool rightToLeft, int depth, bool barInFront = true ) { var borderTI = manager.textureInfoForFilename( borderFilename ); var borderFrame = new Rect( borderxPos, borderyPos, borderTI.frame.width, borderTI.frame.height ); UISprite bar; if( rightToLeft ) bar = manager.addSprite( barFilename, borderxPos - barxPos + ((int)borderTI.frame.width), borderyPos + baryPos, depth ); else bar = manager.addSprite( barFilename, borderxPos + barxPos, borderyPos + baryPos, depth ); var barDepth = barInFront ? depth - 1 : depth + 1; var progressBar = new UIProgressBar( manager, borderFrame, barDepth, borderTI.uvRect, bar ); progressBar.rightToLeft = rightToLeft; return progressBar; }
// Sets the background image for display behind the joystick sprite public void addBackgroundSprite(string filename) { _backgroundSprite = _manager.addSprite(filename, 0, 0, 2, true); _backgroundSprite.parentUIObject = this; _backgroundSprite.hidden = true; }
public static UISprite createTextWrapper( UIToolkit uiTools, UITextInstance text, UIAbstractContainer layout ) { // Get the right wrapping for the text setTextLayoutWrap( layout, text ); // Create the wrapper and scale it // TODO: Check if empty.png exists if not then throw a clear error. UISprite textWrapper = uiTools.addSprite( "empty.png", 0, 0 ); textWrapperScale( layout, textWrapper, text ); // Make the text a child of the wrapper text.parentUIObject = textWrapper; textWrapper.userData = text; textPositionInWrapper( text ); // Return the wrapper return textWrapper; }
void Start() { text = new UIText(textToolkit, "GhoulishFont", "GhoulishFont_0.png"); startScript = FindObjectOfType(typeof(StartScript)) as StartScript; loader = FindObjectOfType(typeof(loadingScript)) as loadingScript; character = FindObjectOfType(typeof(CharacterMaster)) as CharacterMaster; //DontDestroyOnLoad(this.gameObject); AmmoText = text.addTextInstance("Bullets: " + startScript.Ammunition.ToString(), 0, 0, textScaleFactor, 2, Color.white, UITextAlignMode.Left, UITextVerticalAlignMode.Middle); PickupAmount = text.addTextInstance("+20", 0, 0, textScaleFactor * 5, 2, Color.white, UITextAlignMode.Left, UITextVerticalAlignMode.Middle); PickupAmount.alphaTo(0.1f, 0, Easing.Quartic.easeIn); PickupAmount.hidden = true; LevelInstruc = text.addTextInstance("" + LvlInstructions, 0, 0, textScaleFactor, 2, Color.white, UITextAlignMode.Center, UITextVerticalAlignMode.Middle); LevelInstruc.positionCenter(); LevelInstruc.alphaTo(0.01f, 0, Easing.Quartic.easeIn); StartCoroutine(StartLvlInstruction()); // buttons ------------------------------------ PauseBtn = UIButton.create(buttonUI, "PauseBtn.png", "PauseBtn.png", 0, 0, 10); PauseBtn.positionFromTopLeft(0.035f, 0.045f); PauseBtn.onTouchUpInside += onTouchPauseBtn; PauseBtn.touchDownSound = buttonSound; PauseBtn.hidden = false; PlayBtn = UIButton.create(buttonUI, "PlayBtn.png", "PlayBtn.png", 0, 0, 10); PlayBtn.positionFromCenter(0.2f, -0.21f); PlayBtn.onTouchUpInside += onTouchPlayBtn; PlayBtn.touchDownSound = buttonSound; PlayBtn.hidden = true; RetryBtn = UIButton.create(buttonUI, "RetryBtn.png", "RetryBtn.png", 0, 0, 10); RetryBtn.positionFromCenter(0.2f, -0.07f); RetryBtn.onTouchUpInside += onTouchRetryBtn; RetryBtn.touchDownSound = buttonSound; RetryBtn.hidden = true; QuitBtn = UIButton.create(buttonUI, "QuitBtn.png", "QuitBtn.png", 0, 0, 10); QuitBtn.positionFromCenter(0.2f, 0.07f); QuitBtn.onTouchUpInside += onTouchQuitBtn; QuitBtn.touchDownSound = buttonSound; QuitBtn.hidden = true; //------TOGGLE BTNS------------------------------- AudioBtn = UIToggleButton.create(buttonUI, "AudioOffBtn.png", "AudioBtn.png", "AudioOffBtn.png", 0, 0, 10); AudioBtn.positionFromCenter(0.2f, 0.21f); AudioBtn.onToggle += onTouchAudioBtn; AudioBtn.hidden = true; if (PlayerPrefs.GetInt("volume") == 1) { AudioBtn.selected = true; } //-------------------HEALTH METER-------------------------------------- HealthBG = buttonUI.addSprite("HealthBG.png", 0, 0, 10); HealthBG.positionFromCenter(-0.41f, 0.0f); HealthBar = UIProgressBar.create(buttonUI, "HealthBar.png", 0, 0, false, 5, false); Vector2 tempVec; tempVec = new Vector2(HealthBG.position.x + 95, HealthBG.position.y - 10); HealthBar.position = tempVec; HealthBar.value = 1; //----------------------PICKUPS------------------------- HealthPickup = buttonUI.addSprite("HeartPickup.png", 0, 0, 10); HealthPickup.positionFromCenter(-0.0f, 0.0f); HealthPickup.alphaTo(0.1f, 0, Easing.Quartic.easeIn); HealthPickup.hidden = true; AmmoPickup = buttonUI.addSprite("AmmoPickup.png", 0, 0, 10); AmmoPickup.positionFromCenter(-0.0f, 0.0f); AmmoPickup.alphaTo(0.1f, 0, Easing.Quartic.easeIn); AmmoPickup.hidden = true; //-----------------------------CONTROLS------------------------------------------ LToggle = UIJoystick.create(buttonUI, "LToggle.png", new Rect(Screen.width * 0.01f, Screen.height * 0.45f, Screen.width * 0.4f, Screen.height * 0.6f), Screen.width * 0.175f, Screen.height * -0.3f); LToggle.deadZone = new Vector2(0.8f, 0.8f); //LToggle.setJoystickHighlightedFilename( "LToggleT.png" ); AttackBtn = UIContinuousButton.create("AttackBtn.png", "AttackBtn.png", 0, 0); AttackBtn.positionFromBottomRight(0.05f, 0.05f); AttackBtn.centerize(); // centerize the button so we can scale it from the center AttackBtn.highlightedTouchOffsets = new UIEdgeOffsets(30); AttackBtn.onTouchIsDown += onTouchAttackBtn; AttackBtn.onTouchUpInside += onTouchAttackBtnUp; if (loader != null) { if (loader.ControllerCount > 0) { LToggle.hidden = true; AttackBtn.hidden = true; } } }