private void DrawAniClipItem(AniClip clip) { GUILayout.BeginHorizontal(GUILayout.Width(300)); if (this._curClip == null) { return; } if (this._curClip.name == clip.name) { GUI.color = Color.green; } else { GUI.color = Color.white; } if (GUILayout.Button(clip.name)) { this._curClip = clip; } GUI.color = GUI.backgroundColor; if (GUILayout.Button("确定", GUILayout.Width(100))) { SkillBlock sb = new SkillBlock(); sb.AniName = clip.name; sb.Events = new List <SkillEvent>(); this._skillBlocks.Insert(this._index, sb); this.Close(); } GUILayout.EndHorizontal(); }
public void LoadDefense() { GameObject slot = Instantiate(_attackSlot); slot.transform.SetParent(transform.Find("ActionMask").Find("GridView")); slot.transform.localScale = new Vector3(1, 1, 1); slot.transform.localPosition = Vector3.zero; slot.transform.Find("Crystal").GetComponentInChildren <Text>().text = 1 + ""; slot.transform.Find("Image").GetComponent <Image>().sprite = _defenseIcon[0]; slot.transform.Find("Icon").gameObject.SetActive(false); SkillBlock skill = new SkillBlock(); skill.slotId = _blockCount; skill.defCrystal = 1; skill.heroStoreId = 1; skill.color = 5; skill.isAttack = false; skill.blockStack = 1; skill.crystal = 1; skill.obj = slot; AttackSlot atk = slot.GetComponent <AttackSlot>(); atk._skill = skill; _attackList.Add(skill); _blockCount++; transform.Find("ActionMask").Find("GridView").localPosition = new Vector3(1, 0, 0); }
public void Show(int frame, SkillBlock sb, List <SkillEvent> curSkillEventList) { this._curBlock = sb; this._curFrame = frame; this._curSkillEventList = curSkillEventList; this.Show(); }
public static void PushSkillEventToBlock(ref SkillBlock sb, Dictionary <int, List <SkillEvent> > dict) { sb.Events.Clear(); foreach (List <SkillEvent> list in dict.Values) { foreach (SkillEvent se in list) { sb.Events.Add(se); } } }
public void LoadAttack() { if (_core == null) { _core = Camera.main.GetComponent <MainCore>(); } if (_battleCon == null) { _battleCon = _core._battleCon; } int ranSlot = Random.Range(0, _battleCon._heroData.Length); if (_battleCon._heroData[ranSlot].hero.hp == 0) { //Debug.Log("old block "+ranSlot); ranSlot = Random.Range(0, _battleCon._heroData.Length); //Debug.Log("new ran block "+ ranSlot); } GameObject slot = Instantiate(_attackSlot); slot.transform.SetParent(transform.Find("ActionMask").Find("GridView")); slot.transform.localScale = new Vector3(1, 1, 1); slot.transform.localPosition = Vector3.zero; if (getSpriteSet != _battleCon._heroData[ranSlot].hero.hero.spriteSet) { getSpriteSet = _battleCon._heroData[ranSlot].hero.hero.spriteSet; loadSprite = Resources.LoadAll <Sprite>("Sprites/Character/Hero/" + getSpriteSet); } slot.transform.Find("Icon").GetComponent <Image>().sprite = loadSprite.Single(s => s.name == "Map_" + _battleCon._heroData[ranSlot].hero.hero.spriteName); SkillBlock skill = new SkillBlock(); skill.slotId = _blockCount; skill.defCrystal = _battleCon._heroData[ranSlot].hero.attack[0].skill.crystal; slot.transform.Find("Crystal").GetComponentInChildren <Text>().text = skill.defCrystal.ToString(); slot.transform.Find("Image").GetComponent <Image>().sprite = loadSprite.Single(s => s.name == "Skill_" + _battleCon._heroData[ranSlot].hero.hero.spriteName); skill.heroStoreId = _battleCon._heroData[ranSlot].hero.id; skill.blockStack = 1; skill.color = _battleCon._heroData[ranSlot].slotId; skill.isAttack = true; skill.isUltimate = false; skill.crystal = skill.defCrystal; skill.obj = slot; AttackSlot atk = slot.GetComponent <AttackSlot>(); atk._skill = skill; _attackList.Add(skill); _blockCount++; transform.Find("ActionMask").Find("GridView").localPosition = new Vector3(1, 0, 0); }
// 어떤 스킬 블록을 사용할 지 무작위로 정하는 함수 SkillBlock SkillBlockKind() { // skillBlock 변수 초기화 SkillBlock skillBlock = null; // SkillList 내의 스킬 블록 종류 무작위로 고르기 int index = Random.Range(0, SkillList.Length); // index값을 토대로 스킬블록에 할당 skillBlock = SkillList[index]; return(skillBlock); }
// 스킬블록을 만드는 함수 private void SkillBlockGen() { // skillBlock 인스턴스화 SkillBlock skillBlock = Instantiate( SkillBlockKind(), SkillBlockPosition(), Quaternion.identity ); // skillBlock을 skillBlocks의 부모로 설정 skillBlock.transform.parent = skillBlocks.transform; // skillBlock을 skillBlockArray에 추가 skillBlockArray.Add(skillBlock); }
public static void GetSkillEventDict(SkillBlock sb, ref Dictionary <int, List <SkillEvent> > dict) { dict.Clear(); foreach (SkillEvent se in sb.Events) { List <SkillEvent> seList; if (!dict.TryGetValue(se.FrameId, out seList)) { seList = new List <SkillEvent>(); dict.Add(se.FrameId, seList); } seList.Add(se); } }
// 블록 체인 확인하는 함수 public void IsChain() { // 체인 구현 시 이전 스킬블록을 저장하기 위한 임시 변수 SkillBlock temp = null; for (int i = 0; i < SkillBlockController.skillBlockArray.Count; i++) { // 현재 인덱스의 스킬 블록 SkillBlock sb = SkillBlockController.skillBlockArray[i]; // temp는 sb의 이전 스킬 블록 if (temp != null) { // temp와 sb의 스킬 종류가 같고, temp 체인 배열에 sb가 포함이 안되있고, 체인 배열 크기가 3보다 작으면 if (temp.tag.Equals(sb.tag) && sb.blockActive && !temp.ChainBlock.Contains(sb) && temp.ChainBlock.Count < skillBlockController.MaxChainNum) { // sb 체인 블록의 크기가 2 이상일 경우 중복이 되므로 제거해주어야 함 if (sb.ChainBlock.Count != 1) { sb.ChainBlock.Remove(sb); } // 크기가 1이면 sb의 체인블록을 제거해서 메모리 확보 else { sb.ChainBlock.Clear(); } // temp 체인 블록에 sb 추가 temp.ChainBlock.Add(sb); // 이후 sb 체인 블록이 temp 체인 블록과 같게 함 sb.ChainBlock = temp.ChainBlock; } // 다음 스킬 블록을 불러오기 전 temp에 sb를 할당 temp = sb; } // 첫 스킬 블록일 때 이므로 temp에 sb를 할당 else { temp = sb; } } }
public void UseAttack(SkillBlock skill) { _core._ActionMode = skill.isAttack?_ActionStatus.Attack: _ActionStatus.Defense; if (_core.UseCrystal(skill.crystal)) { _battleCon._battleState = _BattleState.Wait; if (skill.isAttack) { bool have = false; foreach (Hero hero in _battleCon._hero.ToList()) { if (hero.hero.id == skill.heroStoreId) { have = true; if (_core.dataSetting[0].question && _core._questionLoadComplete > 1) { _battleCon.OpenQuestion(hero, skill.isUltimate, skill.blockStack); } else { hero.Attack(skill.isUltimate, false, skill.blockStack); } break; } } if (!have) { _battleCon._battleState = _BattleState.Finish; } } else { _battleCon.GetHeroFocus().AddDefenseList(skill.crystal); } DeleteBlock(skill); UpdateAttackSlot(); } else { //_core.CallSubMenu(_SubMenu.Alert, "คริสตัลของคุณไม่พอ!"); _core.OpenErrorNotify("คริสตัลของคุณไม่พอ!"); } }
public static List <SkillEvent> GetCurFrameEventList(int frame, SkillBlock block) { if (block == null || block.Events == null) { return(null); } List <SkillEvent> evtList = new List <SkillEvent>(); foreach (SkillEvent evt in block.Events) { if (evt.FrameId == frame) { evtList.Add(evt); } } return(evtList); }
/// <summary> /// 播放技能,默认一段攻击 /// </summary> /// <param name="id"></param> /// <param name="block"></param> public void PlaySkill(int id, int block) { isPlaySkill = true; this.CurSkillBlockIndex = block; try { var skill = Skills.SkillList[id]; if (skill != null) { this.curSkill = skill; curSkillBlock = curSkill.Blocks[CurSkillBlockIndex]; var c = aniPlayer.GetClip(curSkillBlock.AniName); aniPlayer.Play(c); } } catch (Exception e) { Debug.LogError(string.Format("技能数据错误: id-{0} block-{1}", id, block)); } }
void DeleteBlock(SkillBlock skill) { string slotIdIsDelete = ""; for (int i = 0; i < _attackList.Count; i++) { if (_attackList[i].slotId == skill.slotId) { if (_attackList[i].blockStack == 3) { Destroy(_attackList[i - 1].obj); slotIdIsDelete += _attackList[i - 1].slotId + ":"; Destroy(_attackList[i - 2].obj); slotIdIsDelete += _attackList[i - 2].slotId + ":"; } else if (_attackList[i].blockStack == 2) { Destroy(_attackList[i - 1].obj); slotIdIsDelete += _attackList[i - 1].slotId + ":"; } Destroy(_attackList[i].obj); slotIdIsDelete += _attackList[i].slotId + ""; break; } } string[] splitSlotId = slotIdIsDelete.Split(':'); for (int a = 0; a < splitSlotId.Length; a++) { foreach (SkillBlock data in _attackList.ToList()) { if (data.slotId == System.Int32.Parse(splitSlotId[a])) { _attackList.Remove(data); break; } } } }
/// <summary> /// 当前技能block /// </summary> private void OnGUI_DrawSkillBlock() { GUILayout.BeginVertical(GUILayout.Width(300), GUILayout.Height(800)); GUILayout.Label("技能块列表:"); if (curSkillblockList != null) { int count = curSkillblockList.Count; for (int i = 0; i < count; i++) { GUILayout.BeginVertical(); if (curSkillblockIndex == i) { GUI.color = Color.green; } else { GUI.color = Color.white; } var sb = this.curSkillblockList[i]; GUILayout.BeginHorizontal(); if (GUILayout.Button(string.Format("[{0}] -" + sb.AniName, i))) { curSkillblockIndex = i; curAniClip = ani.GetClip(sb.AniName); curSkillblock = sb; curSkillEventList = EditorSkillTool.GetCurFrameEventList(this.curframe, curSkillblock); curSkillEvnetIndex = -1; curSkillEventEditor = null; GUI.FocusControl("RefreshFocus"); } GUI.color = GUI.backgroundColor; if (GUILayout.Button("DEL", GUILayout.Width(35))) { this.curSkillblockList.Remove(sb); count = curSkillblockList.Count; curSkillblockIndex = -1; curSkillblock = null; curSkillEventList = null; curSkillEvnetIndex = -1; curAniClip = null; curSkillEventEditor = null; GUI.FocusControl("RefreshFocus"); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); } } GUILayout.Space(20); if (curSkillblockList != null) { if (GUILayout.Button("创建skillBlock")) { Window_SelectAniClip window = (Window_SelectAniClip)EditorWindow.GetWindow(typeof(Window_SelectAniClip), false, "SelectAniClip"); window.Show(this.curSkillblockList, this.ani); } } GUILayout.EndVertical(); TableToolMenu.Layout_DrawSeparatorV(Color.gray, 2); }
public void Show(int frame, SkillBlock sb) { this._curBlock = sb; this._curFrame = frame; this.Show(); }
public static SkillBlock[] Remove(int index, SkillBlock[] list) { ArrayList tmp = new ArrayList(); foreach(SkillBlock str in list) tmp.Add(str); tmp.RemoveAt(index); return tmp.ToArray(typeof(SkillBlock)) as SkillBlock[]; }
private void ShowBlockList(List <SkillBlock> blocks) { int count = blocks.Count; if (count == 0) { curblock = null; if (GUILayout.Button("新建一个Block", GUILayout.Width(300))) { Window_SelectAniClip window = (Window_SelectAniClip)EditorWindow.GetWindow(typeof(Window_SelectAniClip), false, "SelectAniClip"); window.Show(blocks, 0, this.ani); } } else { for (int i = 0; i < count; i++) { SkillBlock sb = blocks[i]; if (!EditorSkillTool.CheckAniExist(this.ani.clips, sb.AniName)) { GUIStyle titleStyle2 = new GUIStyle(); titleStyle2.normal.textColor = new Color(1, 0, 0, 1); GUILayout.Label("ani不存在动作:" + sb.AniName, titleStyle2); } GUILayout.BeginHorizontal(GUILayout.Width(300)); if (this.blockIndex == i) { GUI.color = Color.green; curblock = sb; } else { GUI.color = Color.white; } if (GUILayout.Button(sb.AniName + " index:" + i)) { blockIndex = i; curblock = sb; eventIndex = 0; curEvent = null; GUI.FocusControl("RefreshFocus"); } GUI.color = GUI.backgroundColor; if (GUILayout.Button("add", GUILayout.Width(50))) { Window_SelectAniClip window = (Window_SelectAniClip)EditorWindow.GetWindow(typeof(Window_SelectAniClip), false, "SelectAniClip"); window.Show(blocks, i + 1, this.ani); } if (GUILayout.Button("del", GUILayout.Width(50))) { blocks.Remove(sb); count = blocks.Count; if (blockIndex == i) { curblock = null; blockIndex = 0; } else if (blockIndex > i) { blockIndex--; } } GUILayout.EndHorizontal(); } } }
public static SkillBlock[] Add(SkillBlock n, SkillBlock[] list) { ArrayList tmp = new ArrayList(); foreach(SkillBlock str in list) tmp.Add(str); tmp.Add(n); return tmp.ToArray(typeof(SkillBlock)) as SkillBlock[]; }