void Start() { int ow = Screen.width; int oh = Screen.height; if (ow % 2 != 0) { ow--; } if (oh % 2 != 0) { oh--; } _Width = ow; _Height = oh; // set w/h to screen res Camera cam = GetComponent <Camera>(); //camera.transform.position = new Vector3(-0.5f, 0.5f); cam.orthographicSize = _Height / 2; /*camera.transform.Translate((float)Screen.width / 2 / 100, (float)Screen.height / 2 / 100, 0, Space.World); * camera.projectionMatrix *= Matrix4x4.Scale(new Vector3(100, -100, 1));*/ cam.transform.Translate((float)_Width / 2, (float)_Height / 2, 0, Space.World); cam.projectionMatrix *= Matrix4x4.Scale(new Vector3(1, -1, 1)); Debug.LogFormat("{0}x{1}", _Width, _Height); m_fpsr = new AllodsTextRenderer(Fonts.Font1, Font.Align.Right, _Width - 176); m_fpso = m_fpsr.GetNewGameObject(0.01f, SceneRoot.Instance.transform, 100); m_fpso.transform.position = new Vector3(0, 0, OverlayZ + 0.99f); }
public void Start() { _Instance = this; transform.localScale = new Vector3(1, 1, 0.01f); Background = GameObject.CreatePrimitive(PrimitiveType.Quad); MeshRenderer mr = Background.GetComponent <MeshRenderer>(); mr.material = new Material(MainCamera.MainShader); mr.material.SetColor("_Color", new Color(0, 0, 0, 1)); Background.transform.parent = transform; Background.transform.localPosition = new Vector3(Screen.width / 2, Screen.height / 2, 0.1f); Background.transform.localScale = new Vector3(Screen.width, Screen.height, 1); Background.name = "Background"; RendererMapName = new AllodsTextRenderer(Fonts.Font1, Font.Align.Center, Screen.width, Fonts.Font1.LineHeight, false); RendererMapName.Text = "downloading map " + FileName + "..."; ObjectMapName = RendererMapName.GetNewGameObject(0.01f, transform, 100); ObjectMapName.transform.localPosition = new Vector3(0, Screen.height / 2 - 16, -1); RendererMapPercent = new AllodsTextRenderer(Fonts.Font1, Font.Align.Center, Screen.width, Fonts.Font1.LineHeight, false); RendererMapPercent.Text = "0% complete"; RendererMapPercent.Material.color = new Color(0.6f, 0.6f, 0.6f); ObjectMapPercent = RendererMapPercent.GetNewGameObject(0.01f, transform, 100); ObjectMapPercent.transform.localPosition = new Vector3(0, Screen.height / 2, -1); }
// public static MapViewNumbers Create(float x, float y, float z, int damage, bool crit, int offsX, int offsY, Player p) { AllodsTextRenderer textRenderer = new AllodsTextRenderer(Fonts.Font2, Font.Align.Center); textRenderer.Text = crit?"CRIT ":"" + (-damage).ToString(); GameObject gObject = textRenderer.GetNewGameObject(0.01f, null, 100); MapViewNumbers mvn = gObject.AddComponent <MapViewNumbers>(); mvn.X = x; mvn.Y = y; mvn.Z = z; mvn.Number = damage; mvn.Critical = crit; mvn.Player = p; mvn.Count = 0; mvn.OffsX = offsX; mvn.OffsY = offsY; mvn.GObject = gObject; mvn.TextRenderer = textRenderer; mvn.GObject.name = string.Format("MapViewNumbers (damage = {0})", mvn.TextRenderer.Text); // return(mvn); }
public void Start() { UiManager.Instance.Subscribe(this); if (Font == null) { Font = Fonts.Font1; } EditRendererA = new AllodsTextRenderer(Font); EditObject = EditRendererA.GetNewGameObject(0.01f, transform, 100, 1); EditObject.transform.localPosition = new Vector3(0, 0, 0); EditRenderer = EditObject.GetComponent <MeshRenderer>(); EditRenderer.material.color = new Color(1, 1, 1); SelectionObject = Utils.CreateObject(); SelectionObject.transform.parent = transform; SelectionObject.transform.localScale = new Vector3(1, 1, 1); SelectionObject.transform.localPosition = new Vector3(0, 0, 0.1f); SelectionMesh = new Mesh(); MeshFilter selectionFilter = SelectionObject.AddComponent <MeshFilter>(); SelectionRenderer = SelectionObject.AddComponent <MeshRenderer>(); selectionFilter.mesh = SelectionMesh; SelectionRenderer.material = new Material(MainCamera.MainShader); Selection1 = Selection2 = 0; }
private static AllodsTextRenderer Info_Experience; // experience value private AllodsTextRenderer DisplayInfoInit(Font.Align align, int x, int y, int w, int h, Color color) { // 70 10 39 19 AllodsTextRenderer tr = new AllodsTextRenderer(Fonts.Font2, align, w, h, false); GameObject trO = tr.GetNewGameObject(0.01f, InfoObject.transform, 100, 0.2f); trO.transform.localPosition = new Vector3(x, y, 0); tr.Material.color = color; return(tr); }
public void Update() { if (Object == null || Renderer == null) { Renderer = new AllodsTextRenderer(Fonts.Font1, Font.Align.Left, Screen.width - 176 - 12, 0, true); Renderer.Text = Text; Renderer.Material.color = MsgColor; Object = Renderer.GetNewGameObject(0.01f, Instance.transform, 100, 1); } }
public void Start() { UiManager.Instance.Subscribe(this); CommandHistory.Add(""); transform.localScale = new Vector3(1, 1, 1); ConsoleHeight = Screen.height / 3; BgObject = Utils.CreatePrimitive(PrimitiveType.Quad); BgObject.name = "ConsoleBackground"; BgObject.transform.parent = transform; BgRenderer = BgObject.GetComponent <MeshRenderer>(); BgObject.transform.localPosition = new Vector3(Screen.width / 2, ConsoleHeight / 2, 0f); BgObject.transform.localScale = new Vector3(Screen.width, ConsoleHeight); BgRenderer.material = new Material(MainCamera.MainShader); BgRenderer.material.color = new Color(0, 0, 0, 0.6f); BgRenderer.enabled = false; transform.position = new Vector3(0, 0, MainCamera.MouseZ + 0.01f); // prepare text. this renderer will wrap lines based on screen width. TextRendererA = new AllodsTextRenderer(Fonts.Font2, Font.Align.Left, Screen.width - 4, 0, true); TextObject = TextRendererA.GetNewGameObject(0.01f, transform, 100); TextObject.transform.localPosition = new Vector3(2, 2, -0.001f); TextRenderer = TextObject.GetComponent <MeshRenderer>(); TextRenderer.material.color = new Color(0.8f, 0.8f, 0.8f); EditField = Utils.CreateObjectWithScript <TextField>(); EditField.transform.parent = transform; EditField.transform.localPosition = new Vector3(2, ConsoleHeight - 13, -0.001f); EditField.transform.localScale = new Vector3(1, 1, 0.001f); EditField.Font = Fonts.Font2; EditField.Prefix = "> "; EditField.Width = Screen.width - 4; EditField.Height = Fonts.Font2.LineHeight; EditField.IsFocused = true; EditField.OnReturn = () => { string cmd = EditField.Value; if (cmd.Trim().Length > 0) { WriteLine("> " + cmd); EditField.Value = ""; ExecuteCommand(cmd); CommandHistory[CommandHistory.Count - 1] = cmd; CommandHistory.Add(""); CommandHistoryPosition = CommandHistory.Count - 1; } }; WriteLine("Welcome to UnityAllods!"); }
public void Start() { if (Font == null) { Font = Fonts.Font1; } EditRendererA = new AllodsTextRenderer(Font, Font.Align.LeftRight, Width, Height, true); EditRendererA.Text = Value; EditObject = EditRendererA.GetNewGameObject(0.01f, transform, 100, 1); EditObject.transform.localPosition = new Vector3(0, 0, 0); EditRenderer = EditObject.GetComponent <MeshRenderer>(); EditRenderer.material.color = new Color32(214, 214, 214, 255); }
public void Start() { UiManager.Instance.Subscribe(this); Renderer = gameObject.AddComponent <MeshRenderer>(); Renderer.material = new Material(MainCamera.MainShader); Filter = gameObject.AddComponent <MeshFilter>(); LabelRendererA = new AllodsTextRenderer(Fonts.Font1, Font.Align.Center, Width); LabelRendererA.Text = _Text; LabelObject = LabelRendererA.GetNewGameObject(0.02f, transform, 100, 1); LabelObject.transform.localPosition = new Vector3(0, 0, 0); LabelSubObject = LabelObject.transform.GetChild(0).gameObject; LabelRenderer = LabelObject.GetComponent <MeshRenderer>(); UpdateMesh(); }
public override void OnStart() { // "Diplomacy" title AllodsTextRenderer tr_Diplomacy = new AllodsTextRenderer(Fonts.Font1, Font.Align.Center, Width * 96, 16, false); tr_Diplomacy.Text = Locale.Dialogs[145]; tr_Diplomacy.Material.color = new Color32(214, 211, 214, 255); // gray interface color GameObject go_Diplomacy = tr_Diplomacy.GetNewGameObject(0.01f, WorkingArea.transform, 100); go_Diplomacy.transform.localPosition = new Vector3(0, 0); // move slightly above. // Diplomacy subtitle: "Player .. enemy .. ally .. vision .. ignore" AllodsTextRenderer tr_Columns = new AllodsTextRenderer(Fonts.Font1, Font.Align.Left, Width * 96, 16, false); tr_Columns.Text = Locale.Dialogs[79]; tr_Columns.Material.color = new Color32(189, 158, 74, 255); GameObject go_Columns = tr_Columns.GetNewGameObject(0.01f, WorkingArea.transform, 100); go_Columns.transform.localPosition = new Vector3(-8, 28); for (int i = 0; i < 16; i++) { int y = i * 25 + 28 + 18; FieldBorder border = Utils.CreateObjectWithScript <FieldBorder>(); border.transform.parent = WorkingArea.transform; border.transform.localPosition = new Vector3(-8, y); border.Width = Width * 96 + 16; border.Height = 24; GameObject contents = Utils.CreateObject(); contents.transform.parent = border.transform; contents.transform.localPosition = new Vector3(0, 0, 0); BorderContents.Add(contents); AllodsTextRenderer tr_PlayerName = new AllodsTextRenderer(Fonts.Font1, Font.Align.Left, border.Width, 16, false); GameObject go_PlayerName = tr_PlayerName.GetNewGameObject(0.01f, contents.transform, 100); go_PlayerName.transform.localPosition = new Vector3(4, 3); PlayerNames.Add(tr_PlayerName); } Update(); }
public void Start() { UiManager.Instance.Subscribe(this); if (imgRadiob == null) { imgRadiob = Images.Load256("graphics/interface/radiob.256"); } Renderer = gameObject.AddComponent <MeshRenderer>(); Renderer.material = new Material(MainCamera.MainShaderPaletted); Renderer.material.mainTexture = imgRadiob.Atlas; Renderer.material.SetTexture("_Palette", imgRadiob.OwnPalette); Filter = gameObject.AddComponent <MeshFilter>(); LabelRendererA = new AllodsTextRenderer(Fonts.Font1, Font.Align.Left, Width); LabelRendererA.Text = _Text; LabelObject = LabelRendererA.GetNewGameObject(0.01f, transform, 100, 1); LabelObject.transform.localPosition = new Vector3(32, 0, 0); LabelSubObject = LabelObject.transform.GetChild(0).gameObject; LabelRenderer = LabelObject.GetComponent <MeshRenderer>(); UpdateMesh(); }
public void SetTooltip(string text) { if (Tooltip == null) { TooltipRendererA = new AllodsTextRenderer(Fonts.Font2, Font.Align.Left, 0, 0, false, 12); Tooltip = Utils.CreateObject(); Tooltip.transform.parent = transform; TooltipRenderer = Tooltip.AddComponent <MeshRenderer>(); TooltipFilter = Tooltip.AddComponent <MeshFilter>(); TooltipBall = Images.LoadImage("graphics/interface/ball.bmp", 0, Images.ImageType.AllodsBMP); Material[] materials = new Material[] { new Material(MainCamera.MainShader), new Material(MainCamera.MainShader) }; materials[0].mainTexture = TooltipBall; TooltipRenderer.materials = materials; GameObject TooltipText = TooltipRendererA.GetNewGameObject(0.01f, Tooltip.transform, 100); TooltipRendererA.Material.color = new Color32(165, 121, 49, 255); TooltipText.transform.localPosition = new Vector3(6, 6, -0.02f); } Tooltip.SetActive(true); float topX = lastMouseX; float topY = lastMouseY; text = text.Replace('#', '\n').Replace("~", ""); TooltipRendererA.Text = text; // ideal position for the tooltip is top/right of the mouse. // but if it doesn't fit, should be moved around. topX = lastMouseX; topY = lastMouseY - TooltipRendererA.Height - 12; float fw = TooltipRendererA.ActualWidth + 12; float fh = TooltipRendererA.Height + 12; if (topX + fw > MainCamera.Width) { topX = MainCamera.Width - fw; } if (topY + fh > MainCamera.Height) { topY = MainCamera.Height - fh; } if (topX < 0) { topX = 0; } if (topY < 0) { topY = 0; } Tooltip.transform.localPosition = new Vector3(topX, topY, MainCamera.MouseZ + 0.01f); TooltipBuilder.Reset(); TooltipBuilder.AddQuad(0, 0, 0, 4, 4); TooltipBuilder.AddQuad(0, TooltipRendererA.ActualWidth + 8, 0, 4, 4); TooltipBuilder.AddQuad(0, TooltipRendererA.ActualWidth + 8, TooltipRendererA.Height + 6, 4, 4); TooltipBuilder.AddQuad(0, 0, TooltipRendererA.Height + 6, 4, 4); // now render border quads float bw = TooltipRendererA.ActualWidth + 6; float bh = TooltipRendererA.Height + 6 - 2; // 2 = difference between "LineHeight" and our custom LineHeight of 12 // top border bright TooltipBuilder.CurrentMesh = 1; TooltipBuilder.CurrentColor = new Color32(165, 121, 49, 255); TooltipBuilder.CurrentPosition = new Vector3(3, 1); TooltipBuilder.NextVertex(); TooltipBuilder.CurrentColor = new Color32(165, 121, 49, 255); TooltipBuilder.CurrentPosition = new Vector3(3 + bw, 1); TooltipBuilder.NextVertex(); // top border dark TooltipBuilder.CurrentColor = new Color32(82, 60, 24, 255); TooltipBuilder.CurrentPosition = new Vector3(3 + bw, 1 + 2); TooltipBuilder.NextVertex(); TooltipBuilder.CurrentColor = new Color32(82, 60, 24, 255); TooltipBuilder.CurrentPosition = new Vector3(3, 1 + 2); TooltipBuilder.NextVertex(); // bottom border bright TooltipBuilder.CurrentMesh = 1; TooltipBuilder.CurrentColor = new Color32(165, 121, 49, 255); TooltipBuilder.CurrentPosition = new Vector3(3, 3 + bh); TooltipBuilder.NextVertex(); TooltipBuilder.CurrentColor = new Color32(165, 121, 49, 255); TooltipBuilder.CurrentPosition = new Vector3(3 + bw, 3 + bh); TooltipBuilder.NextVertex(); // bottom border dark TooltipBuilder.CurrentColor = new Color32(82, 60, 24, 255); TooltipBuilder.CurrentPosition = new Vector3(3 + bw, 3 + bh + 2); TooltipBuilder.NextVertex(); TooltipBuilder.CurrentColor = new Color32(82, 60, 24, 255); TooltipBuilder.CurrentPosition = new Vector3(3, 3 + bh + 2); TooltipBuilder.NextVertex(); // left border bright TooltipBuilder.CurrentMesh = 1; TooltipBuilder.CurrentColor = new Color32(165, 121, 49, 255); TooltipBuilder.CurrentPosition = new Vector3(1, 3); TooltipBuilder.NextVertex(); TooltipBuilder.CurrentColor = new Color32(165, 121, 49, 255); TooltipBuilder.CurrentPosition = new Vector3(1, 3 + bh); TooltipBuilder.NextVertex(); // left border dark TooltipBuilder.CurrentColor = new Color32(82, 60, 24, 255); TooltipBuilder.CurrentPosition = new Vector3(1 + 2, 3 + bh); TooltipBuilder.NextVertex(); TooltipBuilder.CurrentColor = new Color32(82, 60, 24, 255); TooltipBuilder.CurrentPosition = new Vector3(1 + 2, 3); TooltipBuilder.NextVertex(); // right border bright TooltipBuilder.CurrentMesh = 1; TooltipBuilder.CurrentColor = new Color32(165, 121, 49, 255); TooltipBuilder.CurrentPosition = new Vector3(3 + bw, 3); TooltipBuilder.NextVertex(); TooltipBuilder.CurrentColor = new Color32(165, 121, 49, 255); TooltipBuilder.CurrentPosition = new Vector3(3 + bw, 3 + bh); TooltipBuilder.NextVertex(); // right border dark TooltipBuilder.CurrentColor = new Color32(82, 60, 24, 255); TooltipBuilder.CurrentPosition = new Vector3(3 + bw + 2, 3 + bh); TooltipBuilder.NextVertex(); TooltipBuilder.CurrentColor = new Color32(82, 60, 24, 255); TooltipBuilder.CurrentPosition = new Vector3(3 + bw + 2, 3); TooltipBuilder.NextVertex(); // BACKGROUND QUAD TooltipBuilder.AddQuad(TooltipBuilder.CurrentMesh, 3, 3, bw, bh, new Color32(33, 44, 33, 255)); TooltipFilter.mesh = TooltipBuilder.ToMesh(MeshTopology.Quads, MeshTopology.Quads); }
public void Update() { // update text if (TextObjects.Count != InvWidth * InvHeight || TextRenderers.Count != InvWidth * InvHeight) { for (int i = 0; i < TextRenderers.Count; i++) { TextRenderers[i].DestroyImmediate(); } TextObjects.Clear(); TextRenderers.Clear(); for (int ly = 0; ly < InvHeight; ly++) { for (int lx = 0; lx < InvWidth; lx++) { AllodsTextRenderer atr = new AllodsTextRenderer(Fonts.Font2); atr.Text = ""; atr.Material.color = new Color32(0xBD, 0x9E, 0x4A, 0xFF); GameObject go = atr.GetNewGameObject(0.01f, transform, 100, 0.01f); TextObjects.Add(go); TextRenderers.Add(atr); go.transform.localPosition = new Vector3((lx * 80 + 6) * InvScale, (ly * 80 + 80 - 4) * InvScale - atr.Font.LineHeight, -0.2f); } } } // first submesh = quads, item background // second submesh = lines, item magic glow // third submesh = quads, item pictures if (Pack == null) { Filter.mesh.Clear(); return; } Builder.Reset(); int start = Math.Max(Math.Min(Scroll, Pack.Count - InvWidth * InvHeight), 0); int end = Math.Min(start + InvWidth * InvHeight, Pack.Count); int x = 0; int y = 0; for (int i = start; i < end; i++) { Builder.AddQuad(y * InvWidth + x, (x * 80) * InvScale, (y * 80) * InvScale, 80 * InvScale, 80 * InvScale, new Rect(0, 0, 1, 1)); // check texture. // for now, just put generic background Renderer.materials[y * InvWidth + x].mainTexture = img_BackInv; x++; if (x >= InvWidth) { x = 0; y++; } } for (int i = 0; i < TextObjects.Count; i++) { TextObjects[i].SetActive(false); } // now add magic glow where it should be x = 0; y = 0; UpdateMGlow(); // per-widget unique animation is used. int rnd = 0; for (int i = start; i < end; i++) { // check if item has special effects Item item = Pack[i]; if (item.MagicEffects.Count > 0) { float baseX = x * 80 * InvScale; float baseY = y * 80 * InvScale; Builder.CurrentMesh = InvWidth * InvHeight * 2; foreach (MGlowPart part in MGlowParts) { // draw all glow parts // left Builder.CurrentPosition = new Vector3(baseX + part.x, baseY + part.y); Builder.CurrentColor = new Color32(208, 0, 208, 255); Builder.NextVertex(); Builder.CurrentPosition = new Vector3(baseX + part.x - 2f * part.state, baseY + part.y); Builder.CurrentColor = new Color32(64, 0, 64, 255); Builder.NextVertex(); // right Builder.CurrentPosition = new Vector3(baseX + part.x, baseY + part.y); Builder.CurrentColor = new Color32(208, 0, 208, 255); Builder.NextVertex(); Builder.CurrentPosition = new Vector3(baseX + part.x + 2f * part.state, baseY + part.y); Builder.CurrentColor = new Color32(64, 0, 64, 255); Builder.NextVertex(); // top Builder.CurrentPosition = new Vector3(baseX + part.x, baseY + part.y); Builder.CurrentColor = new Color32(208, 0, 208, 255); Builder.NextVertex(); Builder.CurrentPosition = new Vector3(baseX + part.x, baseY + part.y - 2f * part.state); Builder.CurrentColor = new Color32(64, 0, 64, 255); Builder.NextVertex(); // bottom Builder.CurrentPosition = new Vector3(baseX + part.x, baseY + part.y); Builder.CurrentColor = new Color32(208, 0, 208, 255); Builder.NextVertex(); Builder.CurrentPosition = new Vector3(baseX + part.x, baseY + part.y + 2f * part.state); Builder.CurrentColor = new Color32(64, 0, 64, 255); Builder.NextVertex(); } } int dcount = item.Count; if (UiManager.Instance.DragItem == item) { dcount -= UiManager.Instance.DragItemCount; } if (dcount > 1) { TextRenderers[rnd].Text = dcount.ToString(); TextObjects[rnd].SetActive(true); } rnd++; x++; if (x >= InvWidth) { x = 0; y++; } } // add item pictures x = 0; y = 0; for (int i = start; i < end; i++) { Item item = Pack[i]; item.Class.File_Pack.UpdateSprite(); // check texture. // for now, just put generic background Renderer.materials[InvWidth * InvHeight + y * InvWidth + x].mainTexture = item.Class.File_Pack.File.Atlas; Renderer.materials[InvWidth * InvHeight + y * InvWidth + x].SetTexture("_Palette", item.Class.File_Pack.File.OwnPalette); Color color = new Color(1, 1, 1, (item == UiManager.Instance.DragItem) ? 0.25f : 1); // draw dragged items half transparent Builder.AddQuad(InvWidth * InvHeight + y * InvWidth + x, (x * 80) * InvScale, (y * 80) * InvScale, 80 * InvScale, 80 * InvScale, item.Class.File_Pack.File.AtlasRects[0], color); x++; if (x >= InvWidth) { x = 0; y++; } } MeshTopology[] topologies = new MeshTopology[InvWidth * InvHeight * 2 + 1]; for (int i = 0; i < InvWidth * InvHeight; i++) { topologies[i] = MeshTopology.Quads; topologies[InvWidth * InvHeight + i] = MeshTopology.Quads; } topologies[InvWidth * InvHeight * 2] = MeshTopology.Lines; Builder.CurrentMesh = topologies.Length - 1; Filter.mesh = Builder.ToMesh(topologies); }
public void DisplayInfo(bool on, Transform parent) { if (on) { if (InfoObject == null) { InfoObject = Utils.CreateObject(); InfoObject.name = "MapViewUnit$InfoText"; Color colorCaption = new Color32(0xBD, 0x9E, 0x4A, 0xFF); Color colorValue = new Color32(0x6B, 0x9A, 0x7B, 0xFF); Info_Name = DisplayInfoInit(Font.Align.Center, 39, 19, 70, 10, colorCaption); Info_LifeCaption = DisplayInfoInit(Font.Align.Center, 85, 45, 58, 10, colorCaption); Info_Life = DisplayInfoInit(Font.Align.Center, 85, 45, 58, 10, colorValue); Info_BRMSCaption = DisplayInfoInit(Font.Align.Left, 7, 45, 73, 39, colorCaption); Info_BRMS = DisplayInfoInit(Font.Align.Right, 7, 45, 73, 39, colorValue); Info_DamageCaption = DisplayInfoInit(Font.Align.Left, 7, 89, 63, 18, colorCaption); Info_Damage = DisplayInfoInit(Font.Align.Right, 7, 89, 63, 18, colorValue); Info_DefenseCaption = DisplayInfoInit(Font.Align.Left, 75, 89, 65, 18, colorCaption); Info_Defense = DisplayInfoInit(Font.Align.Right, 75, 89, 65, 18, colorValue); Info_ResistCaptionMain = DisplayInfoInit(Font.Align.Left, 75, 113, 65, 8, new Color32(0x94, 0x59, 0x00, 0xFF)); Info_ResistCaption = DisplayInfoInit(Font.Align.Left, 75, 123, 65, 48, colorCaption); Info_Resist = DisplayInfoInit(Font.Align.Right, 75, 123, 65, 48, colorValue); Info_SkillCaptionMain = DisplayInfoInit(Font.Align.Left, 7, 113, 63, 8, new Color32(0x94, 0x59, 0x00, 0xFF)); Info_SkillCaption = DisplayInfoInit(Font.Align.Left, 7, 123, 63, 48, colorCaption); Info_Skill = DisplayInfoInit(Font.Align.Right, 7, 123, 63, 48, colorValue); Info_ScanSpeedCaption = DisplayInfoInit(Font.Align.Left, 41, 201, 65, 18, colorCaption); Info_ScanSpeed = DisplayInfoInit(Font.Align.Right, 41, 201, 65, 18, colorValue); Info_ExperienceCaption = DisplayInfoInit(Font.Align.Left, 16, 187, 110, 8, colorCaption); Info_Experience = DisplayInfoInit(Font.Align.Right, 16, 187, 110, 8, colorValue); } InfoObject.transform.parent = parent; InfoObject.transform.localPosition = new Vector3(0, 0, -0.2f); InfoObject.transform.localScale = new Vector3(1, 1, 1); InfoObject.SetActive(true); if (LogicUnit.Player != null && LogicUnit.Player.Avatar == LogicUnit) { Info_Name.Text = LogicUnit.Player.Name; } else { Info_Name.Text = "\n" + Locale.UnitName[LogicUnit.Class.ID]; } string lifeCaption = Locale.Main[19]; string lifeValue = string.Format("\n{0}/{1}", LogicUnit.Stats.Health, LogicUnit.Stats.HealthMax); if (LogicUnit.Stats.ManaMax > 0) { lifeCaption += "\n\n" + Locale.Main[20]; lifeValue += string.Format("\n\n{0}/{1}", LogicUnit.Stats.Mana, LogicUnit.Stats.ManaMax); } Info_LifeCaption.Text = lifeCaption; Info_Life.Text = lifeValue; Info_BRMSCaption.Text = string.Format("{0}\n{1}\n{2}\n{3}", Locale.Main[15], Locale.Main[16], Locale.Main[17], Locale.Main[18]); Info_BRMS.Text = string.Format("{0}\n{1}\n{2}\n{3}", LogicUnit.Stats.Body, LogicUnit.Stats.Reaction, LogicUnit.Stats.Mind, LogicUnit.Stats.Spirit); Info_DamageCaption.Text = string.Format("{0}\n{1}", Locale.Main[23], Locale.Main[25]); Info_Damage.Text = string.Format("{0}-{1}\n{2}", LogicUnit.Stats.DamageMin, LogicUnit.Stats.DamageMax, LogicUnit.Stats.ToHit); Info_DefenseCaption.Text = string.Format("{0}\n{1}", Locale.Main[24], Locale.Main[26]); Info_Defense.Text = string.Format("{0}\n{1}", LogicUnit.Stats.Absorbtion, LogicUnit.Stats.Defence); Info_ResistCaptionMain.Text = Locale.Main[28]; Info_ResistCaption.Text = string.Format("{0}\n{1}\n{2}\n{3}\n{4}", Locale.Main[41], Locale.Main[42], Locale.Main[43], Locale.Main[44], Locale.Main[45]); Info_Resist.Text = string.Format("{0}\n{1}\n{2}\n{3}\n{4}", LogicUnit.Stats.ProtectionFire, LogicUnit.Stats.ProtectionWater, LogicUnit.Stats.ProtectionAir, LogicUnit.Stats.ProtectionEarth, LogicUnit.Stats.ProtectionAstral); // parts of human info here. if (LogicUnit is MapHuman) { Info_SkillCaptionMain.Text = Locale.Main[27]; MapHuman human = (MapHuman)LogicUnit; if ((human.Gender & MapHuman.GenderFlags.Mage) != 0) { Info_SkillCaption.Text = string.Format("{0}\n{1}\n{2}\n{3}\n{4}", Locale.Main[36], Locale.Main[37], Locale.Main[38], Locale.Main[39], Locale.Main[40]); Info_Skill.Text = string.Format("{0}\n{1}\n{2}\n{3}\n{4}", LogicUnit.Stats.SkillFire, LogicUnit.Stats.SkillWater, LogicUnit.Stats.SkillAir, LogicUnit.Stats.SkillEarth, LogicUnit.Stats.SkillAstral); } else if ((human.Gender & MapHuman.GenderFlags.Fighter) != 0) { Info_SkillCaption.Text = string.Format("{0}\n{1}\n{2}\n{3}\n{4}", Locale.Main[30], Locale.Main[31], Locale.Main[32], Locale.Main[33], Locale.Main[34]); Info_Skill.Text = string.Format("{0}\n{1}\n{2}\n{3}\n{4}", LogicUnit.Stats.SkillBlade, LogicUnit.Stats.SkillAxe, LogicUnit.Stats.SkillBludgeon, LogicUnit.Stats.SkillPike, LogicUnit.Stats.SkillShooting); } else { Info_SkillCaptionMain.Text = Locale.Main[28]; Info_SkillCaption.Text = string.Format("{0}\n{1}\n{2}\n{3}\n{4}", Locale.Main[30], Locale.Main[31], Locale.Main[32], Locale.Main[33], Locale.Main[34]); Info_Skill.Text = string.Format("{0}\n{1}\n{2}\n{3}\n{4}", LogicUnit.Stats.ProtectionBlade, LogicUnit.Stats.ProtectionAxe, LogicUnit.Stats.ProtectionBludgeon, LogicUnit.Stats.ProtectionPike, LogicUnit.Stats.ProtectionShooting); } // display exp Info_ExperienceCaption.Text = Locale.Main[46]; Info_Experience.Text = human.GetExperience().ToString(); } else { Info_SkillCaptionMain.Text = Locale.Main[28]; Info_SkillCaption.Text = string.Format("{0}\n{1}\n{2}\n{3}\n{4}", Locale.Main[30], Locale.Main[31], Locale.Main[32], Locale.Main[33], Locale.Main[34]); Info_Skill.Text = string.Format("{0}\n{1}\n{2}\n{3}\n{4}", LogicUnit.Stats.ProtectionBlade, LogicUnit.Stats.ProtectionAxe, LogicUnit.Stats.ProtectionBludgeon, LogicUnit.Stats.ProtectionPike, LogicUnit.Stats.ProtectionShooting); Info_ExperienceCaption.Text = Info_Experience.Text = ""; } Info_ScanSpeedCaption.Text = string.Format("{0}\n{1}", Locale.Main[21], Locale.Main[22]); Info_ScanSpeed.Text = string.Format("{0:F1}\n{1}", LogicUnit.Stats.ScanRange, LogicUnit.Stats.Speed); } else { if (InfoObject != null) { InfoObject.SetActive(false); } } }
private void UpdateHpMesh() { // put player nickname if this unit is an Avatar if (LogicUnit.Player != null && LogicUnit.Player.Avatar == LogicUnit) { if (PlayerNick == null) { PlayerNick = new AllodsTextRenderer(Fonts.Font2, Font.Align.Center, LogicUnit.Class.SelectionX2 - LogicUnit.Class.SelectionX1, 0, false); PlayerNickObject = PlayerNick.GetNewGameObject(0, transform, 100); PlayerNickObject.SetActive(LogicUnit.IsAlive); } PlayerNick.Text = LogicUnit.Player.Name; PlayerNick.Material.color = Player.AllColors[LogicUnit.Player.Color]; } if (HpBall == null) { HpBall = Images.LoadImage("graphics/interface/ball.bmp", 0, Images.ImageType.AllodsBMP); } if (HpMat1 == null) { HpMat1 = new Material(MainCamera.MainShader); HpMat1.mainTexture = HpBall; } if (HpMat2 == null) { HpMat2 = new Material(MainCamera.MainShader); } int hpHeight = 4; if (LogicUnit.Stats.ManaMax > 0 || LogicUnit.SummonTimeMax > 0) { hpHeight += 4; } if (HpObject == null) { HpObject = Utils.CreateObject(); HpObject.name = "Health"; HpRenderer = HpObject.AddComponent <MeshRenderer>(); HpFilter = HpObject.AddComponent <MeshFilter>(); HpRenderer.enabled = LogicUnit.IsAlive; HpMesh = new Mesh(); HpFilter.mesh = HpMesh; HpObject.transform.parent = transform; HpObject.transform.localScale = new Vector3(1, 1, 1); HpRenderer.materials = new Material[] { HpMat1, HpMat2 }; } HpObject.transform.localPosition = new Vector3(0, -hpHeight, -64); HpMesh.Clear(); int vcnt = 4 * 8; // if (LogicUnit.Stats.ManaMax > 0 || LogicUnit.SummonTimeMax > 0) { vcnt += 4 * 8; // } Vector3[] qv = new Vector3[vcnt]; Vector2[] quv = new Vector2[vcnt]; Color[] qc = new Color[vcnt]; int pp = 0, ppt = pp, ppc = pp; int x = LogicUnit.Class.SelectionX1; int y = LogicUnit.Class.SelectionY1; int w = LogicUnit.Class.SelectionX2 - LogicUnit.Class.SelectionX1; int w2 = w - 8; if (PlayerNickObject != null && PlayerNick != null) { PlayerNickObject.transform.localPosition = new Vector3(x, y - PlayerNick.Height - 1 - hpHeight, -64); } float row1 = (float)LogicUnit.Stats.Health / LogicUnit.Stats.HealthMax; float row2 = 0; bool row2alternate = false; Utils.PutQuadInMesh(qv, quv, qc, ref pp, ref ppt, ref ppc, x, y, 4, 4, new Rect(0, 0, 1, 1), new Color(1, 1, 1, 1)); Utils.PutQuadInMesh(qv, quv, qc, ref pp, ref ppt, ref ppc, x + w - 4, y, 4, 4, new Rect(0, 0, 1, 1), new Color(1, 1, 1, 1)); if (LogicUnit.Stats.ManaMax > 0) { Utils.PutQuadInMesh(qv, quv, qc, ref pp, ref ppt, ref ppc, x, y + 4, 4, 4, new Rect(0, 0, 1, 1), new Color(1, 1, 1, 1)); Utils.PutQuadInMesh(qv, quv, qc, ref pp, ref ppt, ref ppc, x + w - 4, y + 4, 4, 4, new Rect(0, 0, 1, 1), new Color(1, 1, 1, 1)); row2 = (float)LogicUnit.Stats.Mana / LogicUnit.Stats.ManaMax; } else if (LogicUnit.SummonTimeMax > 0) { Utils.PutQuadInMesh(qv, quv, qc, ref pp, ref ppt, ref ppc, x, y + 4, 4, 4, new Rect(0, 0, 1, 1), new Color(1, 1, 1, 1)); Utils.PutQuadInMesh(qv, quv, qc, ref pp, ref ppt, ref ppc, x + w - 4, y + 4, 4, 4, new Rect(0, 0, 1, 1), new Color(1, 1, 1, 1)); row2 = 1f - ((float)LogicUnit.SummonTime / LogicUnit.SummonTimeMax); row2alternate = true; } for (int i = 0; i < vcnt; i += 4 * 8) { int lpp = i + vcnt / 4; int lppc = i + vcnt / 4; if (i >= 4 * 8) { y += 4; // mana is +5px } qv[lpp++] = new Vector3(x + 4, y); qv[lpp++] = new Vector3(x + w - 4, y); qv[lpp++] = new Vector3(x + w - 4, y + 4); qv[lpp++] = new Vector3(x + 4, y + 4); qc[lppc++] = new Color(0.3f, 0.3f, 0.3f, 0.5f); qc[lppc++] = new Color(0.3f, 0.3f, 0.3f, 0.5f); qc[lppc++] = new Color(0.3f, 0.3f, 0.3f, 0.5f); qc[lppc++] = new Color(0.3f, 0.3f, 0.3f, 0.5f); float lcnt = (i >= 4 * 8) ? row2 : row1; if (lcnt < 0) { lcnt = 0; } Color clBase = new Color(0, 1, 0, 1); if (i >= 4 * 8) { clBase = row2alternate ? new Color(1, 0, 1, 1) : new Color(0, 0, 1, 1); } else if (lcnt < 0.33) { clBase = new Color(1, 0, 0, 1); } else if (lcnt < 0.66) { clBase = new Color(1, 1, 0, 1); } Color clDk1 = clBase / 2; clDk1.a = 1; Color clDk2 = clBase / 3; clDk2.a = 1; qv[lpp++] = new Vector3(x + 4, y); qv[lpp++] = new Vector3(x + 4 + w2 * lcnt, y); qv[lpp++] = new Vector3(x + 4 + w2 * lcnt, y + 4); qv[lpp++] = new Vector3(x + 4, y + 4); qc[lppc++] = clDk2; qc[lppc++] = clDk2; qc[lppc++] = clDk2; qc[lppc++] = clDk2; qv[lpp++] = new Vector3(x + 4, y + 1); qv[lpp++] = new Vector3(x + 4 + w2 * lcnt, y + 1); qv[lpp++] = new Vector3(x + 4 + w2 * lcnt, y + 3); qv[lpp++] = new Vector3(x + 4, y + 3); qc[lppc++] = clBase; qc[lppc++] = clBase; qc[lppc++] = clDk1; qc[lppc++] = clDk1; } HpMesh.vertices = qv; HpMesh.uv = quv; HpMesh.colors = qc; HpMesh.subMeshCount = 2; int[] qt = new int[vcnt / 4]; for (int i = 0; i < qt.Length; i++) { qt[i] = i; } HpMesh.SetIndices(qt, MeshTopology.Quads, 0); int[] qt2 = new int[vcnt - qt.Length]; for (int i = 0; i < qt2.Length; i++) { qt2[i] = qt.Length + i; } HpMesh.SetIndices(qt2, MeshTopology.Quads, 1); HpFilter.mesh = HpMesh; }