unityzgy/Assets/Scripts/GameObjectCtrl/AreaFlageCtrl.cs
ayuan9957 bf12e02276 feat: 多语言本地化系统 - 支持中/英/法/俄实时切换
- LocalizationManager: 新增翻译表(SetFormatted/SetDuration/LocalizeOperateMsg)
- LoginPanel: InputField placeholder本地化、字体颜色保持
- HistoryPanel: 用时数据本地化、placeholder本地化
- RecordDetailPanel: 操作详情消息本地化(LanguageChanged重建)
- AppraiseWindowBase: 评价等级本地化、操作消息重建
- EditorAppraiser: 所有评估消息改用InjectOperateMsgLocalized
- StudentOperateRecorder: 新增InjectOperateMsgLocalized方法
- LocalizationLanguageTestBar: 单例模式、ScreenSpaceOverlay筛选
- 字体切换时保留颜色和verticalOverflow
2026-07-16 10:05:59 +08:00

168 lines
4.6 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using XFramework.NetOuter;
//一区九厂标记旗帜
public class AreaFlageCtrl : MonoBehaviour,IPicked,IBindIcon
{
public Text3DCtrl [] text3DCtrl;
private bool canPick;
private StudentButtonIcon buttonIcon;
private string areaName;
private IconBase thisIcon;
bool firstSet = true;
float radius = 50;//厂区半径
public string AreaName
{
get
{
return areaName;
}
}
public float Radius
{
get
{
return radius;
}
}
private void Start()
{
canPick = true;//默认物体能被捡起
}
public bool CanPickDown()
{
return true;
}
//改变当前物体是否能够被捡起
public void ChangePicked(bool can)
{
canPick = can;
}
//不一定所有的时候都能捡起
public bool CanPickUpByRay()
{
return canPick;
}
public void InitFlage(StudentButtonIcon studentButtonIcon)
{
if (buttonIcon&&buttonIcon != studentButtonIcon)//未完成放置时 又发起了新的生成指令 不做任何处理
{
//buttonIcon.SetInteractable(true);
return;
}
buttonIcon = studentButtonIcon;
buttonIcon.SetInteractable(false);
areaName = studentButtonIcon.text_IconName.text;
for (int i = 0; i < text3DCtrl.Length; i++)
{
text3DCtrl[i].SetName(areaName);
}
}
//同步生成时调用
public void SyncInitFlage(string areaName, XFramework.TransGesture trans)
{
this.areaName = areaName;
this.transform.position = trans.GetPos();
for (int i = 0; i < text3DCtrl.Length; i++)
{
text3DCtrl[i].SetName(areaName);
}
PickDown();//同步生产默认在地上
this.gameObject.AddComponent<AreaFlageSyncHandler>();
}
//同步更新位置
public void SyncUpdatePos(Vector3 postion)
{
this.transform.position = postion;
thisIcon?.SetUpdateIconMsg(this.transform.position, "UpdatePos");//更新UI位置
}
//同步更新位置
public void SyncDestory()
{
Destroy(this.gameObject);
}
//放置在地上
public void PickDown()
{
GameObjectManager.Instance.AddPlannedArea(this);//添加安置记录
if (firstSet)//首次放置在地上
{
firstSet = false;
EventCenter.Instance.EventTrigger<IBindIcon>("CreatAreaFlageIcon", this);//发起创建UI指令
if (GroupLearnHelper.isMaster)//分组训练时只有组长可以操作
{
AreaFlagSyncProtoBuilder protoBuilder = new AreaFlagSyncProtoBuilder(AreaFlagActionType.Creat, areaName, new XFramework.TransGesture(this.transform.position, Vector3.zero));
NetUDPManager.Instance.SendNetMess(protoBuilder.GetProto());
}
}
else if(GroupLearnHelper.isMaster)//分组训练时 改变位置发送位置更新消息
{
AreaFlagSyncProtoBuilder protoBuilder = new AreaFlagSyncProtoBuilder(AreaFlagActionType.UpdatePos, areaName, new XFramework.TransGesture(this.transform.position, Vector3.zero));
NetUDPManager.Instance.SendNetMess(protoBuilder.GetProto());
}
thisIcon?.SetUpdateIconMsg(this.transform.position, "UpdatePos");//更新UI位置
}
//捡起
public void PickUp()
{
GameObjectManager.Instance.RemoveArea(this);//移除安置记录
}
private void OnDestroy()
{
buttonIcon?.SetInteractable(true);
GameObjectManager.Instance.RemoveArea(this);
if (thisIcon)
Destroy(thisIcon.gameObject);//删除对应的UI
}
//中途放弃拾取 则自动删除该物体
public void StopPick()
{
if (GroupLearnHelper.isMaster)//分组训练时只有组长可以操作
{
AreaFlagSyncProtoBuilder protoBuilder = new AreaFlagSyncProtoBuilder(AreaFlagActionType.Destory, areaName, new XFramework.TransGesture(this.transform.position, Vector3.zero));
NetUDPManager.Instance.SendNetMess(protoBuilder.GetProto());
}
Destroy(this.gameObject);
}
//任意情况下都能中止
public bool CanStopPick()
{
return true;
}
public GameObject GetGameObject()
{
return this.gameObject;
}
//绑定UI 根据物体初始化UI
public void BindIcon(IconBase icon)
{
thisIcon = icon;
icon.SetName(areaName);
icon.SetUpdateIconMsg(radius);
}
}