public void ShowElement(Character c) { if(this.showBox) { GUI.Box(this.bounds, ""); } GUIStyle guiStyle = new GUIStyle(GUI.skin.label); guiStyle.alignment = this.textAnchor; if(HUDElementType.TEXT.Equals(this.type)) { if(this.showShadow) { guiStyle.normal.textColor = DataHolder.Color(this.shadowColor); GUI.Label( new Rect(this.bounds.x + this.shadowOffset.x, this.bounds.y + this.shadowOffset.y, this.bounds.width, this.bounds.height), this.text[GameHandler.GetLanguage()], guiStyle); } guiStyle.normal.textColor = DataHolder.Color(this.textColor); GUI.Label(this.bounds, this.text[GameHandler.GetLanguage()], guiStyle); } else if(HUDElementType.IMAGE.Equals(this.type)) { GUI.DrawTexture(this.bounds, this.GetImage(), this.scaleMode, this.alphaBlend, this.imageAspect); } else if(HUDElementType.NAME.Equals(this.type)) { GUIContent gc = null; if(HUDContentType.TEXT.Equals(this.contentType)) { if(HUDNameType.CHARACTER.Equals(this.nameType)) gc = new GUIContent(c.GetName()); else if(HUDNameType.CLASS.Equals(this.nameType)) gc = new GUIContent(DataHolder.Classes().GetName(c.currentClass)); else if(HUDNameType.STATUS.Equals(this.nameType)) gc = new GUIContent(DataHolder.StatusValues().GetName(this.statusID)); } else if(HUDContentType.ICON.Equals(this.contentType)) { if(HUDNameType.CHARACTER.Equals(this.nameType)) gc = new GUIContent(c.GetIcon()); else if(HUDNameType.CLASS.Equals(this.nameType)) gc = new GUIContent(DataHolder.Classes().GetIcon(c.currentClass)); else if(HUDNameType.STATUS.Equals(this.nameType)) gc = new GUIContent(DataHolder.StatusValues().GetIcon(this.statusID)); } else if(HUDContentType.BOTH.Equals(this.contentType)) { if(HUDNameType.CHARACTER.Equals(this.nameType)) gc = c.GetContent(); else if(HUDNameType.CLASS.Equals(this.nameType)) gc = DataHolder.Classes().GetContent(c.currentClass); else if(HUDNameType.STATUS.Equals(this.nameType)) gc = DataHolder.StatusValues().GetContent(this.statusID); } if(gc != null) { if(this.showShadow) { guiStyle.normal.textColor = DataHolder.Color(this.shadowColor); GUI.Label( new Rect(this.bounds.x + this.shadowOffset.x, this.bounds.y + this.shadowOffset.y, this.bounds.width, this.bounds.height), gc, guiStyle); } guiStyle.normal.textColor = DataHolder.Color(this.textColor); GUI.Label(this.bounds, gc, guiStyle); } } else if(HUDElementType.STATUS.Equals(this.type)) { if(HUDDisplayType.TEXT.Equals(this.displayType)) { string txt = c.status[this.statusID].GetValue().ToString(); if(c.status[this.statusID].IsConsumable() && this.showMax) { txt += this.divider+c.status[c.status[this.statusID].maxStatus].GetValue().ToString(); } if(this.showShadow) { guiStyle.normal.textColor = DataHolder.Color(this.shadowColor); GUI.Label( new Rect(this.bounds.x + this.shadowOffset.x, this.bounds.y + this.shadowOffset.y, this.bounds.width, this.bounds.height), txt, guiStyle); } guiStyle.normal.textColor = DataHolder.Color(this.textColor); GUI.Label(this.bounds, txt, guiStyle); } else if(HUDDisplayType.BAR.Equals(this.displayType) && c.status[this.statusID].IsConsumable()) { float v1 = c.status[this.statusID].GetValue(); float v2 = c.status[c.status[this.statusID].maxStatus].GetValue(); v2 /= 100; v1 /= v2; GUI.DrawTexture(new Rect(this.bounds.x, this.bounds.y, this.bounds.width*v1/100, this.bounds.height), this.GetImage(), this.scaleMode, this.alphaBlend, this.imageAspect); } } else if(HUDElementType.TIMEBAR.Equals(this.type) || HUDElementType.USED_TIMEBAR.Equals(this.type) || HUDElementType.CASTTIME.Equals(this.type)) { float v1 = 0; float v2 = 0; if(HUDElementType.TIMEBAR.Equals(this.type)) { v1 = c.timeBar; v2 = DataHolder.BattleSystem().maxTimebar; } else if(HUDElementType.USED_TIMEBAR.Equals(this.type)) { v1 = c.usedTimeBar; v2 = DataHolder.BattleSystem().maxTimebar; } else if(HUDElementType.CASTTIME.Equals(this.type)) { v1 = c.GetSkillCastTime(); v2 = c.GetSkillCastTimeMax(); } if(HUDDisplayType.TEXT.Equals(this.displayType)) { string txt = ((int)v1).ToString(); if(this.showShadow) { guiStyle.normal.textColor = DataHolder.Color(this.shadowColor); GUI.Label( new Rect(this.bounds.x + this.shadowOffset.x, this.bounds.y + this.shadowOffset.y, this.bounds.width, this.bounds.height), txt, guiStyle); } guiStyle.normal.textColor = DataHolder.Color(this.textColor); GUI.Label(this.bounds, txt, guiStyle); } else if(HUDDisplayType.BAR.Equals(this.displayType) && v2 > 0) { v2 /= 100; v1 /= v2; GUI.DrawTexture(new Rect(this.bounds.x, this.bounds.y, this.bounds.width*v1/100, this.bounds.height), this.GetImage(), this.scaleMode, this.alphaBlend, this.imageAspect); } } else if(HUDElementType.EFFECT.Equals(this.type)) { int maxView = this.rows*this.columns; float cellWidth = this.bounds.width; float cellHeight = this.bounds.height; cellWidth -= this.spacing*(this.columns-1); cellHeight -= this.spacing*(this.rows-1); cellWidth /= this.columns; cellHeight /= this.rows; int currentColumn = 0; int currentRow = 0; for(int i=0; i<c.effect.Length; i++) { if(i >= maxView) { break; } else { GUIContent gc = null; if(HUDContentType.TEXT.Equals(this.contentType)) { gc = new GUIContent(DataHolder.Effects().GetName(c.effect[i].realID)); } else if(HUDContentType.ICON.Equals(this.contentType)) { gc = new GUIContent(DataHolder.Effects().GetIcon(c.effect[i].realID)); } else if(HUDContentType.BOTH.Equals(this.contentType)) { gc = DataHolder.Effects().GetContent(c.effect[i].realID); } if(gc != null) { Rect pos = new Rect(this.bounds.x+cellWidth*currentColumn+this.spacing*currentColumn, this.bounds.y+cellHeight*currentRow+this.spacing*currentRow, cellWidth, cellHeight); if(this.showShadow && (HUDContentType.TEXT.Equals(this.contentType) || HUDContentType.BOTH.Equals(this.contentType))) { guiStyle.normal.textColor = DataHolder.Color(this.shadowColor); GUI.Label( new Rect(pos.x + this.shadowOffset.x, pos.y + this.shadowOffset.y, pos.width, pos.height), gc, guiStyle); } guiStyle.normal.textColor = DataHolder.Color(this.textColor); GUI.Label(pos, gc, guiStyle); currentColumn++; } if(currentColumn >= this.columns) { currentColumn = 0; currentRow++; } } } } else if(HUDElementType.VARIABLE.Equals(this.type)) { string txt = this.GetVariableText(); if(txt != null && txt != "") { if(this.showShadow) { guiStyle.normal.textColor = DataHolder.Color(this.shadowColor); GUI.Label( new Rect(this.bounds.x + this.shadowOffset.x, this.bounds.y + this.shadowOffset.y, this.bounds.width, this.bounds.height), txt, guiStyle); } guiStyle.normal.textColor = DataHolder.Color(this.textColor); GUI.Label(this.bounds, txt, guiStyle); } } }
public Texture2D AddTexture(Texture2D hudTexture, Character c, Vector2 pos, GUIFont font, int hudID) { if(HUDElementType.TEXT.Equals(this.type)) { hudTexture = font.AddTextTexture(hudTexture, this.text[GameHandler.GetLanguage()], this.GetAnchoredRect(pos, font.GetTextSize(this.text[GameHandler.GetLanguage()]), this.bounds), DataHolder.Color(this.textColor), DataHolder.Color(this.shadowColor), 0, Vector2.zero, this.showShadow, this.shadowOffset, false); } else if(HUDElementType.IMAGE.Equals(this.type)) { this.GetImage(); if(this.texture != null) { Vector2 scaledSize = TextureDrawer.GetScaledSize(this.texture, this.bounds, this.scaleMode); hudTexture = TextureDrawer.AddTexture(hudTexture, new Rect(this.bounds.x+pos.x, pos.y-this.bounds.y-scaledSize.y, scaledSize.x, scaledSize.y), TextureDrawer.GetScaledPixels(this.texture, scaledSize, this.bounds, this.scaleMode)); } } else if(HUDElementType.NAME.Equals(this.type)) { GUIContent gc = null; if(HUDContentType.TEXT.Equals(this.contentType)) { if(HUDNameType.CHARACTER.Equals(this.nameType)) gc = new GUIContent(c.GetName()); else if(HUDNameType.CLASS.Equals(this.nameType)) gc = new GUIContent(DataHolder.Classes().GetName(c.currentClass)); else if(HUDNameType.STATUS.Equals(this.nameType)) gc = new GUIContent(DataHolder.StatusValues().GetName(this.statusID)); } else if(HUDContentType.ICON.Equals(this.contentType)) { if(HUDNameType.CHARACTER.Equals(this.nameType)) gc = new GUIContent(c.GetIcon()); else if(HUDNameType.CLASS.Equals(this.nameType)) gc = new GUIContent(DataHolder.Classes().GetIcon(c.currentClass)); else if(HUDNameType.STATUS.Equals(this.nameType)) gc = new GUIContent(DataHolder.StatusValues().GetIcon(this.statusID)); } else if(HUDContentType.BOTH.Equals(this.contentType)) { if(HUDNameType.CHARACTER.Equals(this.nameType)) gc = c.GetContent(); else if(HUDNameType.CLASS.Equals(this.nameType)) gc = DataHolder.Classes().GetContent(c.currentClass); else if(HUDNameType.STATUS.Equals(this.nameType)) gc = DataHolder.StatusValues().GetContent(this.statusID); } if(gc != null) { Vector2 size = Vector2.zero; float gap = 0; if("" != gc.text) { size = font.GetTextSize(gc.text); if(gc.image != null) { gap = font.GetTextSize(" ").x; size.x += gap; } } if(gc.image != null) { size.x += gc.image.width; if(size.y < gc.image.height) size.y = gc.image.height; } Rect rect = this.GetAnchoredRect(pos, size, this.bounds); if(gc.image != null) { Texture2D tex = gc.image as Texture2D; hudTexture = TextureDrawer.AddTexture(hudTexture, new Rect(rect.x, rect.y, gc.image.width, gc.image.height), tex.GetPixels()); rect.x += gc.image.width+gap; rect.width -= gc.image.width+gap; } if("" != gc.text) { hudTexture = font.AddTextTexture(hudTexture, gc.text, rect, DataHolder.Color(this.textColor), DataHolder.Color(this.shadowColor), 0, Vector2.zero, this.showShadow, this.shadowOffset, false); } } } else if(HUDElementType.STATUS.Equals(this.type)) { c.status[this.statusID].lastValueHUD[hudID] = c.status[this.statusID].GetValue(); if(HUDDisplayType.TEXT.Equals(this.displayType)) { string txt = c.status[this.statusID].GetValue().ToString(); if(c.status[this.statusID].IsConsumable() && this.showMax) { txt += this.divider+c.status[c.status[this.statusID].maxStatus].GetValue().ToString(); } hudTexture = font.AddTextTexture(hudTexture, txt, this.GetAnchoredRect(pos, font.GetTextSize(txt), this.bounds), DataHolder.Color(this.textColor), DataHolder.Color(this.shadowColor), 0, Vector2.zero, this.showShadow, this.shadowOffset, false); } else if(HUDDisplayType.BAR.Equals(this.displayType) && c.status[this.statusID].IsConsumable()) { float v1 = c.status[this.statusID].GetValue(); float v2 = c.status[c.status[this.statusID].maxStatus].GetValue(); v2 /= 100; v1 /= v2; this.GetImage(); if(this.texture != null) { Rect b = new Rect(this.bounds.x, this.bounds.y, this.bounds.width*v1/100, this.bounds.height); Vector2 scaledSize = TextureDrawer.GetScaledSize(this.texture, b, this.scaleMode); hudTexture = TextureDrawer.AddTexture(hudTexture, new Rect(b.x+pos.x, pos.y-b.y-scaledSize.y, scaledSize.x, scaledSize.y), TextureDrawer.GetScaledPixels(this.texture, scaledSize, b, this.scaleMode)); } } } else if(HUDElementType.TIMEBAR.Equals(this.type) || HUDElementType.USED_TIMEBAR.Equals(this.type) || HUDElementType.CASTTIME.Equals(this.type)) { float v1 = 0; float v2 = 0; if(HUDElementType.TIMEBAR.Equals(this.type)) { v1 = c.timeBar; v2 = DataHolder.BattleSystem().maxTimebar; c.timeBarHUD[hudID] = v1; } else if(HUDElementType.USED_TIMEBAR.Equals(this.type)) { v1 = c.usedTimeBar; v2 = DataHolder.BattleSystem().maxTimebar; c.usedTimeBarHUD[hudID] = v1; } else if(HUDElementType.CASTTIME.Equals(this.type)) { v1 = c.GetSkillCastTime(); v2 = c.GetSkillCastTimeMax(); c.castTimeHUD[hudID] = v1; } if(HUDDisplayType.TEXT.Equals(this.displayType)) { string txt = ((int)v1).ToString(); hudTexture = font.AddTextTexture(hudTexture, txt, this.GetAnchoredRect(pos, font.GetTextSize(txt), this.bounds), DataHolder.Color(this.textColor), DataHolder.Color(this.shadowColor), 0, Vector2.zero, this.showShadow, this.shadowOffset, false); } else if(HUDDisplayType.BAR.Equals(this.displayType) && v2 > 0) { v2 /= 100; v1 /= v2; this.GetImage(); if(this.texture != null) { Rect b = new Rect(this.bounds.x, this.bounds.y, this.bounds.width*v1/100, this.bounds.height); Vector2 scaledSize = TextureDrawer.GetScaledSize(this.texture, b, this.scaleMode); hudTexture = TextureDrawer.AddTexture(hudTexture, new Rect(b.x+pos.x, pos.y-b.y-scaledSize.y, scaledSize.x, scaledSize.y), TextureDrawer.GetScaledPixels(this.texture, scaledSize, b, this.scaleMode)); } } } else if(HUDElementType.EFFECT.Equals(this.type)) { c.effectHUD = false; int maxView = this.rows*this.columns; float cellWidth = this.bounds.width; float cellHeight = this.bounds.height; cellWidth -= this.spacing*(this.columns-1); cellHeight -= this.spacing*(this.rows-1); cellWidth /= this.columns; cellHeight /= this.rows; int currentColumn = 0; int currentRow = 0; for(int i=0; i<c.effect.Length; i++) { if(i >= maxView) { break; } else { GUIContent gc = null; if(HUDContentType.TEXT.Equals(this.contentType)) { gc = new GUIContent(DataHolder.Effects().GetName(c.effect[i].realID)); } else if(HUDContentType.ICON.Equals(this.contentType)) { gc = new GUIContent(DataHolder.Effects().GetIcon(c.effect[i].realID)); } else if(HUDContentType.BOTH.Equals(this.contentType)) { gc = DataHolder.Effects().GetContent(c.effect[i].realID); } if(gc != null) { Rect rect = new Rect(this.bounds.x+cellWidth*currentColumn+this.spacing*currentColumn, this.bounds.y+cellHeight*currentRow+this.spacing*currentRow, cellWidth, cellHeight); Vector2 size = Vector2.zero; float gap = 0; if("" != gc.text) { size = font.GetTextSize(gc.text); if(gc.image != null) { gap = font.GetTextSize(" ").x; size.x += gap; } } if(gc.image != null) { size.x += gc.image.width; if(size.y < gc.image.height) size.y = gc.image.height; } rect = this.GetAnchoredRect(pos, size, rect); if(gc.image != null) { Texture2D tex = gc.image as Texture2D; hudTexture = TextureDrawer.AddTexture(hudTexture, new Rect(rect.x, rect.y, gc.image.width, gc.image.height), tex.GetPixels()); rect.x += gc.image.width+gap; rect.width -= gc.image.width+gap; } if("" != gc.text) { hudTexture = font.AddTextTexture(hudTexture, gc.text, rect, DataHolder.Color(this.textColor), DataHolder.Color(this.shadowColor), 0, Vector2.zero, this.showShadow, this.shadowOffset, false); } currentColumn++; } if(currentColumn >= this.columns) { currentColumn = 0; currentRow++; } } } } else if(HUDElementType.VARIABLE.Equals(this.type)) { string txt = this.GetVariableText(); if(txt != null && txt != "") { hudTexture = font.AddTextTexture(hudTexture, txt, this.GetAnchoredRect(pos, font.GetTextSize(txt), this.bounds), DataHolder.Color(this.textColor), DataHolder.Color(this.shadowColor), 0, Vector2.zero, this.showShadow, this.shadowOffset, false); } this.lastVarText = txt; } return hudTexture; }