public void NeuerHai(string name) { Hai neuerHai = new Hai(name); _tiere.Add(neuerHai); }
protected void AddHai(Hai hai, int index) { int line = Mathf.Max(0, (index - this.yama_start) % MaxLines); int indexInLine = Mathf.Max(0, (index - this.yama_start) / MaxLines); Transform parent = top; if (line == 0) { parent = top; } else { parent = bottom; } // set position. align right. float posX = AlignRightLocalPos.x - MahjongPai.Width * indexInLine; Vector3 localPos = new Vector3(posX, 0, 0); MahjongPai pai = PlayerUI.CreateMahjongPai(parent, localPos, hai, false); mahjongYama.Add(index, pai); //if(index == 0 || index == 2 || index == Yama.YAMA_HAIS_MAX-2) pai.Show(); }
protected virtual void thinkReach() { _action.ReachSelectIndex = 0; List <int> reachHaiIndex = _action.ReachHaiIndexList; Tehai tehaiCopy = new Tehai(Tehai); int minScore = int.MaxValue; for (int i = 0; i < reachHaiIndex.Count; i++) { Hai hai = tehaiCopy.removeJyunTehaiAt(reachHaiIndex[i]); // reachHaiIndex[i], not i List <Hai> machiiHais; if (MahjongAgent.tryGetMachiHais(tehaiCopy, out machiiHais)) { for (int m = 0; m < machiiHais.Count; m++) { Hai addHai = machiiHais[m]; FormatWorker.setCounterFormat(tehaiCopy, addHai); int score = MahjongAgent.getAgariScore(tehaiCopy, addHai, JiKaze); if (score <= minScore) { minScore = score; _action.ReachSelectIndex = i; } } } tehaiCopy.insertJyunTehai(i, hai); } }
public void NeuerHai(string name) { Hai neuerHai = new Hai(name); _tiere.Add(neuerHai); neuerHai.FrissDenTaucher(); }
protected virtual void thinkSutehai(Hai addHai) { _action.SutehaiIndex = Tehai.getJyunTehaiCount(); Tehai tehaiCopy = new Tehai(Tehai); FormatWorker.setCounterFormat(tehaiCopy, null); int maxScore = getCountFormatScore(FormatWorker); for (int i = 0; i < tehaiCopy.getJyunTehaiCount(); i++) { Hai hai = tehaiCopy.removeJyunTehaiAt(i); FormatWorker.setCounterFormat(tehaiCopy, addHai); int score = getCountFormatScore(FormatWorker); if (score > maxScore) { maxScore = score; _action.SutehaiIndex = i; } tehaiCopy.insertJyunTehai(i, hai); } }
void InitDoraHais(Hai[] allOmoteDoras, Hai[] allUraDoras) { if (_omoteDoraHais != null) { ClearMahjongList(_omoteDoraHais); for (int i = 0; i < DoraHaisColumn; i++) { Vector3 pos = new Vector3(-i * (MahjongPai.Width + haiOffset), 0f, 0f); Hai hai = allOmoteDoras[i]; MahjongPai pai = PlayerUI.CreateMahjongPai(omoteDoraRoot, pos, hai, false); _omoteDoraHais.Add(pai); } } if (_uraDoraHais != null) { ClearMahjongList(_uraDoraHais); for (int i = 0; i < DoraHaisColumn; i++) { Vector3 pos = new Vector3(-i * (MahjongPai.Width + haiOffset), 0f, 0f); Hai hai = allUraDoras[i]; MahjongPai pai = PlayerUI.CreateMahjongPai(uraDoraRoot, pos, hai, false); _uraDoraHais.Add(pai); } } }
public static void copy(SuteHai dest, Hai src) { Hai.copy(dest, src); dest._isNaki = false; dest._isReach = false; dest._isTedashi = false; }
public void OnClickMahjong(int index) { for (int i = 0; i < buttons.Count; i++) { buttons [i].gameObject.SetActive(false); } Hai pai = kazePaiList [index]; int paiID = pai.ID; string name = ResManager.getMagjongName(pai.Kind, pai.Num); //Debug.Log ("OnClickMahjong("+name+")"+paiID); chiiChaIndex = ((Hai.ID_TON - paiID) + 4) % 4; Debug.Log("chiiChaIndex: " + chiiChaIndex.ToString()); for (int i = 0; i < pais.Count; i++) { Hai h = kazePaiList [i]; // pais [i].sprite = ResManager.getMahjongSprite( h.Kind, h.Num); pais[i].sprite = ResManager.getSelectCCSprite(h.Num); pais [i].transform.parent.gameObject.SetActive(true); cachePais.Add(h.ID, pais [i]); } StartCoroutine(MoveMahjongPaiToKaze(paiID, index)); }
public static void copy(SuteHai dest, SuteHai src) { Hai.copy(dest, src); dest._isNaki = src._isNaki; dest._isReach = src._isReach; dest._isTedashi = src._isTedashi; }
protected virtual void thinkSutehai(Hai addHai) { //_action.SutehaiIndex = Tehai.getJyunTehaiCount(); //_action.SutehaiIndex = UnityEngine.Random.Range(0, Tehai.getJyunTehaiCount ()-1); _action.SutehaiIndex = 0; /* * Tehai tehaiCopy = new Tehai( Tehai ); * * FormatWorker.setCounterFormat(tehaiCopy, null); * int maxScore = getCountFormatScore(FormatWorker); * * for( int i = 0; i < tehaiCopy.getJyunTehaiCount(); i++ ) * { * Hai hai = tehaiCopy.removeJyunTehaiAt(i); * * FormatWorker.setCounterFormat(tehaiCopy, addHai); * * int score = getCountFormatScore( FormatWorker ); * if( score > maxScore ) * { * maxScore = score; * _action.SutehaiIndex = i; * } * * tehaiCopy.insertJyunTehai(i, hai); * } */ }
public void Show() { Hai[] init_hais = new Hai[4] { new Hai(Hai.ID_TON), //27 %4 = 3 new Hai(Hai.ID_NAN), //28 %4 = 0 new Hai(Hai.ID_SYA), //29 %4 = 1 new Hai(Hai.ID_PE), //30 %4 = 2 }; Hai temp; for (int i = 0; i < init_hais.Length; i++) { int index = Random.Range(0, init_hais.Length); temp = init_hais[i]; init_hais[i] = init_hais[index]; init_hais[index] = temp; } gameObject.SetActive(true); kazePaiList = init_hais.ToList(); //cachePais //int rd = Utils.GetRandomNum(0,4); //OnClickMahjong(rd); StartCoroutine(_clickMj()); }
protected override EResponse OnHandle_KakanHai(EKaze fromPlayerKaze, Hai haiToHandle) { _action.Reset(); if (inTest) { return(DoResponse(EResponse.Nagashi)); } Hai kanHai = haiToHandle; int agariScore = MahjongAgent.getAgariScore(Tehai, kanHai, JiKaze); if (agariScore > 0) { if (GameSettings.AllowFuriten || !isFuriten()) { return(DoResponse(EResponse.Ron_Agari)); } else { Utils.LogWarningFormat("AI {0} is enable ron but furiten...", JiKaze.ToString()); } } return(DoResponse(EResponse.Nagashi)); }
protected override EResponse OnSelect_SuteHai(EKaze fromPlayerKaze, Hai haiToHandle) { _action.Reset(); _action.State = EActionState.Select_Sutehai; return(DisplayMenuList()); }
protected void AddHai(Hai hai, int index) { int line = Mathf.Max(0, (index - this.yama_start) % MaxLines); int indexInLine = Mathf.Max(0, (index - this.yama_start) / MaxLines); Transform parent = top; if (line == 0) { parent = top; } else { parent = bottom; } // set position. align right. float posX = AlignRightLocalPos.x - MahjongPai.Width * indexInLine; Vector3 localPos = new Vector3(posX, 0, 0); MahjongPai pai = PlayerUI.CreateMahjongPai(parent, localPos, hai, false); string name = ResManager.getMahjongTextureName(hai.Kind, hai.Num); //Debug.Log ("AddHai("+hai.ID+","+name+")"); mahjongYama.Add(index, pai); //if(index == 0 || index == 2 || index == Yama.YAMA_HAIS_MAX-2) pai.Show(); }
public void Show() { Hai[] init_hais = new Hai[4] { new Hai(Hai.ID_TON), new Hai(Hai.ID_NAN), new Hai(Hai.ID_SYA), new Hai(Hai.ID_PE), }; Hai temp; for (int i = 0; i < init_hais.Length; i++) { int index = Random.Range(0, init_hais.Length); temp = init_hais[i]; init_hais[i] = init_hais[index]; init_hais[index] = temp; } gameObject.SetActive(true); for (int i = 0; i < init_hais.Length; i++) { MahjongPai pai = PlayerUI.CreateMahjongPai(transform, new Vector3(leftPosX + i * offset, posY, 0), init_hais[i], false); pai.SetOnClick(OnClickMahjong); pai.EnableInput(); kazePaiList.Add(pai); } }
public override void Enter() { base.Enter(); logicOwner.PickNewTsumoHai(); if (logicOwner.checkNoTsumoHai()) { logicOwner.RyuuKyokuReason = ERyuuKyokuReason.NoTsumoHai; owner.ChangeState <LoopState_HandleRyuuKyoKu>(); } else { Hai tsumoHai = logicOwner.TsumoHai; int lastPickIndex = logicOwner.Yama.getPreTsumoHaiIndex(); if (lastPickIndex < 0) { Debug.LogError("Error!!!"); return; } EventManager.Get().SendEvent(UIEventType.PickTsumoHai, logicOwner.ActivePlayer, lastPickIndex, tsumoHai); owner.ChangeState <LoopState_AskHandleTsumoHai>(); } }
// 加槓を設定する public bool setKaKan(Hai tsumoHai) { if (!validKaKan(tsumoHai)) { return(false); } int relation = (int)ERelation.JiBun; //0; int newPickIndex = 3; for (int i = 0; i < _fuuros.Count; i++) { if (_fuuros[i].Type == EFuuroType.MinKou) { if (_fuuros[i].Hais[0].ID == tsumoHai.ID) { List <Hai> fuuroHais = new List <Hai>(_fuuros[i].Hais); fuuroHais.Add(new Hai(tsumoHai)); _fuuros[i].Update(EFuuroType.KaKan, fuuroHais.ToArray(), relation, newPickIndex); } } } return(true); }
// 大明槓を設定する public bool setDaiMinKan(Hai suteHai, int relation) { Hai[] hais = new Hai[Tehai.MENTSU_LENGTH_4]; hais[0] = new Hai(suteHai); int newPickIndex = 0; int count = 1; for (int i = 0; i < _jyunTehais.Count; i++) { if (_jyunTehais[i].ID == suteHai.ID) { hais[count] = new Hai(_jyunTehais[i]); count++; removeJyunTehaiAt(i); i--; if (count >= Tehai.MENTSU_LENGTH_4) { break; } } } _fuuros.Add(new Fuuro(EFuuroType.DaiMinKan, hais, relation, newPickIndex)); return(true); }
protected override EResponse OnSelect_SuteHai(EKaze fromPlayerKaze, Hai haiToHandle) { _action.Reset(); thinkSelectSuteHai(); return(DoResponse(EResponse.SuteHai)); }
public static string GetHCVPath(EVoiceType role, ECvType cv, Hai h) { string roleStr = role.ToString().ToLower(); string num = ((int)cv).ToString("000"); string path = string.Format("Sounds/MJ/b/{0}", h.ID); //Debug.Log ("GetHCVPath("+path+")"); return(path); }
// 捨牌の配列に牌を追加する public bool addHai(Hai hai) { if (_suteHais.Count >= SUTE_HAIS_LENGTH_MAX) { return(false); } _suteHais.Add(new SuteHai(hai)); return(true); }
public bool CheckHaiTypeOver9(Tehai tehai, Hai addHai) { if (!_game.isChiHou) { return(false); } if (tehai.getJyunTehaiCount() < Tehai.JYUN_TEHAI_LENGTH_MAX - 1) { return(false); } int[] checkId = { Hai.ID_WAN_1, Hai.ID_WAN_9, Hai.ID_PIN_1, Hai.ID_PIN_9, Hai.ID_SOU_1, Hai.ID_SOU_9, Hai.ID_TON, Hai.ID_NAN, Hai.ID_SYA, Hai.ID_PE, Hai.ID_HAKU, Hai.ID_HATSU, Hai.ID_CHUN }; int[] countNumber = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; //length = 13 //手牌をコピーする Hai[] checkHais = tehai.getJyunTehai(); for (int i = 0; i < checkHais.Length; i++) { for (int j = 0; j < checkId.Length; j++) { if (checkHais[i].ID == checkId[j]) { countNumber[j]++; } } } for (int j = 0; j < checkId.Length; j++) { if (addHai.ID == checkId[j]) { countNumber[j]++; } } int totalHaiType = 0; for (int c = 0; c < countNumber.Length; c++) { if (countNumber[c] > 0) { totalHaiType++; } } return(totalHaiType >= 9); }
// 純手牌の指定位置の牌をコピーする public bool copyJyunTehaiIndex(Hai hai, int index) { if (index >= _jyunTehais.Count) { return(false); } Hai.copy(hai, _jyunTehais[index]); return(true); }
// 純手牌に牌を追加する public bool addJyunTehai(Hai hai) { if (_jyunTehais.Count >= JYUN_TEHAI_LENGTH_MAX) { return(false); } _jyunTehais.Add(new Hai(hai)); return(true); }
public Yama() { for (int id = Hai.ID_MIN; id <= Hai.ID_MAX; id++) { for (int n = 0; n < 4; n++) { _yamaHais[(id * 4) + n] = new Hai(id); } } setTsumoHaisStartIndex(0); }
// 表ドラの配列を取得する public Hai[] getOpenedOmoteDoraHais() { int omoteDoraHaisCount = _rinshanHaisIndex + 1; Hai[] omoteDoraHais = new Hai[omoteDoraHaisCount]; for (int i = 0; i < omoteDoraHais.Length; i++) { Hai haiInYama = _yamaHais[OmoteDoraHaiIndex_InYama[i]]; omoteDoraHais[i] = new Hai(haiInYama); } return(omoteDoraHais); }
// 純手牌から指定の牌を削除する public bool removeJyunTehai(Hai hai) { for (int i = 0; i < _jyunTehais.Count; i++) { if (_jyunTehais[i].ID == hai.ID) { _jyunTehais.RemoveAt(i); return(true); } } return(false); }
/// <summary> /// 初始拿牌. /// </summary> public Hai[] PickHaipai() { Hai[] hais = new Hai[4]; for (int i = 0; i < hais.Length; i++) { Hai haiInYama = _yamaHais[TsumoHaiIndex_InYama[_tsumoHaisIndex]]; hais[i] = new Hai(haiInYama); _tsumoHaisIndex++; } return(hais); }
// 純手牌から指定位置の牌を削除する public Hai removeJyunTehaiAt(int index) { if (index >= _jyunTehais.Count) { return(null); } //Debug.Log("_jyunTehais.Count = " + _jyunTehais.Count + "Hai index = " + index); //CSU Hai hai = _jyunTehais[index]; _jyunTehais.RemoveAt(index); return(hai); }
public void ShowPai(int index, Hai h) { Image im = null; Sprite sp = ResManager.getMahjongSprite(h.Kind, h.Num); if (index < Pais.Count) { im = Pais [index]; im.sprite = sp; im.transform.parent.parent.gameObject.SetActive(true); } StartCoroutine(HidePai(index)); }