public static int[] CalcPath1Steps(int[] map, JgNation nation, int location, JgFilter filter) { //nation = FindNation(map[location]); List<int> locations = new List<int>(); // 12 -> 12+1, 12+10, 12-1, 12-10 tempInts[0] = location + 1; tempInts[1] = location + 10; tempInts[2] = location - 1; tempInts[3] = location - 10; // int count = 0; for (int i = 0; i < 4; ++i) AddReachable(map, locations, nation, tempInts[i]); List<int> locations2 = new List<int>(); switch (filter) { case JgFilter.kNoFilter: foreach (int loc in locations) locations2.Add(loc); break; case JgFilter.kOurSide: foreach (int loc in locations) { if (IsOurSide(nation, map[loc]) == false) locations2.Add(loc); } break; case JgFilter.kEnemySide: foreach (int loc in locations) { if (IsEnemy(nation, map[loc]) == false) locations2.Add(loc); } break; case JgFilter.kAllSide: foreach (int loc in locations) { if (map[loc] == 0) locations2.Add(loc); } break; } return locations2.ToArray(); }
static void AddReachablePoInCastle(int[] map, JgNation nation, int occulusion, int target, List<int> locations) { bool canPass = map[occulusion] % 10 != Jg.PO && map[occulusion] != 0; if (canPass && IsOurSide(nation, map[target]) == false) locations.Add(target); }
static void AddReachablePo(int[] map, List<int> locations, JgNation nation, int target) { if (IsReachable(map, nation, target) && (map[target] % 10) != Jg.ChoPo) locations.Add(target); }
static void AddReachable(int[] map, List<int> locations, JgNation nation, int target) { if (IsReachable(map, nation, target)) locations.Add(target); }
public static bool IsReachable(int[] map, JgNation nation, int location) { return IsValidLocation(location) && IsOurSide(nation, map[location]) == false; }
public static bool IsOurSide(JgNation nation, int piece) { if (nation == JgNation.kCho && piece < 10 && piece > 0) return true; else if (nation == JgNation.kHan && piece > 10) return true; return false; }
public static bool IsEnemy(JgNation nation, int piece) { if (nation == JgNation.kCho && piece >= Jg.HanJang) return true; else if (nation == JgNation.kHan && piece > 0 && piece < 10) return true; return false; }
void OnNtfMatch(TBase message) { // Debug.Log("VirtualPlayer.OnNtfMatch \n" + message.ToString()); NtfMatch msg = message as NtfMatch; //Debug.Log(string.Format("{0} got a match. localId({1}), \n{2}", ansLogin.NickName, msg.LocalId, message.ToString())); nation = msg.LocalId == 0 ? JgNation.kCho : JgNation.kHan; localId = msg.LocalId; this.Invoke("SendSangcharim", 1f); }