void OnPress(Board.coordinate co, GameObject[,] chessboard) { for (int i = 0; i < chessboard.GetLength(0); ++i) { for (int j = 0; j < chessboard.GetLength(1); ++j) { chessboard[i, j].GetComponent <chessUI>().blocker.SetActive(false); } } }
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); }
// void npcAttack( NPC npc) // { // ButtonCallBack bcb = npc.gameObject.GetComponent<ButtonCallBack>(); // foreach( NPC nnpc in GetAttackTargets(npc, bcb.id1, bcb.id2 ) ) // { // nnpc.OnHit( npc); // } // } void playerAttack(int turn, GameObject[,] chessboard, Board.coordinate atkco) { GameObject go = chessBoard.GetChess(atkco); NPC npc = go.GetComponent <NPC>(); Dictionary <string, object> Params = new Dictionary <string, object>(); Params.Add("this", go); npc.pData.aggressiveSkill.Trigger(Params); GameObject[] ngos = chessBoard.GetNeighbors(atkco); // if(npc.pData.charType == NPC.CharType.STR) // { foreach (GameObject ngo in ngos) { if (ngo != null) { NPC nnpc = ngo.GetComponent <NPC>(); if (!NPC.IsEnemy(npc, nnpc)) { Dictionary <string, object> Params2 = new Dictionary <string, object>(); Params2.Add("this", nnpc.gameObject); nnpc.pData.assistSkill.Trigger(Params2); } } } // } // else if(npc.pData.charType == NPC.CharType.AGI) // { // foreach(GameObject ngo in ngos) // { // if(ngo != null) // { // NPC atkedNPC = ngo.GetComponent<NPC>(); // if(NPC.IsEnemy(npc, atkedNPC)) // { // foreach(GameObject assistpos in chessBoard.GetNeighbors(ngo)) // { // if(assistpos == null) // continue; // // NPC assistNPC = assistpos.GetComponent<NPC>(); // if(assistNPC != null && assistNPC != npc && NPC.IsEnemy(assistNPC, atkedNPC)) // { // npcAttack(assistNPC); // } // } // } // } // } // // } // else if(npc.pData.charType == NPC.CharType.WIS) // { // } // for(int i=0; i<chessboard.GetLength(0); ++i) // { // for(int j=0; j<chessboard.GetLength(1); ++j) // { // NPC npc = chessboard[i,j].GetComponent<NPC>(); // if(npc.playerID == turn) // { // foreach( NPC nnpc in GetAttackTargets(npc, i, j ) ) // { // nnpc.OnHit( npc); // } // } // } // } }