public GameObject InstantiateCommandButton(GameObject board, BattleMapCommandType commandType) { GameObject prefab = null; switch (commandType) { case BattleMapCommandType.MOVE: prefab = buttonCommandGreenPrefab; break; case BattleMapCommandType.ACTION: prefab = buttonCommandRedPrefab; break; case BattleMapCommandType.SUMMON: prefab = buttonCommandAquaPrefab; break; } GameObject go = Instantiate(prefab) as GameObject; go.transform.SetAsLastSibling(); go.transform.SetParent(board.transform, false); // y位置とサイズ // x位置は動的に変更されるためここでは設定しない RectTransform rect = go.GetComponent <RectTransform>(); rect.anchoredPosition = new Vector2(rect.anchoredPosition.x, BUTTON_ACTION_Y); rect.sizeDelta = new Vector2(BUTTON_ACTION_WIDTH, BUTTON_ACTION_HEIGHT); return(go); }
/// <summary> /// コマンドの追加 /// </summary> public void AddCommand() { string text = dropdownAddCommand.captionText.text; BattleMapCommandType commandType = BattleMapCommandType.MOVE; if (text == "Move") { commandType = BattleMapCommandType.MOVE; } else if (text == "Action") { commandType = BattleMapCommandType.ACTION; } else if (text == "Summon") { commandType = BattleMapCommandType.SUMMON; } // ボード BattleMapCommandBoard commandBoard = holder.GetCurrentTeam().CommandBoard; // コマンドを作成 BattleMapCommand command = CreateBattleMapCommand(commandBoard.GameObject, commandType, UnityEngine.Random.Range(2, 5)); commandBoard.CommandList.Add(command); // ボードの更新 commandController.DrawActionBoard(); }
public BattleMapCommand(BattleMapCommandType commandType, int maxCount) { this.CommandType = commandType; this.MaxCount = maxCount; this.Count = maxCount; id = "" + idIndex++; if (System.Int32.MaxValue == idIndex) { idIndex = 0; } }
/// <summary> /// コマンドを作成 /// </summary> /// <param name="boardGo"></param> /// <param name="commandType"></param> /// <param name="maxCount"></param> /// <returns></returns> private BattleMapCommand CreateBattleMapCommand(GameObject boardGo, BattleMapCommandType commandType, int maxCount) { // ゲームオブジェクトの作成 BattleMapCommand command = new BattleMapCommand(commandType, maxCount); command.ButtonGameObject = commandPrefabHolder.InstantiateCommandButton(boardGo, command.CommandType); command.TextGameObject = commandPrefabHolder.InstantiateCommandCountText(command.ButtonGameObject); // テキスト command.TextGameObject.GetComponent <Text>().text = "" + command.MaxCount; // ボタンにイベント追加 Button button = command.ButtonGameObject.GetComponent <Button>(); button.onClick.AddListener(() => commandController.PushCommandButton(command.Id)); return(command); }
public void SetStatusTypeByCommandType(BattleMapCommandType commandType) { switch (commandType) { case BattleMapCommandType.MOVE: this.BattleMapStatusType = BattleMapStatusType.MOVE; break; case BattleMapCommandType.ACTION: this.BattleMapStatusType = BattleMapStatusType.ACTION; break; case BattleMapCommandType.SUMMON: this.BattleMapStatusType = BattleMapStatusType.SUMMON; break; default: throw new ArgumentException("invalid commandType:" + commandType); } }