public void AddBuff(BuffData buff, PlayerController player) { int id = player.idInManager; List <BuffData> buffs = m_PlayerBuffs[id]; buffs.Add(buff); }
public BuffData LoadData(BuffName tag) { ; Debug.Log("尝试读取:" + tag.ToString()); int index = -1, minLRU = INF; bool findFlag = false, evictFlag = true; BuffData res = null; for (int i = 0; i < dataCells.Length; i++) { //如果不为空 if (dataCells[i].IsValid) { //如果标签一致 if (dataCells[i].Tag == tag) { findFlag = true; res = dataCells[i].Object; dataCells[i].LRU = INF; Debug.Log("缓存命中!!!"); } //标签不一致 else { //LRU减一 dataCells[i].LRU--; //如果需要evict并且没有find,则需要搜索最小LRU if (evictFlag && !findFlag && minLRU > dataCells[i].LRU) { minLRU = dataCells[i].LRU; index = i; } } } //单元格为空时,如果需要evict,则记录该空格为可替换的空格 else if (evictFlag && !findFlag) { evictFlag = false; index = i; } } if (!findFlag) { if (evictFlag) { Debug.Log("冲突不命中"); } else { Debug.Log("冷不命中"); } dataCells[index].IsValid = true; dataCells[index].LRU = INF; dataCells[index].Tag = tag; dataCells[index].Object = Resources.Load <BuffData>(GameDB.Instance.buffDataPath.paths[(int)tag]); res = dataCells[index].Object; } return(res); }
/// <summary> /// 读取字节流(完整版) /// </summary> protected override void toReadBytesFull(BytesReadStream stream) { base.toReadBytesFull(stream); stream.startReadObj(); BaseData dataT = stream.readDataFullNotNull(); if (dataT != null) { if (dataT is BuffData) { this.data = (BuffData)dataT; } else { this.data = new BuffData(); if (!(dataT.GetType().IsAssignableFrom(typeof(BuffData)))) { stream.throwTypeReadError(typeof(BuffData), dataT.GetType()); } this.data.shadowCopy(dataT); } } else { this.data = null; } stream.endReadObj(); }
private void BuffUpdate() { for (int i = 0; i < mBuffs.Count; i++) { BuffData data = mBuffs[i]; data.RemainTime = Mathf.Max(0f, data.RemainTime - Time.deltaTime); if (data.IsBuffEnd) { mBuffs.Remove(data); mRemoveBuffs.Add(data); } } while (mRemoveBuffs.Count > 0) { BuffData data = mRemoveBuffs[0]; //Debug.Log("Remove Buff:" + data.BuffType + " Count:" + mRemoveBuffs.Count); mRemoveBuffs.Remove(data); mRemoveBuffTypes.Add(data.BuffType); } if (mRemoveBuffTypes.Count > 0) { Apply(); mRemoveBuffTypes.Clear(); } }
/// <summary> /// 移除buff /// </summary> /// <param name="buffData"></param> public void RemoveBuff(BuffData buffData) { if (buffs.Contains(buffData)) { buffData.CloseBuff(); } }
/// <summary> /// 构造函数 /// </summary> public BaseBuff(BuffData data, int level) { id = data.id; round = data.round; this.level = level; superposition = data.superposition; }
public BuffTargetCommand(IBuff iBuff, BuffData buffData, TickService tick) { //takes in this unit _buffData = buffData; _iBuff = iBuff; //this is actually bringing in the instance of the wrapper buff, not the "class" iBuff. //you can call it IBuff because it extends it, and use the IBuff method because it extends it. _tick = tick; }
//角色 public Hashtable QueryBuffTable() { InitDB(); SqliteDataReader sqReader = db.ReadFullTable("buff"); Hashtable table = new Hashtable(); while (sqReader.Read()) { BuffData item = new BuffData(); item.buffid = sqReader.GetInt32(sqReader.GetOrdinal("buffer_id")); item.id1 = (Def.AttrId)sqReader.GetInt32(sqReader.GetOrdinal("property_id1")); item.v1 = sqReader.GetFloat(sqReader.GetOrdinal("value1")); item.id2 = (Def.AttrId)sqReader.GetInt32(sqReader.GetOrdinal("property_id2")); item.v2 = sqReader.GetFloat(sqReader.GetOrdinal("value2")); item.id3 = (Def.AttrId)sqReader.GetInt32(sqReader.GetOrdinal("property_id3")); item.v3 = sqReader.GetFloat(sqReader.GetOrdinal("value3")); item.id4 = (Def.AttrId)sqReader.GetInt32(sqReader.GetOrdinal("property_id4")); item.v4 = sqReader.GetFloat(sqReader.GetOrdinal("value4")); item.id5 = (Def.AttrId)sqReader.GetInt32(sqReader.GetOrdinal("property_id5")); item.v5 = sqReader.GetFloat(sqReader.GetOrdinal("value5")); item.id6 = (Def.AttrId)sqReader.GetInt32(sqReader.GetOrdinal("property_id6")); item.v6 = sqReader.GetFloat(sqReader.GetOrdinal("value6")); item.id7 = (Def.AttrId)sqReader.GetInt32(sqReader.GetOrdinal("property_id7")); item.v7 = sqReader.GetFloat(sqReader.GetOrdinal("value7")); item.id8 = (Def.AttrId)sqReader.GetInt32(sqReader.GetOrdinal("property_id8")); item.v8 = sqReader.GetFloat(sqReader.GetOrdinal("value8")); item.GetBuffAttr(); table.Add(item.buffid, item); } return(table); }
/// <summary> /// 업그레이드 된 버프 적용 준비 /// </summary> /// <param name="buffData">적용할 버프 객체</param> public void SetBuffApply(BuffData buffData) { Player player = GameManager.Instance.GetCurrentSceneManager <InGameSceneManager>().Player; switch (buffData.weaponStyle) { case WeaponStyle.WEAPON: BuffApply(buffData, player.MainGun); break; case WeaponStyle.PISTOL: BuffApply(buffData, player.SubGun); break; //case WeaponStyle.GRENADE: // BuffApply(buffData); // break; //case WeaponStyle.TNT: // BuffApply(buffData); // break; case WeaponStyle.MELEE: BuffApply(buffData, null, player); break; } }
//Метод очищения базы данных public void ClearDatabase() { buffsList.Clear(); buffsList.Add(new BuffData()); currentBuff = buffsList[0]; currentIndex = 0; }
public Buff CreateBuff(int id, int duration) { BuffData data = database.GetBuffData(id); string name = languageService.GetTranslation(TranslationCategory.Buff, data.NameKey); return(new Buff(id, name, data.GroupId, (BuffCategory)data.Category, (BuffEffect)data.Effect, data.Level, duration)); }
public BuffBase(BuffData buffData) { m_BuffData = buffData; m_BuffId = BuffUtility.GenerateBuffId(); OnInit(); }
/// <summary> /// 버프 데이터 배열 랜덤 반환 /// </summary> /// <param name="count">루프를 돌 횟수</param> /// <returns></returns> public BuffData[] GetRandomBuffData(int count) { List <BuffData> buffdataList = new List <BuffData>(); // 배열을 리스트로 변환 buffdataList.AddRange(buffDatas); // 현재 레벨이 5미만인 버프만 찾음 buffdataList = buffdataList.FindAll(delegate(BuffData a) { return(a.currentLevel < 5); }); // 남아 있는 버프가 3개 이상인지 검사 if (buffdataList.Count < 3) { return(null); } // 랜덤 선택된 데이터 BuffData[] selectDatas = new BuffData[count]; // 매개변수 만큼 루프 for (int i = 0; i < count; i++) { int ran = Random.Range(0, buffdataList.Count); selectDatas[i] = buffdataList[ran]; // 중복되지 않도록 리스트에서 제거 buffdataList.Remove(buffdataList[ran]); } return(selectDatas); }
internal void OnDestroy() { this.destroyNotifier?.Invoke(this); this.destroyNotifier = null; this.markToDestroy = false; this.battle = null; this._data = null; }
public override void onRefreshBuff(BuffData data) { base.onRefreshBuff(data); _buffEventObj.index = index; _buffEventObj.instanceID = data.instanceID; _me.dispatch(GameEventType.MUnitBuffRefresh, _buffEventObj); }
/// <summary> /// 버프 업그레이드 /// </summary> /// <param name="buffData">업그레이드할 버프 데이터</param> public void UpgradeBuffData(BuffData buffData) { buffData.currentLevel += 1; buffData.SetCurrentValue(); // 업그레이드 된 버프 적용 준비 SetBuffApply(buffData); }
void loadBuff() { //string jsonString = Tools.ReadStringFromFile(Application.dataPath + "/" + buffDataFile); buffDataDic = Tools.LoadOneData <BuffData>(Application.dataPath + "/" + "Resources_moved/Scripts/Buff/BuffList"); buffDataList = buffDataDic.Values.ToList(); currBuffData = buffDataList[0]; }
/// <summary> /// 添加buff /// </summary> /// <param name="buffData"></param> public void AddBuff(BuffData buffData) { if (!buffs.Contains(buffData)) { buffs.Add(buffData); buffData.StartBuff(); } }
public BuffData getRandomResetBuff() { BuffData buff = resetBuffs[resetBuffs.Length - 1]; //Initiated to default Buff int buffInd = Random.Range(0, resetBuffNumer - 1); buff = resetBuffs[buffInd]; return(buff); }
// Update is called once per frame public void NewBuff(BuffData buff) { data = buff; panel.SetActive(true); buffName.text = data.buffName; image.sprite = data.artwork; Description(data.type); }
/// <summary> /// 通过反射获得一个Buff /// </summary> public static BaseBuff GetBuffByID(int id, int level) { BuffData buffData = DataManager.GetInstance().buffData[id]; string className = "Buff" + buffData.templateID; Object obj = Activator.CreateInstance(Type.GetType(className), buffData, level); return(obj as BaseBuff); }
public void loadBuffs(List <string> list) { foreach (string buffName in list) { BuffData buff = Resources.Load <BuffData>(resetBuffsPath + "/" + buffName); applyBuff(buff); } }
private void doPlusMaxActions(BuffData data) { //叠加上限动作 foreach (int[] v in data.levelConfig.plusMaxActions) { doOneOverAction(v); } }
//server部分 /** 服务器添加buff */ public void addBuffByServer(BuffData data) { data.config = BuffConfig.get(data.id); data.levelConfig = BuffLevelConfig.get(data.id, data.level); data.timeMax = getBuffUseLastTime(data); toAddBuff(data); }
private void toAddBuff(BuffData data) { toAddBuffToDic(data); doAddActions(data, true); _parent.onAddBuff(data); }
/** 执行添加动作(isFull:是否完整添加) */ private void doRemoveActions(BuffData data, bool isFull) { int[][] actions = data.levelConfig.actions; for (int i = 0; i < actions.Length; ++i) { doOneAction(data, i, actions[i], false, isFull); } }
/** 刷新buff时 */ public virtual void onRefreshBuff(BuffData data) { Unit unit; if ((unit = _unit) != null) { unit.fight.onRefreshBuff(data); } }
private void AddView(BuffData data) { GameObject instance = Instantiate <GameObject>(buffViewPrefab); RoomMapBuffView view = instance.GetComponent <RoomMapBuffView>(); view.Setup(data); instance.transform.SetParent(layout, false); views.Add(view); }
/** 移除buff显示 */ public void removeBuffShow(BuffData data) { int effectID; if ((effectID = data.config.effect) > 0) { removeEffect(effectID); } }
/** 添加buff显示 */ public void addBuffShow(BuffData data) { int effectID; if ((effectID = data.config.effect) > 0) { addEffect(effectID); } }
public void Init(BuffData data, int effectTurns) { string path = GlobalDataStructure.PATH_UIIMAGE_ICON + "Buff_" + data.buffEffect; this.icon.sprite = Resources.Load(path, typeof(Sprite)) as Sprite; description.text = data.name + ":" + data.description; turns.text = effectTurns >= 0 ? effectTurns.ToString() : ""; GetComponent<Button>().onClick.AddListener(delegate(){OnClick();}); description.transform.parent.localScale = new Vector3(0, 0, 0); }
public static Buff CreateBuff(BattleObject bo, BuffData data, int effectTurns) { Buff buff = (Buff)Assembly.GetExecutingAssembly().CreateInstance("Buff" + data.buffEffect, true); buff.source = bo; buff.data = data; buff.effectTurns = effectTurns; buff.Init(); buff.AddBuffIcon(); return buff; }
/// <summary> /// Adds the buff. /// </summary> /// <param name="buffData">Buff data.</param> public void AddBuff(BuffData buffData) { RemoveBuff(buffData.Id); GameObject toRole = GameObject.Find(buffData.ToId); if (toRole != null) { if (buffData.EffectResName != "") { if (!effectsResMapping.ContainsKey(buffData.EffectResName)) { effectsResMapping.Add(buffData.EffectResName, Statics.GetPrefab("Prefabs/Effects/" + buffData.EffectResName)); } if (!effectsObjMapping.ContainsKey(buffData.Id)) { effectsObjMapping[buffData.Id] = MonoBehaviour.Instantiate(effectsResMapping[buffData.EffectResName]) as GameObject; if (effectsObjMapping[buffData.Id] != null) { effectsObjMapping[buffData.Id].transform.parent = toRole.transform.FindChild("Effects"); effectsObjMapping[buffData.Id].transform.localPosition = Vector3.zero; effectsObjMapping[buffData.Id].layer = Statics.GetEffectLayer(); } } } if (buffData.HaloResName != "") { if (!haloResMapping.ContainsKey(buffData.HaloResName)) { haloResMapping.Add(buffData.HaloResName, Statics.GetPrefab("Prefabs/Halos/" + buffData.HaloResName)); } if (!halosObjMapping.ContainsKey(buffData.Id)) { halosObjMapping[buffData.Id] = MonoBehaviour.Instantiate(haloResMapping[buffData.HaloResName]) as GameObject; if (halosObjMapping[buffData.Id] != null) { halosObjMapping[buffData.Id].transform.parent = toRole.transform.FindChild("Halos"); halosObjMapping[buffData.Id].transform.localPosition = Vector3.zero; halosObjMapping[buffData.Id].layer = Statics.GetHaloLayer(); } } } Timer.AddTimer(buffData.Id, buffData.Second, null, (timer) => { RemoveBuff(timer.Id); }); buffDataObjMapping.Add(buffData.Id, buffData); //save buff data } }
public bool Start(BuffData data, Character _caster, bool _forever) { forever = _forever; caster = _caster; _enabled = true; effobj = null; _id = data.ID; _priority = data.Priority; _weight = data.Weight; _isDestroy = false; buffdata = data; return Init(); }
private void ParseBuffTable(DataTable buffTable) { this.m_BuffDic = new Dictionary<int, BuffData>(); foreach (DataRow row in buffTable.Rows) { BuffData data = new BuffData(); this.ParseSkillDataBase(row, data); data.BuffType = (BuffType)Enum.Parse(typeof(BuffType), row["BuffType"].ToString()); this.m_BuffDic.Add(data.ID, data); } }