// } else { // if (isClearing) { // view_frame = view_period; // isClearing = false; // } // } // } //色の決定 void ViewFadeColor() { // if (view_frame == view_period - 1 && !isClearing) { //最初の色を決定 if (!isClearing) { colorFrame = -1; colorFrom = CardObj.GetStartColor(card); } //次の色を決定 if (colorFrame < 0) { colorFrom = colorTo; int colorHave = 0; for (int i = 0; i < (int)Card.Color.size; ++i) { if (card.color[(i + 1 + (int)colorFrom) % (int)Card.Color.size] > 0) { colorTo = (Card.Color)((i + 1 + (int)colorFrom) % (int)Card.Color.size); ++colorHave; break; } } if (colorHave == 0) { colorTo = Card.Color.size; ++colorHave; } if (colorHave == 1) { colorFrame = colorPeriodAdd; colorPeriod = colorPeriodAdd; } else { colorFrame = colorPeriod = (colorPeriodMin + (colorHave - 2) * colorPeriodAdd) / (colorHave - 1); } } //色を確定させて塗る if (colorFrom != colorTo || !isClearing) { for (int i = 0; i < (int)CardObj.ColorMaterial.size; ++i) { Card.State iState = 0; switch ((CardObj.ColorMaterial)i) { case CardObj.ColorMaterial.frame: case CardObj.ColorMaterial.name: continue; case CardObj.ColorMaterial.cost: iState = Card.State.cost; break; case CardObj.ColorMaterial.power: iState = Card.State.power; break; case CardObj.ColorMaterial.toughness: iState = Card.State.toughness; break; } GameObject obj = obj_stateView[(int)iState]; //外部のカードの情報を用いる Color color = Utility.GetRatio( CardObj.colorList[(int)colorFrom][i], CardObj.colorList[(int)colorTo][i], (Mathf.Cos(Mathf.PI * colorFrame / colorPeriod) + 1f) / 2); color.a = viewFrame / viewPeriod; obj.GetComponent <Image>().color = color; if ((CardObj.ColorMaterial)i == CardObj.ColorMaterial.cost) { obj_characterStateView[(int)Card.CharacterState.mana].GetComponent <Image>().color = color; obj_characterStateView[(int)Card.CharacterState.od].GetComponent <Image>().color = color; } } } colorFrame = (colorFrame + 1) % colorPeriod; }
//カード情報をウィンドウに反映させる void WriteWindow(Card _card) { text_name.text = _card.GetName(); text_user.text = ""; for (int i = 0; i < _card.GetUser().Length; ++i) { text_user.text += i == 0 ? "" : " " + _card.GetUser()[i]; } // //書き換えタイミング // if (view_frame == view_period - 1 && !isClearing) { // //if (!isClearing) { // Card cs = card; //GetByteCountは使えない //nm_size = nm_char_size * System.Text.Encoding.GetEncoding(932) // .GetByteCount(nm.text.ToString()) / 2; var gui = new GUIStyle() { font = font_name }; nameSize = gui.CalcSize(new GUIContent(text_name.text)).x; text_name.rectTransform.offsetMin.Set(0, text_name.rectTransform.offsetMin.y); nameMode = ScrollMode.size - 1; nameFrame = -1; //nmMode = NameModeType.size - 1; //nm_frame = -1; //テキストの決定 //テキストで使えるのは //\n : 改行 //\h : ぶら下げ float textLength = 0; //1行に入るテキスト長さ float textLine = 0; //縦の長さ int lineStart = 0; //一行の開始地点 int lineFromFirst = 0; //段落から何行目か bool yen = false; //直前が\のときに真 bool breakFlag = false; //改行フラグ string hungFirst = ""; //段落冒頭の左側 string hungSecond = ""; //段落冒頭以外の左側 string buffer = ""; //これを最終的にtxt.textに流す gui = new GUIStyle() { font = font_text }; for (int i = 0; i < _card.text.Length; ++i) { if (_card.text[i] == '\\') { yen = true; continue; } if (yen) { yen = false; switch (_card.text[i]) { case 'n': breakFlag = true; hungFirst = ""; hungSecond = ""; continue; case 'h': breakFlag = true; hungFirst = ""; hungSecond = " "; continue; } } textLength += gui.CalcSize(new GUIContent(_card.text[i].ToString())).x; if (textLength > textLengthBorder || breakFlag || i == _card.text.Length - 1) { string line = _card.text.Substring(lineStart, i - lineStart); line = line.Replace("\\n", ""); line = line.Replace("\\h", ""); buffer += lineFromFirst == 0 ? hungFirst : hungSecond + line + "\n"; lineStart = i; if (breakFlag) { lineFromFirst = 0; } else { ++lineFromFirst; } textLine += gui.CalcSize(new GUIContent(_card.text[i].ToString())).y; textLength = gui.CalcSize(new GUIContent( (lineFromFirst == 0 ? hungFirst : hungSecond))).x; breakFlag = false; } } text_text.text = buffer; //offsetMin = new Vector2 (left,top); //offsetMax = new Vector2 (right,bottom); var hoge = new Vector2(0, textLineBorder - textLine); text_text.rectTransform.offsetMin = hoge; if (textLine < textLineBorder) { text_text.rectTransform.offsetMax = hoge; obj_textScroll.GetComponent <ScrollRect>().vertical = false; } else { text_text.rectTransform.offsetMax = new Vector2(0, 0); obj_textScroll.GetComponent <ScrollRect>().vertical = true; } obj_textScroll.GetComponent <ScrollRect>().verticalNormalizedPosition = 1f; //コスト火力耐久の反映 for (int i = 0; i < obj_stateView.Length; ++i) { int state = 0; switch ((Card.State)i) { case Card.State.cost: state = _card.GetCost(); break; case Card.State.power: state = _card.GetPower(); break; case Card.State.toughness: state = _card.GetToughness(); break; } stateNum[i].GetComponent <Number>().num = state; stateNum[i].transform.localScale = new Vector3(1, 1, 0) * numScale; } stateNum[(int)Card.State.cost].GetComponent <Number>().isVisible = _card.type != Card.Type.character; for (int i = 0; i < (int)Card.CharacterState.size; ++i) { var isTypeChar = _card.type == Card.Type.character; obj_characterStateView[i].SetActive(isTypeChar); characterStateNum[i].GetComponent <Number>().isVisible = isTypeChar; characterStateNum[i].transform.localScale = new Vector3(1, 1, 0) * numScale; int state = 0; switch ((Card.CharacterState)i) { case Card.CharacterState.mana: state = _card.mana; break; case Card.CharacterState.manaCapacity: state = _card.manaCapacity; break; case Card.CharacterState.od: state = _card.od; break; } characterStateNum[i].GetComponent <Number>().num = state; } //彩度の決定 foreach (var i in chromas) { Destroy(i); } foreach (var i in chromaNums) { Destroy(i); } chromas.Clear(); chromaNums.Clear(); //スタート地点を見つける Card.Color start = CardObj.GetStartColor(_card); //シンボルの種類を数える int colorHave = 0; for (int i = 0; i < (int)Card.Color.size; ++i) { if (_card.color[i] > 0) { ++colorHave; } } //配置する for (int i = 0, a = 0; i < (int)Card.Color.size; ++i) { int b = ((int)start + i) % (int)Card.Color.size; if (0 < _card.color[b]) { var obj = Utility.InstantiateWithTransform(orig_chroma, orig_chroma.transform); obj.transform.localPosition += new Vector3(chromaBlank * a++, 0, 0); obj.transform.localScale = new Vector3(1, 1, 1) * chromaScale; obj.GetComponent <Image>().sprite = chromaPic[b]; chromas.Add(obj); if (1 < _card.color[b]) { var num = Instantiate(orig_num, obj.transform.position + chromaNumPos, obj.transform.rotation, obj.transform); num.GetComponent <Number>().num = _card.color[b]; num.transform.localScale = new Vector3(1, 1, 0) * chromaNumScale; chromaNums.Add(num); } } } }