/// <summary> /// 替换规则 /// </summary> /// <param name="scripteContent"></param> /// <param name="fileName"></param> /// <returns></returns> protected static Dictionary <string, string> ReplaceRole(string className) { //这里实现自定义的一些规则 Dictionary <string, string> dicReplaceData = new Dictionary <string, string>(); dicReplaceData.Add("#ClassName#", className); Dictionary <string, Component> dicSelect = HierarchySelect.dicSelectObj; StringBuilder content = new StringBuilder(); //获取基类 GameObject objSelect = Selection.activeGameObject; BaseMonoBehaviour uiComponent = objSelect.GetComponent <BaseMonoBehaviour>(); Dictionary <string, Type> dicBaseTypes = ReflexUtil.GetAllNameAndTypeFromBase(uiComponent); foreach (var itemSelect in dicSelect) { if (itemSelect.Value == null) { continue; } Type type = itemSelect.Value.GetType(); //如果基类里面已经有了这个属性,则不再添加 if (dicBaseTypes.ContainsKey($"ui_{itemSelect.Key}")) { continue; } content.Append(" public " + type.Name + " ui_" + itemSelect.Key + ";\r\n\r\n"); } dicReplaceData.Add("#PropertyList#", content.ToString()); return(dicReplaceData); }
/// <summary> /// 处理 设置UI的值 /// </summary> public void HandleForSetUICompontData() { GameObject objSelect = Selection.activeGameObject; if (objSelect == null) { return; } BaseMonoBehaviour uiComponent = objSelect.GetComponent <BaseMonoBehaviour>(); Dictionary <string, object> dicData = ReflexUtil.GetAllNameAndValue(uiComponent); foreach (var itemData in dicData) { string itemKey = itemData.Key; object itemValue = itemData.Value; if (itemKey.Contains("ui_")) { //获取选中的控件 Dictionary <string, Component> dicSelect = HierarchySelect.dicSelectObj; //对比选中的控件和属性名字是否一样 if (dicSelect.TryGetValue(itemKey.Replace("ui_", ""), out Component itemComponent)) { ReflexUtil.SetValueByName(uiComponent, itemKey, itemComponent); } } } Undo.RecordObject(objSelect, objSelect.gameObject.name); EditorUtility.SetDirty(objSelect); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); }
public void DeregisterMonoBehaviour(BaseMonoBehaviour obj) { if (instance.baseMonoBehaviours.Contains(obj) == true) { instance.baseMonoBehaviours.Remove(obj); } }
public void RegisterMonoBehaviour(BaseMonoBehaviour obj) { if (instance.baseMonoBehaviours.Contains(obj) == false) { instance.baseMonoBehaviours.Add(obj); } }
public static void RemoveBehaviour(BaseMonoBehaviour behaviour) { int addAtIndex = 0; BaseMonoBehaviour[] tempArray = new BaseMonoBehaviour[instance.maxBehaviors]; for (int i = 0; i < instance.behaviours.Length; i++) { if (instance.behaviours[i] == null) { continue; } else if (instance.behaviours[i] == behaviour) { instance.behaviourCount -= 1; continue; } tempArray[addAtIndex] = instance.behaviours[i]; addAtIndex++; } instance.behaviours = new BaseMonoBehaviour[instance.maxBehaviors]; for (int i = 0; i < tempArray.Length; i++) { instance.behaviours[i] = tempArray[i]; } }
/// <summary> /// 创建创意工坊物品 /// </summary> /// <param name="content"></param> /// <param name="updateBean"></param> /// <param name="callBack"></param> public static void CreateWorkshopItem(BaseMonoBehaviour content, SteamWorkshopUpdateBean updateBean, ISteamWorkshopUpdateCallBack callBack) { if (SteamManager.Initialized) { ISteamWorkshopUpdate update = new SteamWorkshopUpdateImpl(content); update.CreateWorkshopItem(updateBean, callBack); } }
/// <summary> /// 查询创意工坊本地安装文件信息 /// </summary> /// <param name="content"></param> /// <param name="pageNumber">页数 初始页为1 每页查询50条数据</param> /// <param name="callBack"></param> public static void QueryInstallInfo(BaseMonoBehaviour content, uint pageNumber, EUserUGCList type, ISteamWorkshopQueryInstallInfoCallBack callBack) { if (SteamManager.Initialized) { ISteamWorkshopQuery query = new SteamWorkshopQueryImpl(content); query.QueryInstallInfo(pageNumber, type, callBack); } }
public BaseMVCController(BaseMonoBehaviour content, V view) { SetContent(content); //添加相应模型 mModel = new M(); mModel.SetContent(mContent); //添加相应视图 mView = view; }
void OnEnemyControllerGotDisabled(BaseMonoBehaviour obj) { obj.GotDisabled -= OnEnemyControllerGotDisabled; // unsubscribed cause this could belong to a pooled object if (!_isDisabling) { // while we are disabling this object we don't want to touch the spawned enemies list nor respawn _spawnedEnemies.Remove(obj.gameObject); ScheduleSpawn(); } }
//Updatable script can be registered using this //to avoid duplicates public bool RegisterScript(BaseMonoBehaviour script) { if (!registeredScripts.Contains(script)) { registeredScripts.Add(script); return(true); } else { throw new System.Exception("script " + script.name + " cant be registered"); } }
public static void AddBehaviour(BaseMonoBehaviour behaviour) { if (instance.behaviours == null) { instance.behaviours = new BaseMonoBehaviour[1]; } else { System.Array.Resize(ref instance.behaviours, instance.behaviours.Length + 1); } instance.behaviours[instance.behaviours.Length - 1] = behaviour; instance.behaviourcount_ = instance.behaviours.Length; }
public static void AddBehaviour(BaseMonoBehaviour behaviour) { if (instance.behaviours == null) { instance.behaviours = new BaseMonoBehaviour[instance.maxBehaviors]; } if (instance.behaviourCount >= instance.maxBehaviors) { instance.maxBehaviors += 10; System.Array.Resize(ref instance.behaviours, instance.maxBehaviors); } instance.behaviours[instance.behaviourCount] = behaviour; instance.behaviourCount += 1; }
/// <summary> /// 自动完成拼图 /// </summary> public static void CompletePuzzles(BaseMonoBehaviour content) { CommonData.GameStatus = 3; CommonData.IsCheating = true; JigsawContainerCpt[] cptList = UnityEngine.Object.FindObjectsOfType <JigsawContainerCpt>(); if (cptList == null || cptList.Length == 0) { return; } //设置不可在拖拽 CommonData.IsDargMove = false; JigsawContainerCpt tempCpt = cptList[0]; content.StartCoroutine(delayComplete(content, cptList, tempCpt, 10f)); }
static IEnumerator delayComplete(BaseMonoBehaviour content, JigsawContainerCpt[] cptList, JigsawContainerCpt tempCpt, float mergeTime) { foreach (JigsawContainerCpt itemCpt in cptList) { Rigidbody2D itemRB = itemCpt.GetComponent <Rigidbody2D>(); if (itemCpt != null) { //设置质量为0 防止动画时错位 itemRB.velocity = Vector3.zero; //顺便冻结缸体 itemRB.constraints = RigidbodyConstraints2D.FreezeAll; } CompositeCollider2D itemCollider = itemCpt.GetComponent <CompositeCollider2D>(); if (itemCollider != null) { UnityEngine.Object.Destroy(itemCollider); } } yield return(new WaitForEndOfFrame()); for (int i = 0; i < cptList.Length; i++) { if (mergeTime > 5) { tempCpt.transform.position = tempCpt.startPosition; tempCpt.transform.localRotation = tempCpt.startRotation; } JigsawContainerCpt itemCpt = cptList[i]; itemCpt.isSelect = false; // 添加拼图碎片到容器里 if (cptList[i] != tempCpt) { tempCpt.addJigsawList(itemCpt.listJigsaw); //位置纠正 tempCpt.jigsawLocationCorrect(mergeTime, itemCpt.listJigsaw); // 最后删除当前容器 UnityEngine.Object.Destroy(itemCpt.gameObject); } yield return(new WaitForSeconds(0.1f)); } tempCpt.mergeDeal(mergeTime); }
/// <summary> /// 读取拼图进度 /// </summary> /// <param name="content"></param> /// <param name="progressBean"></param> public static void setGameProgress(BaseMonoBehaviour content, PuzzlesProgressBean progressBean) { JigsawContainerCpt[] cptList = UnityEngine.Object.FindObjectsOfType <JigsawContainerCpt>(); if (cptList == null || cptList.Length == 0) { return; } List <PuzzlesProgressItemBean> progress = progressBean.progress; foreach (PuzzlesProgressItemBean itemProgress in progress) { JigsawContainerCpt tempCpt = null; //其次需要合并的子对象 List <JigsawContainerCpt> tempListCpt = new List <JigsawContainerCpt>(); foreach (JigsawContainerCpt itemCpt in cptList) { //首先获取父对象 if (itemCpt.listJigsaw[0].MarkLocation == itemProgress.markPostion) { tempCpt = itemCpt; } foreach (Vector2 listPuzzleItem in itemProgress.listPuzzles) { if (listPuzzleItem == itemCpt.listJigsaw[0].MarkLocation) { tempListCpt.Add(itemCpt); } } } JigsawContainerCpt[] tempArraryCpt = DevUtil.listToArray(tempListCpt); if (tempCpt != null) { //设置不可在拖拽 CommonData.IsDargMove = false; content.StartCoroutine(delayComplete(content, tempArraryCpt, tempCpt, 1f)); } } }
void enemyController_Disabled(BaseMonoBehaviour obj) { obj.GotDisabled -= enemyController_Disabled; // unsubscribed cause this could belong to a pooled object if (!_isDisabling) { // while we are disabling this object we don't want to touch the spawned enemies list nor respawn _spawnedEnemies.Remove(obj.gameObject); try { if (this.isActiveAndEnabled && respawnMode == RespawnMode.SpawnWhenDestroyed) { // we need to invoke here as the spawn method would set the enemy active while being currently deactivated... Invoke("Spawn", respawnOnDestroyDelay); } } catch (MissingReferenceException) { // we swallow that one, it happens on scene unload when an enemy disables after this object has been finalized } } }
public AreaTypeInfoController(BaseMonoBehaviour content, IAreaTypeInfoView view) : base(content, view) { }
public UITextController(BaseMonoBehaviour content, IUITextView view) : base(content, view) { }
public UserSceneDataController(BaseMonoBehaviour content, IUserSceneDataView view) : base(content, view) { }
public DateInfoController(BaseMonoBehaviour content, IDateInfoView view) : base(content, view) { }
public NpcTeamController(BaseMonoBehaviour content, INpcTeamView view) : base(content, view) { }
public static void RemoveBehaviour(BaseMonoBehaviour behaviour) { instance._behaviours.Remove(behaviour); }
public static void AddBehaviour(BaseMonoBehaviour behaviour) { instance._behaviours.Add(behaviour); }
public SteamWorkshopUpdateImpl(BaseMonoBehaviour mContent) { //初始化appid this.mAppId = new AppId_t(uint.Parse(ProjectConfigInfo.STEAM_APP_ID)); this.mContent = mContent; }
public CreatureInfoController(BaseMonoBehaviour content, ICreatureInfoView view) : base(content, view) { }
public BaseDataController(BaseMonoBehaviour content, IBaseDataView view) : base(content, view) { InitAllBaseData(); }
public GameDataController(BaseMonoBehaviour content, IGameDataView view) : base(content, view) { }
public ChunkSaveController(BaseMonoBehaviour content, IChunkSaveView view) : base(content, view) { }
public SkillInfoController(BaseMonoBehaviour content, ISkillInfoView view) : base(content, view) { }
public CharacterInfoController(BaseMonoBehaviour content, ICharacterInfoView view) : base(content, view) { }