Aimbot Enviroment very first
Basic environment include Multi scene, Reward Change, Visible chart, etc....
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// Title component, including main title and subtitle.
|
||||
/// |标题组件,包含主标题和副标题。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[ComponentHandler(typeof(TitleHander), true)]
|
||||
public class Title : MainComponent, IPropertyChanged
|
||||
{
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private string m_Text = "Chart Title";
|
||||
[SerializeField] private string m_SubText = "";
|
||||
[SerializeField] private LabelStyle m_LabelStyle = new LabelStyle();
|
||||
[SerializeField] private LabelStyle m_SubLabelStyle = new LabelStyle();
|
||||
[SerializeField] private float m_ItemGap = 0;
|
||||
[SerializeField] private Location m_Location = Location.defaultTop;
|
||||
|
||||
/// <summary>
|
||||
/// [default:true]
|
||||
/// Set this to false to prevent the title from showing.
|
||||
/// |是否显示标题组件。
|
||||
/// </summary>
|
||||
public bool show { get { return m_Show; } set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); } }
|
||||
/// <summary>
|
||||
/// The main title text, supporting \n for newlines.
|
||||
/// |主标题文本,支持使用 \n 换行。
|
||||
/// </summary>
|
||||
public string text { get { return m_Text; } set { if (PropertyUtil.SetClass(ref m_Text, value)) SetComponentDirty(); } }
|
||||
/// <summary>
|
||||
/// The text style of main title.
|
||||
/// |主标题文本样式。
|
||||
/// </summary>
|
||||
public LabelStyle labelStyle
|
||||
{
|
||||
get { return m_LabelStyle; }
|
||||
set { if (PropertyUtil.SetClass(ref m_LabelStyle, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Subtitle text, supporting for \n for newlines.
|
||||
/// |副标题文本,支持使用 \n 换行。
|
||||
/// </summary>
|
||||
public string subText
|
||||
{
|
||||
get { return m_SubText; }
|
||||
set { if (PropertyUtil.SetClass(ref m_SubText, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The text style of sub title.
|
||||
/// |副标题文本样式。
|
||||
/// </summary>
|
||||
public LabelStyle subLabelStyle
|
||||
{
|
||||
get { return m_SubLabelStyle; }
|
||||
set { if (PropertyUtil.SetClass(ref m_SubLabelStyle, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// [default:8]
|
||||
/// The gap between the main title and subtitle.
|
||||
/// |主副标题之间的间距。
|
||||
/// </summary>
|
||||
public float itemGap
|
||||
{
|
||||
get { return m_ItemGap; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ItemGap, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The location of title component.
|
||||
/// |标题显示位置。
|
||||
/// </summary>
|
||||
public Location location
|
||||
{
|
||||
get { return m_Location; }
|
||||
set { if (PropertyUtil.SetClass(ref m_Location, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
public override bool vertsDirty { get { return false; } }
|
||||
public override bool componentDirty
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_ComponentDirty ||
|
||||
location.componentDirty ||
|
||||
m_LabelStyle.componentDirty ||
|
||||
m_SubLabelStyle.componentDirty;
|
||||
}
|
||||
}
|
||||
|
||||
public override void ClearComponentDirty()
|
||||
{
|
||||
base.ClearComponentDirty();
|
||||
location.ClearComponentDirty();
|
||||
m_LabelStyle.ClearComponentDirty();
|
||||
m_SubLabelStyle.ClearComponentDirty();
|
||||
}
|
||||
|
||||
public void OnChanged()
|
||||
{
|
||||
m_Location.OnChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0c4f5a39710624b94a3d015eb552f53a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,88 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
[UnityEngine.Scripting.Preserve]
|
||||
internal sealed class TitleHander : MainComponentHandler<Title>
|
||||
{
|
||||
private static readonly string s_TitleObjectName = "title";
|
||||
private static readonly string s_SubTitleObjectName = "title_sub";
|
||||
private ChartLabel m_LabelObject;
|
||||
private ChartLabel m_SubLabelObject;
|
||||
|
||||
public override void InitComponent()
|
||||
{
|
||||
var title = component;
|
||||
title.painter = null;
|
||||
title.refreshComponent = delegate()
|
||||
{
|
||||
title.OnChanged();
|
||||
var anchorMin = title.location.runtimeAnchorMin;
|
||||
var anchorMax = title.location.runtimeAnchorMax;
|
||||
var pivot = title.location.runtimePivot;
|
||||
var objName = ChartCached.GetComponentObjectName(title);
|
||||
var titleObject = ChartHelper.AddObject(objName, chart.transform, anchorMin, anchorMax,
|
||||
pivot, chart.chartSizeDelta);
|
||||
title.gameObject = titleObject;
|
||||
title.gameObject.transform.SetSiblingIndex(chart.m_PainterTop.transform.GetSiblingIndex() + 1);
|
||||
anchorMin = title.location.runtimeAnchorMin;
|
||||
anchorMax = title.location.runtimeAnchorMax;
|
||||
pivot = title.location.runtimePivot;
|
||||
var fontSize = title.labelStyle.textStyle.GetFontSize(chart.theme.title);
|
||||
ChartHelper.UpdateRectTransform(titleObject, anchorMin, anchorMax, pivot, new Vector2(chart.chartWidth, chart.chartHeight));
|
||||
var titlePosition = chart.GetTitlePosition(title);
|
||||
var subTitlePosition = -new Vector3(0, fontSize + title.itemGap, 0);
|
||||
|
||||
titleObject.transform.localPosition = titlePosition;
|
||||
titleObject.hideFlags = chart.chartHideFlags;
|
||||
ChartHelper.HideAllObject(titleObject);
|
||||
|
||||
m_LabelObject = ChartHelper.AddChartLabel(s_TitleObjectName, titleObject.transform, title.labelStyle, chart.theme.title,
|
||||
GetTitleText(title), Color.clear, title.location.runtimeTextAlignment);
|
||||
m_LabelObject.SetActive(title.show && title.labelStyle.show);
|
||||
|
||||
m_SubLabelObject = ChartHelper.AddChartLabel(s_SubTitleObjectName, titleObject.transform, title.subLabelStyle, chart.theme.subTitle,
|
||||
GetSubTitleText(title), Color.clear, title.location.runtimeTextAlignment);
|
||||
m_SubLabelObject.SetActive(title.show && title.subLabelStyle.show);
|
||||
m_SubLabelObject.transform.localPosition = subTitlePosition + title.subLabelStyle.offset;
|
||||
};
|
||||
title.refreshComponent();
|
||||
}
|
||||
|
||||
public override void OnSerieDataUpdate(int serieIndex)
|
||||
{
|
||||
if (m_LabelObject != null && FormatterHelper.NeedFormat(component.text))
|
||||
m_LabelObject.SetText(GetTitleText(component));
|
||||
if (m_SubLabelObject != null && FormatterHelper.NeedFormat(component.subText))
|
||||
m_SubLabelObject.SetText(GetSubTitleText(component));
|
||||
}
|
||||
|
||||
private string GetTitleText(Title title)
|
||||
{
|
||||
if (FormatterHelper.NeedFormat(title.text))
|
||||
{
|
||||
var content = title.text;
|
||||
FormatterHelper.ReplaceContent(ref content, 0, title.labelStyle.numericFormatter, null, chart);
|
||||
return content;
|
||||
}
|
||||
else
|
||||
{
|
||||
return title.text;
|
||||
}
|
||||
}
|
||||
|
||||
private string GetSubTitleText(Title title)
|
||||
{
|
||||
if (FormatterHelper.NeedFormat(title.subText))
|
||||
{
|
||||
var content = title.subText;
|
||||
FormatterHelper.ReplaceContent(ref content, 0, title.subLabelStyle.numericFormatter, null, chart);
|
||||
return content;
|
||||
}
|
||||
else
|
||||
{
|
||||
return title.subText;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cbe3062b7770040e6b4a98026f0ad044
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// the title of serie.
|
||||
/// |标题相关设置。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TitleStyle : LabelStyle, ISerieDataComponent, ISerieExtraComponent
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cd97375f7d84f4fd18dab048c465cdd8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user