private void ShowMoneyAction(ActionString moneyString) { MoneyAction.MoneyActor payer = (MoneyAction.MoneyActor)Enum.Parse(typeof(MoneyAction.MoneyActor), moneyString.variables[0]); moneyString.variables[0] = EditorGUILayout.EnumPopup("Payer", payer).ToString(); MoneyAction.MoneyActor receiver = (MoneyAction.MoneyActor)Enum.Parse(typeof(MoneyAction.MoneyActor), moneyString.variables[1]); moneyString.variables[1] = EditorGUILayout.EnumPopup("Receiver", receiver).ToString(); float amount = float.Parse(moneyString.variables[2]); moneyString.variables[2] = EditorGUILayout.FloatField("Amount", amount).ToString(); }
/// <summary> /// Tworzy obiekt Akcji na podstawie informacji zawartych w ActionStringu(Nazwa klasy + lista zmiennych) /// </summary> /// <param name="form">Obiekt przechowujący informacje o ActionCardzie</param> /// <returns></returns> public static ActionCard Create(ActionString form) { ActionCard card = null; switch (form.actionType) { case ActionType.Money: { MoneyAction.MoneyActor payer = (MoneyAction.MoneyActor)Enum.Parse(typeof(MoneyAction.MoneyActor), form.variables[0]); MoneyAction.MoneyActor receiver = (MoneyAction.MoneyActor)Enum.Parse(typeof(MoneyAction.MoneyActor), form.variables[1]); float value = float.Parse(form.variables[2]); card = new MoneyAction(payer, receiver, value); } break; case ActionType.Wait: { WaitAction.WaitActor target = (WaitAction.WaitActor)Enum.Parse(typeof(WaitAction.WaitActor), form.variables[0]); int rounds = int.Parse(form.variables[1]); card = new WaitAction(target, rounds); } break; case ActionType.Move: { MoveAction.Mode mode = (MoveAction.Mode)Enum.Parse(typeof(MoveAction.Mode), form.variables[0]); int byAmount = int.Parse(form.variables[1]); MoveAction.ToTarget toTarget = (MoveAction.ToTarget)Enum.Parse(typeof(MoveAction.ToTarget), form.variables[2]); int targetId = int.Parse(form.variables[3]); MoveAction.PlaceTypeTarget targetType = (MoveAction.PlaceTypeTarget)Enum.Parse(typeof(MoveAction.PlaceTypeTarget), form.variables[4]); MoveAction.MovementType movementType = (MoveAction.MovementType)Enum.Parse(typeof(MoveAction.MovementType), form.variables[5]); card = new MoveAction(mode, byAmount, toTarget, targetId, targetType, movementType); } break; case ActionType.WithUser: { ActionType insideType = (ActionType)Enum.Parse(typeof(ActionType), form.variables[0]); if (insideType != ActionType.WithUser) { ActionString insideActionString = ActionString.FromString(form.variables[(int)insideType + 1]); ActionCard insideAction = Create(insideActionString); card = new WithUserAction(insideAction); } else { Debug.LogError("Nie można zagnieżdzać typu WithUser w akcji typu WithUser"); } } break; case ActionType.Imprison: { card = new ImprisonAction(); } break; } return(card); }