//temp skill public void atkSkill(Dictionary <string, object> Params) { GameObject target = (GameObject)Params["target"]; NPC.atkType atktype = (NPC.atkType)Params["atktype"]; foreach (NPC npc in GetAttackTargets(target, atktype)) { npc.OnHit(target.GetComponent <NPC>(), (int)Params["damage"]); } }
List <NPC> GetTargets(GameObject go, NPC.atkType atktype, bool bEnemy) { Board.coordinate co = chessBoard.GetChessCo(gameObject); NPC npc = go.GetComponent <NPC>(); int i = co.x; int j = co.y; List <NPC> targets = new List <NPC>(); if (atktype == NPC.atkType.CROSS) { checkAttackTarget(ref targets, i + 1, j, npc, bEnemy); checkAttackTarget(ref targets, i - 1, j, npc, bEnemy); checkAttackTarget(ref targets, i, j + 1, npc, bEnemy); checkAttackTarget(ref targets, i, j - 1, npc, bEnemy); } else if (atktype == NPC.atkType.BEVEL) { checkAttackTarget(ref targets, i + 1, j + 1, npc, bEnemy); checkAttackTarget(ref targets, i - 1, j - 1, npc, bEnemy); checkAttackTarget(ref targets, i - 1, j + 1, npc, bEnemy); checkAttackTarget(ref targets, i + 1, j - 1, npc, bEnemy); } else if (atktype == NPC.atkType.LINE_MAX) { List <NPC>[] alldir = new List <NPC> [4]; alldir[0] = new List <NPC>(); alldir[1] = new List <NPC>(); alldir[2] = new List <NPC>(); alldir[3] = new List <NPC>(); checkAttackTarget(ref alldir[0], i + 1, j, npc, bEnemy); checkAttackTarget(ref alldir[0], i + 2, j, npc, bEnemy); checkAttackTarget(ref alldir[0], i + 3, j, npc, bEnemy); checkAttackTarget(ref alldir[1], i - 1, j, npc, bEnemy); checkAttackTarget(ref alldir[1], i - 2, j, npc, bEnemy); checkAttackTarget(ref alldir[1], i - 3, j, npc, bEnemy); checkAttackTarget(ref alldir[2], i, j + 1, npc, bEnemy); checkAttackTarget(ref alldir[2], i, j + 2, npc, bEnemy); checkAttackTarget(ref alldir[2], i, j + 3, npc, bEnemy); checkAttackTarget(ref alldir[3], i, j - 1, npc, bEnemy); checkAttackTarget(ref alldir[3], i, j - 2, npc, bEnemy); checkAttackTarget(ref alldir[3], i, j - 3, npc, bEnemy); int idx = 0; int count = 0; for (int m = 0; m < 4; ++m) { if (count >= alldir[m].Count) { count = alldir[m].Count; idx = m; } } return(alldir[idx]); } else if (atktype == NPC.atkType.CROSS_LINE) { checkAttackTarget(ref targets, i + 1, j, npc, bEnemy); checkAttackTarget(ref targets, i + 2, j, npc, bEnemy); checkAttackTarget(ref targets, i + 3, j, npc, bEnemy); checkAttackTarget(ref targets, i - 1, j, npc, bEnemy); checkAttackTarget(ref targets, i - 2, j, npc, bEnemy); checkAttackTarget(ref targets, i - 3, j, npc, bEnemy); checkAttackTarget(ref targets, i, j + 1, npc, bEnemy); checkAttackTarget(ref targets, i, j + 2, npc, bEnemy); checkAttackTarget(ref targets, i, j + 3, npc, bEnemy); checkAttackTarget(ref targets, i, j - 1, npc, bEnemy); checkAttackTarget(ref targets, i, j - 2, npc, bEnemy); checkAttackTarget(ref targets, i, j - 3, npc, bEnemy); } return(targets); }