public void InitTowerList() { ObjectPool <TowerModel> pool = InjectService.Get <ObjectPool <TowerModel> >(); Transform parent = GameObject.Find("LinkListParent").transform; //遍历字典读取所有的信塔,加载预设 foreach (var key in pool.objectsDic.Keys) { var model = pool.objectsDic[key]; var entity = (TowerEntity)model.DataEntity; string strList = ""; for (int i = 0; i < entity.towerList.Count; i++) { strList += entity.towerList[i].ToString() + ">"; } if (string.IsNullOrEmpty(strList)) { continue; } else { strList = strList.Remove(strList.Length - 1); //把资源加载到内存中 Object obj = Resources.Load("TextList", typeof(GameObject)); //用加载得到的资源对象,实例化游戏对象,实现游戏物体的动态加载 GameObject prefab = Instantiate(obj) as GameObject; prefab.transform.SetParent(parent); prefab.transform.Find("name/Text").GetComponent <Text>().text = strList; } } }
/// <summary> /// 执行初始化过程 /// </summary> //[RuntimeInitializeOnLoadMethod] public void Initialize() { ///命令系统注入 if (InjectService.Get <IServiceCommand>() == null) { ServiceCommand commandService = new ServiceCommand(); commandService.Initialize(); } //注册实体工具 if (InjectService.Get <IEntityService>() == null) { InjectService.RegisterSingleton <IEntityService>(new EntityServiceImpl()); } //注册信号塔对象池 if (InjectService.Get <ObjectPool <TowerModel> >() == null) { InjectService.RegisterSingleton(new ObjectPool <TowerModel>()); } //注册手机对象池 if (InjectService.Get <ObjectPool <PhoneModel> >() == null) { InjectService.RegisterSingleton(new ObjectPool <PhoneModel>()); } //注册实体工具 if (InjectService.Get <EntityUtils>() == null) { InjectService.RegisterSingleton(new EntityUtils()); } }
/// <summary> /// 设置连接的显示 /// </summary> public void SettingLinkShow(int index) { //得到当前基站的信息 ObjectPool <TowerModel> pool = InjectService.Get <ObjectPool <TowerModel> >(); foreach (var key in pool.objectsDic.Keys) { pool.objectsDic[key].transform.GetChild(2).GetComponent <Renderer>().material.color = Color.yellow; if (key.ToString().Equals(dropdown.captionText.text)) { pool.objectsDic[key].transform.GetChild(2).GetComponent <Renderer>().material.color = Color.red; var towerEntity = (TowerEntity)pool.objectsDic[key].DataEntity; string linkInfo = ""; for (int i = 0; i < towerEntity.towerList.Count; i++) { if (i == 0) { linkInfo = towerEntity.towerList[0].ToString(); } else { linkInfo = linkInfo + "_" + towerEntity.towerList[i]; } var entity = (SettingLinkEntity)GetComponent <SettingLinkViewModel>().DataEntity; entity.linkList = linkInfo; } } } }
/// <summary> /// 执行初始化过程 /// </summary> //[RuntimeInitializeOnLoadMethod] public void Initialize() { //注册灯对象池 if (InjectService.Get <ObjectPool <LightDataModel> >() == null) { InjectService.RegisterSingleton(new ObjectPool <LightDataModel>()); } //注册舞者对象池 if (InjectService.Get <ObjectPool <DancerDataModel> >() == null) { InjectService.RegisterSingleton(new ObjectPool <DancerDataModel>()); } //注册实体工具 if (InjectService.Get <IEntityService>() == null) { InjectService.RegisterSingleton <IEntityService>(new EntityServiceImpl()); } //注册Logging工具 if (InjectService.Get <ILoggingService>() == null) { InjectService.RegisterSingleton <ILoggingService>(new LoggingServiceImpl()); } }
/// <summary> /// 初始化实验服务 /// </summary> public void Initialize() { //注册服务单利 if (InjectService.Get <IServiceExperiment>() == null) { InjectService.RegisterSingleton <IServiceExperiment, ServiceExperiment>(this); } }
/// <summary> /// 在对象池中删除本对象 /// </summary> private void OnDestroy() { //在对象池中删除本对象 ObjectPool <DancerDataModel> pool = InjectService.Get <ObjectPool <DancerDataModel> >(); pool.RemoveObject(this); }
/// <summary> /// 初始化服务 /// </summary> public void Initialize() { //注册服务单利 if (InjectService.Get <IServiceSerializer>() == null) { InjectService.RegisterSingleton <IServiceSerializer, ServiceJsonDotNet>(this); } }
/// <summary> /// 初始化服务 /// </summary> public void Initialize() { //注册服务单利 if (InjectService.Get <IServiceCompress>() == null) { InjectService.RegisterSingleton <IServiceCompress, ServiceGzip>(this); } }
/// <summary> /// 创建通讯 /// </summary> public void CreateCommincation() { //Debug.Log("创建通讯"); //手机1和手机2是否准备就绪 string str1 = phone1.captionText.text; string str2 = phone2.captionText.text; if (string.IsNullOrEmpty(str1) || string.IsNullOrEmpty(str2)) { ConnectDefeated("请确认通讯设备是否准备就绪"); return; } else { if (str1.Equals(str2)) { ConnectDefeated("不能与自己通讯"); return; } else { //判断通讯状态 int phoneID_1 = System.Convert.ToInt32(phone1.captionText.text); int phoneID_2 = System.Convert.ToInt32(phone2.captionText.text); ObjectPool <PhoneModel> poolPhone = InjectService.Get <ObjectPool <PhoneModel> >(); ObjectPool <TowerModel> poolTower = InjectService.Get <ObjectPool <TowerModel> >(); var phone1Entity = (PhoneEntity)poolPhone.objectsDic[phoneID_1].DataEntity; var phone2Entity = (PhoneEntity)poolPhone.objectsDic[phoneID_2].DataEntity; var tower1ID = phone1Entity.towerModelID; var tower2ID = phone2Entity.towerModelID; //1.两个手机是否都在服务器 if (tower1ID == -1 || tower2ID == -1) { ConnectDefeated("手机不在服务区"); return; } //2.两个手机所在的信号塔是否可以互相通信 else { var tower1Entity = (TowerEntity)poolTower.objectsDic[tower1ID].DataEntity; var tower2Entity = (TowerEntity)poolTower.objectsDic[tower2ID].DataEntity; //phone1 呼叫 phone2 //Debug.Log(tower1ID+"__"+tower2ID); //Debug.Log(tower1Entity.towerList.Count); if (tower1ID == tower2ID || tower1Entity.towerList.Contains(tower2ID)) { ConnectSuccess(); } else { ConnectDefeated("链路不通"); } } } } }
/// <summary> /// 注入服务对象 /// </summary> private void Awake() { //注入WebGLWebAPI接口 if (InjectService.Get <IWebGlWebAPIService>() == null) { WebGLWebAPIService service = new WebGLWebAPIService(); service.Initialize(); } }
private void Update() { if (Input.GetKeyDown(KeyCode.Q)) { ObjectPool <PhoneModel> pool = InjectService.Get <ObjectPool <PhoneModel> >(); Debug.Log(pool.Count()); pool.Foreach(Foreach); } }
/// <summary> /// 改变手机显示状态 /// </summary> public void ChangPhoneState(int phoneObjectID, Color color) { ObjectPool <PhoneModel> pool = InjectService.Get <ObjectPool <PhoneModel> >(); if (pool.objectsDic.ContainsKey(phoneObjectID)) { pool.objectsDic[phoneObjectID].gameObject.GetComponent <Renderer>().material.color = color; } }
public void TestTransient2() { //Not we are not using the interface here InjectService.RegisterTransient <WordService>(); Assert.IsNotNull(InjectService.Get <WordService>()); InjectService.RegisterTransient(() => new SentanceService()); Assert.IsNotNull(InjectService.Get <SentanceService>()); }
/// <summary> /// 注册本对象到对象池中 /// </summary> protected override void Start() { base.Start(); //注册本对象到对象池中 ObjectPool <DancerDataModel> pool = InjectService.Get <ObjectPool <DancerDataModel> >(); pool.RegisterObject(this); }
/// <summary> /// 初始化浏览器服务 /// </summary> public void Initialize() { this.Wapper = new WebGLWebAPIServiceWapper(); Wapper.Initialize(); //注册服务单利 if (InjectService.Get <IWebGlWebAPIService>() == null) { InjectService.RegisterSingleton <IWebGlWebAPIService, WebGLWebAPIService>(this); } }
public void Initialize() { wrapper = new LabInterApiWrapper(); wrapper.Initialize(); //注册服务单利 if (InjectService.Get <ILabInterApiService>() == null) { InjectService.RegisterSingleton <ILabInterApiService, LabInterApiService>(this); } }
/// <summary> /// Undo操作 /// </summary> public override void Undo() { newObject.SetActive(false); ObjectPool <PhoneModel> pool = InjectService.Get <ObjectPool <PhoneModel> >(); pool.RemoveObject(newObject.GetComponent <PhoneModel>()); var phoneModel = newObject.GetComponent <PhoneModel>(); var phoneEntity = (PhoneEntity)phoneModel.DataEntity; pool.objectsDic.Remove(phoneEntity.objectID); }
public void Awake() { if (InjectService.Get <LabInterSystem>() == null) { InjectService.RegisterSingleton(this); } //注入ILabInterApi接口 if (InjectService.Get <ILabInterApiService>() == null) { LabInterApiService service = new LabInterApiService(); service.Initialize(); } }
private void Awake() { if (InjectService.Get <IServiceCommand>() == null) { ServiceCommand commandService = new ServiceCommand(); commandService.Initialize(); } if (InjectService.Get <UIController>() == null) { InjectService.RegisterSingleton(new UIController()); } }
/// <summary> /// Redo操作 /// </summary> public override void Redo() { newObject.SetActive(true); ObjectPool <TowerModel> pool = InjectService.Get <ObjectPool <TowerModel> >(); var towerModel = newObject.GetComponent <TowerModel>(); var towerEntity = (TowerEntity)towerModel.DataEntity; pool.RegisterObject(towerModel); if (!pool.objectsDic.ContainsKey(towerEntity.objectID)) { pool.objectsDic.Add(towerEntity.objectID, towerModel); } }
/// <summary> /// Redo操作 /// </summary> public override void Redo() { newObject.SetActive(true); ObjectPool <PhoneModel> pool = InjectService.Get <ObjectPool <PhoneModel> >(); var phoneModel = newObject.GetComponent <PhoneModel>(); var phoneEntity = (PhoneEntity)phoneModel.DataEntity; pool.RegisterObject(phoneModel); if (!pool.objectsDic.ContainsKey(phoneEntity.objectID)) { pool.objectsDic.Add(phoneEntity.objectID, phoneModel); } }
/// <summary> /// UI关闭 /// </summary> public void UIActveFalse() { transform.localScale = Vector3.zero; SettingLinkEntity settingLinkEntity = (SettingLinkEntity)GetComponent <SettingLinkViewModel>().DataEntity; settingLinkEntity.isShow = false; //得到当前基站的信息 ObjectPool <TowerModel> pool = InjectService.Get <ObjectPool <TowerModel> >(); foreach (var key in pool.objectsDic.Keys) { pool.objectsDic[key].transform.GetChild(2).GetComponent <Renderer>().material.color = Color.yellow; } }
public void TestTransient() { //Register a concrete type keyed by an interface InjectService.RegisterTransient <IWordService, WordService>(); InjectService.RegisterTransient <ISentanceService, SentanceService>(); InjectService.RegisterTransient <Document>(); var document = InjectService.Get <Document>(); Assert.IsNotNull(document); Assert.IsNotNull(document.Sentances); Assert.IsNotNull(document.Words); Assert.AreEqual(document.Print(), document.Sentances.GetSentance()); }
/// <summary> /// 创建设计系统必要服务 /// </summary> public static void CreateDesignSystemService() { if (InjectService.Get <IServiceCommand>() == null) { ServiceCommand commandService = new ServiceCommand(); commandService.Initialize(); } if (InjectService.Get <IServiceExperiment>() == null) { ServiceExperiment exprimentService = new ServiceExperiment(); exprimentService.Initialize(); } }
/// <summary> /// 断开通讯 /// </summary> public void OffCommincation() { Debug.Log("关闭通讯"); //当前所有信号塔的通讯手机都去掉当前通讯的手机 //两个手机变成绿色 if (string.IsNullOrEmpty(phone1.captionText.text) || string.IsNullOrEmpty(phone2.captionText.text)) { return; } int phoneID_1 = System.Convert.ToInt32(phone1.captionText.text); int phoneID_2 = System.Convert.ToInt32(phone2.captionText.text); ObjectPool <PhoneModel> poolPhone = InjectService.Get <ObjectPool <PhoneModel> >(); var phoneEntity1 = (PhoneEntity)poolPhone.objectsDic[phoneID_1].DataEntity; var phoneEntity2 = (PhoneEntity)poolPhone.objectsDic[phoneID_2].DataEntity; //手机在通讯状态 phoneEntity1.currentState = 0; phoneEntity2.currentState = 0; //互相绑定为通话状态的手机 phoneEntity1.withPhoen = -1; phoneEntity2.withPhoen = -1; //poolPhone.objectsDic[phoneID_1].gameObject.GetComponent<Renderer>().material.color = Color.green; //poolPhone.objectsDic[phoneID_2].gameObject.GetComponent<Renderer>().material.color = Color.green; //手机1所在的信号塔广播信号 ObjectPool <TowerModel> poolTower = InjectService.Get <ObjectPool <TowerModel> >(); var phone1Entity = (PhoneEntity)poolPhone.objectsDic[phoneID_1].DataEntity; var tower1ID = phone1Entity.towerModelID; if (!poolTower.objectsDic.ContainsKey(tower1ID)) { return; } var tower1Entity = (TowerEntity)poolTower.objectsDic[tower1ID].DataEntity; tower1Entity.phoneUseList.Remove(phoneID_1); for (int i = 0; i < tower1Entity.towerList.Count; i++) { var _tower1ID = tower1Entity.towerList[i]; var _towerModel = poolTower.objectsDic[_tower1ID]; var _tower1Entity = (TowerEntity)_towerModel.DataEntity; _tower1Entity.phoneUseList.Remove(phoneID_1); } }
public static void InitialieService() { //序列化 if (InjectService.Get <IServiceSerializer>() == null) { ServiceJsonDotNet _serializer = new ServiceJsonDotNet(); _serializer.Initialize(); } //压缩 if (InjectService.Get <IServiceCompress>() == null) { ServiceGzip _compress = new ServiceGzip(); _compress.Initialize(); } }
public void TestRemove() { InjectService.RegisterTransient <IWordService, WordService>(); InjectService.RegisterTransient <ISentanceService, SentanceService>(); InjectService.RegisterTransient <Document>(); InjectService.Unregister <Document>(); var document = InjectService.Get <Document>(); Assert.IsNull(document); InjectService.UnregisterAll(); Assert.IsNull(InjectService.Get <IWordService>()); Assert.IsNull(InjectService.Get <ISentanceService>()); }
public override void LoadStorageData() { base.LoadStorageData(); Watch(this); Transform parent = GameObject.Find("Phone").transform; transform.SetParent(parent); ObjectPool <PhoneModel> pool = InjectService.Get <ObjectPool <PhoneModel> >(); if (!pool.objectsDic.ContainsKey(DataEntity.objectID)) { pool.objectsDic.Add(DataEntity.objectID, this); } }
/// <summary> /// 执行初始化过程 /// </summary> //[RuntimeInitializeOnLoadMethod] public void Initialize() { //清空所有注册实例 InjectService.UnregisterAll(); //注册实体工具 if (InjectService.Get <EntityUtils>() == null) { InjectService.RegisterSingleton(new EntityUtils()); } //注册Logging工具 if (InjectService.Get <LoggingUtils>() == null) { InjectService.RegisterSingleton(new LoggingUtils()); } }
/// <summary> /// 测试瞬态注入 /// </summary> private void Start() { foo1 = InjectService.Get <Foo>(); foo2 = InjectService.Get <Foo>(); foo1.name = "创建了一个Foo类的实例(调用工厂方法完成实例的创建过程)并命名为foo1"; foo2.name = "创建了一个Foo类的实例(调用工厂方法完成实例的创建过程)并命名为foo2"; Debug.Log(foo1.name); Debug.Log(foo2.name); A a1 = InjectService.Get <Foo>().a; A a2 = InjectService.Get <Foo>().a; a1.id = "a1"; a2.id = "a2"; Debug.Log(a1.id); Debug.Log(a2.id); }