Ejemplo n.º 1
0
        public IHttpActionResult UpdateGameScene(int eventChoiceId, int route)
        {
            //will need to think about where to save player character, possibly pass in player id
            var         currentEventChoice = gameService.FindEventChoiceById(eventChoiceId);
            EventChoice NextEventChoice    = null;

            if (currentEventChoice.PositiveRoute > 0 && currentEventChoice.NegativeRoute > 0)
            {
                if (currentEventChoice.PositiveRoute > 0)
                {
                    NextEventChoice = gameService.FindEventChoiceById(route);
                }
                if (currentEventChoice.NegativeRoute > 0)
                {
                    NextEventChoice = gameService.FindEventChoiceById(route);
                }
            }

            if (currentEventChoice.PositiveSceneRoute == route || currentEventChoice.NegativeSceneRoute == route)
            {
                var newScene = new NewScene();
                newScene.Scene = gameService.FindSceneById(currentEventChoice.SceneId + 1);
                //newScene.EventChoice = gameService.FindEventChoiceById(newScene.Scene.);
            }
            return(Ok(NextEventChoice));
        }
Ejemplo n.º 2
0
        private EventChoice Update(EventChoice eventChoice)
        {
            const string sql = "UPDATE EventChoice SET "
                               + "SceneId = @SceneId, "
                               + "GenerationNumber = @GenerationNumber, "
                               + "EventName = @EventName, "
                               + "StartText = @StartText, "
                               + "PositiveText = @PositiveText, "
                               + "NegativeText = @NegativeText, "
                               + "PositiveRoute = @PositiveRoute, "
                               + "NegativeRoute = @NegativeRoute "
                               + "PositiveButton = @PositiveButton, "
                               + "NegativeButton = @NegativeButton, "
                               + "PositiveSceneRoute = @PositiveSceneRoute, "
                               + "NegativeSceneRoute = @NegativeSceneRoute, "
                               + "PositiveEndingId = @PositiveEndingId, "
                               + "NegativeEndingId = @NegativeEndingId "
                               + "WHERE EventChoiceId = @EventChoiceId;";

            using (var conn = Database.GetOpenConnection(CONN_STRING_KEY))
            {
                if (conn.Execute(sql, eventChoice) > 0)
                {
                    return(eventChoice);
                }
            }

            return(null);
        }
Ejemplo n.º 3
0
 public void InitChoice(EventChoice data)
 {
     if (data == null)
     {
         gameObject.SetActive(false);
     }
     else
     {
         gameObject.SetActive(true);
         currentChoice     = data;
         choiceName.text   = currentChoice.choiceName;
         choiceEffect.text = EffectString(currentChoice.type, currentChoice.amount);
         if (currentChoice.typeSecondary != FXT.None)
         {
             choiceEffect.text += ", " + EffectString(currentChoice.typeSecondary, currentChoice.amountSecondary);
         }
         if (IsLimited(currentChoice.type, currentChoice.amount) || IsLimited(currentChoice.typeSecondary, currentChoice.amountSecondary))
         {
             myButton.interactable = false;
             choiceName.color      = GM.I.art.gray;
         }
         else
         {
             myButton.interactable = true;
             choiceName.color      = GM.I.art.white;
         }
     }
 }
            private static bool MergeScripts(ScriptsType from, ScriptsType to, EventChoice eventChoice)
            {
                if (from.Events.ContainsKey(eventChoice))
                {
                    if (to == null)
                    {
                        to = from;
                        return(false);
                    }
                    else
                    {
                        // Retrieve current event handler script
                        string currentScript = to.Events.ContainsKey(eventChoice) && to.Events[eventChoice] != null ? to.Events[eventChoice] : String.Empty;

                        // Append script to be merged
                        currentScript += from.Events[eventChoice] ?? String.Empty;

                        // Update event handler script
                        to.Events[eventChoice] = currentScript;

                        return(true);
                    }
                }

                return(false);
            }
Ejemplo n.º 5
0
    private void ShowConfirmScreen(EventChoice choice)
    {
        if (choice.SkipConfirm)
        {
            EndEventWithoutResults();
            if (startBattle)
            {
                GameManager.Instance.LoadBattleScene();
            }
        }
        else
        {
            string confirmText    = "OK";
            string gainOrLostText = "";
            if (choice.Action == Action.Gain)
            {
                gainOrLostText = GetGainString(choice.Gain);
            }
            else if (choice.Action == Action.Lose)
            {
                gainOrLostText = GetLostString(choice.Gain);
            }

            if (!choice.ShowGainNameInResult)
            {
                gainOrLostText = "";
            }
            ui.eventDialog.ShowResults(choice.ResultText, gainOrLostText, confirmText);
        }
    }
Ejemplo n.º 6
0
    public void parseChoiceLog(EventChoice choice)
    {
        foreach (ResChange change in choice.resChanges)
        {
            if (change.changeValue != 0)
            {
                if (change.changeValue > 0)
                {
                    addLog(change.resource + " increased by " + change.changeValue + " (" + GameEventHandler.main.currentEvent.header + ")");
                }
                else
                {
                    addLog(change.resource + " depleted by " + change.changeValue + " (" + GameEventHandler.main.currentEvent.header + ")");
                }
            }
        }

        foreach (StatChange change in choice.statChanges)
        {
            if (change.changeValue != 0)
            {
                if (change.changeValue > 0)
                {
                    addLog("Your " + change.stat + " improved by " + change.changeValue + " (" + GameEventHandler.main.currentEvent.header + ")");
                }
                else
                {
                    addLog("Your " + change.stat + " deteriorated by " + change.changeValue + " (" + GameEventHandler.main.currentEvent.header + ")");
                }
            }
        }
    }
        public EventPropertyDescriptor(string name)
            : base(name, EventPropertyDescriptor.attributes)
        {
            this.eventName = (EventChoice)Enum.Parse(typeof(EventChoice), name);

            // this.cate
        }
Ejemplo n.º 8
0
    public bool requirementsMet(Transform choiceParent, EventChoice choice)
    {
        Transform reqPanel = choiceParent.transform.Find("RequirementPanel").transform;

        foreach (ResReq req in choice.resReqs)
        {
            DisplayRequirement.main.displayResourceRequirement(reqPanel, req.resource, req.minimum);
            PlayerResources resource = GameInformation.main.playerResources.Find(delegate(PlayerResources res) { return(res.name == req.resource); });
            if (resource.currentValue < req.minimum)
            {
                return(false);
            }
        }
        foreach (StatReq req in choice.statReqs)
        {
            DisplayRequirement.main.displayStatRequirement(reqPanel, req.stat, req.minimum);
            PlayerStats stat = GameInformation.main.playerStats.Find(delegate(PlayerStats st) { return(st.name == req.stat); });
            if (stat.currentValue < req.minimum)
            {
                return(false);
            }
        }
        if (GameInformation.main.currentEnergy + choice.energyChange < 0)
        {
            return(false);
        }
        return(true);
    }
Ejemplo n.º 9
0
 public EventChoice Save(EventChoice eventChoice)
 {
     if (eventChoice.EventChoiceId > 0)
     {
         return(Update(eventChoice));
     }
     return(Insert(eventChoice));
 }
Ejemplo n.º 10
0
    public void SelectChoice(EventChoice choice, Item usage)
    {
        EventOutcome outcome = choice.Outcome(currentUnit, usage, text);

        text.ClearChoices();
        DisplayOutcome(outcome);
        text.NextLine();
    }
    public void CreateChoice(EventChoice e)
    {
        if (e.itemRequirement != null)
        {
            useItem.Init(e, manager);
        }
        DialogueChoice choice = Instantiate <DialogueChoice>(chiocePrefab, choiceContent.transform);

        choice.Init(e, manager);
        choices.Add(choice);
    }
Ejemplo n.º 12
0
        private EventChoice Insert(EventChoice eventChoice)
        {
            const string sql = "INSERT INTO EventChoice (SceneId, GenerationNumber, EventName, StartText, PositiveText, NegativeText, PositiveRoute, NegativeRoute, PositiveButton, NegativeButton, PositiveSceneRoute, NegativeSceneRoute, PositiveEndingId, NegativeEndingId) "
                               + "VALUES (@EventChoiceId, @SceneId, @GenerationNumber, @EventName, @StartText, @PositiveText, @NegativeText, @PositiveRoute, @NegativeRoute, @PositiveButton, @NegativeButton, @PositiveSceneRoute, @NegativeSceneRoute, @PositiveEndingId, @NegativeEndingId); "
                               + "SELECT SCOPE_IDENTITY()";

            using (var conn = Database.GetOpenConnection(CONN_STRING_KEY))
            {
                eventChoice.EventChoiceId = conn.Query <int>(sql, eventChoice).First();
            }
            return(eventChoice);
        }
Ejemplo n.º 13
0
    public void applyChoiceEffects(EventChoice choice)
    {
        foreach (ResChange change in choice.resChanges)
        {
            GameInformation.main.playerResources.Find(delegate(PlayerResources res) { return(res.name == change.resource); }).currentValue += change.changeValue;
        }
        foreach (StatChange change in choice.statChanges)
        {
            GameInformation.main.playerStats.Find(delegate(PlayerStats stat) { return(stat.name == change.stat); }).currentValue += change.changeValue;
        }
        GameInformation.main.currentEnergy += choice.energyChange;
        if (choice.addToSceneQueue != null)
        {
            if (choice.addToSceneQueue.occurs == EventOccurrence.Immediately)
            {
                GameInformation.main.todaysEvents.Insert(0, choice.addToSceneQueue);
            }
            else
            {
                GameInformation.main.queuedEvents.Add(choice.addToSceneQueue);
                if (choice.addToSceneQueue.occurs == EventOccurrence.OnDelay)
                {
                    choice.addToSceneQueue.dayDelayTarget = GameInformation.main.currentDay += choice.addToSceneQueue.dayDelayAmount;
                }
            }
        }
        if (choice.removeFromSceneQueue != null)
        {
            int matchIndex = GameInformation.main.queuedEvents.FindIndex(delegate(GameEvent evn) { return(evn.name == choice.removeFromSceneQueue.name); });
            GameInformation.main.queuedEvents.RemoveAt(matchIndex);
        }
        if (choice.addToLocations != null)
        {
            if (!GameInformation.main.availableLocations.Contains(choice.addToLocations))
            {
                GameInformation.main.availableLocations.Add(choice.addToLocations);
            }
        }
        if (choice.removeFromLocations != null)
        {
            GameInformation.main.availableLocations.Remove(choice.removeFromLocations);
        }
        if (choice.addToTraps != null)
        {
            GameInformation.main.availableTraps.Add(choice.addToTraps);
        }


        DisplayGameInformation.main.updateAllDisplays();
        LogDisplay.main.parseChoiceLog(choice);
    }
 public void Init(EventChoice choice, DialogueManager parent)
 {
     if (backgroundlayout == null)
     {
         Awake();
     }
     manager         = parent;
     current         = choice;
     choiceText.text = choice.choiceDescription;
     Canvas.ForceUpdateCanvases();
     textSize.SetLayoutVertical();
     backgroundlayout.CalculateLayoutInputVertical();
     backgroundSize.SetLayoutVertical();
 }
Ejemplo n.º 15
0
    public void submitChoice()
    {
        EventChoice selectedChoice = EventSystem.current.currentSelectedGameObject.GetComponent <ChoiceDataHolder>().choiceData;

        GameInformation.main.todaysEvents.RemoveAt(0);
        GameEventHandler.main.applyChoiceEffects(selectedChoice);
        Destroy(GameEventHandler.main.subPanel);
        if (GameInformation.main.todaysEvents.Count == 0)
        {
            GameEventHandler.main.eventPanel.SetActive(false);
        }
        else
        {
            GameEventHandler.main.displayNextEvent();
        }
    }
        /// <summary>
        /// Creates a method signature in the source code file for the default event on the component and navigates the user's cursor to that location.
        /// </summary>
        /// <exception cref="T:System.ComponentModel.Design.CheckoutException">An attempt to check out a file that is checked into a source code management program failed.</exception>
        public override void DoDefaultAction()
        {
            base.DoDefaultAction();

            BaseControl baseControl = this.Component as BaseControl;

            if (baseControl == null)
            {
                return;
            }
            if (baseControl.Inherited)
            {
                return;
            }

            if (baseControl.DefaultEventChoice.HasValue)
            {
                FrameType frameType = baseControl.SerializationObject as FrameType;
                if (frameType == null)
                {
                    return;
                }

                if (frameType.Scripts.Count == 0)
                {
                    frameType.Scripts.Add(new ScriptsType());
                }

                IDictionary <EventChoice, string> events = frameType.Scripts[0].Events;
                EventChoice eventChoice = baseControl.DefaultEventChoice.Value;
                string      eventHandlerName;

                if (events.ContainsKey(eventChoice))
                {
                    eventHandlerName = events[eventChoice].Trim().TrimEnd(';').TrimEnd(')').TrimEnd('(');
                }
                else
                {
                    eventHandlerName = String.Format("{0}_{1}", frameType.name, eventChoice);
                    events.Add(eventChoice, eventHandlerName + "();");
                }

                //LuaInterface luaInterface = new LuaInterface(baseControl.DesignerLoader);
                //luaInterface.CreateShowFunction(eventHandlerName);
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// 解析 Tip
        /// </summary>
        /// <param name="ID">事件 ID</param>
        /// <param name="Choice">选项</param>
        /// <param name="TargetActorID">对方的 ID</param>
        /// <param name="Tip"></param>
        /// <returns></returns>
        public static string AnalyzeTip(string ID, EventChoice Choice, int TargetActorID, string Tip)
        {
            if (Tip.Contains("[Effect]"))
            {
                string effect = "Effect:";
                foreach (var i in Choice.Effect.Effects)
                {
                    switch (i.Type)
                    {
                    case ChoiceEnd.Effect.EffectTarget.Time:
                        effect += "\n·时间" + (i.Reduce ? "<color=#FF0000FF>减少" : "<color=#00FF00FF>增加") + $"</color> {i.ValueA}";
                        break;

                    case ChoiceEnd.Effect.EffectTarget.Item:
                        effect += "\n·" + (i.ValueB == 0 ? "太吾" : DateFile.instance.GetActorName(TargetActorID)) + (i.Reduce ? "<color=#FF0000FF>失去" : "<color=#00FF00FF>获得") + $"</color>物品:\n {DateFile.instance.GetItemDate(i.ValueA, 0)}";
                        break;

                    case ChoiceEnd.Effect.EffectTarget.MoveToAround:
                        effect += "\n·" + (i.ValueA == 0 ? "太吾" : DateFile.instance.GetActorName(TargetActorID)) + $"移动到周围";
                        break;

                    case ChoiceEnd.Effect.EffectTarget.Favor:
                        effect += "\n·对方好感" + (i.Reduce ? "<color=#FF0000FF>减少" : "<color=#00FF00FF>增加") + $"</color> {i.ValueA}";
                        break;

                    case ChoiceEnd.Effect.EffectTarget.TaiwuResource:
                    case ChoiceEnd.Effect.EffectTarget.TargetResource:
                        var flag = i.Type == ChoiceEnd.Effect.EffectTarget.TaiwuResource;
                        effect += "\n·" + (flag ? "太吾" : DateFile.instance.GetActorName(TargetActorID)) + RuntimeConfig.ResourceName[i.ValueA] + (i.Reduce ? "<color=#FF0000FF>减少" : "<color=#00FF00FF>增加") + $"</color> {i.ValueA}";
                        break;

                    default:
                        break;
                    }
                }
                Tip = Tip.Replace("[Effect]", effect.Length > 7 ? effect + "\n" : "");
            }
            var result = Tip.Replace("[TargetActorName]", DateFile.instance.GetActorName(DateFile.instance.mianActorId))
                         .Replace("[TaiwuName]", DateFile.instance.GetActorName())
                         .Replace("[TargetActorGang]", DateFile.instance.GetGangDate(int.Parse(DateFile.instance.GetActorDate((TargetActorID > 0) ? TargetActorID : DateFile.instance.mianActorId, 19, applyBonus: false)), 0));

            return(result);
        }
Ejemplo n.º 18
0
 public EventChoice CreateEventChoice(EventChoice eventChoice)
 {
     return(choiceRepo.Save(eventChoice));
 }
            private static bool MergeScripts(ScriptsType from, ScriptsType to, EventChoice eventChoice)
            {
                if (from.Events.ContainsKey(eventChoice))
                {
                    if (to == null)
                    {
                        to = from;
                        return false;
                    }
                    else
                    {
                        // Retrieve current event handler script
                        string currentScript = to.Events.ContainsKey(eventChoice) && to.Events[eventChoice] != null ? to.Events[eventChoice] : String.Empty;

                        // Append script to be merged
                        currentScript += from.Events[eventChoice] ?? String.Empty;

                        // Update event handler script
                        to.Events[eventChoice] = currentScript;

                        return true;
                    }
                }

                return false;
            }
Ejemplo n.º 20
0
 private void buttonUnLineRun_Click(object sender, EventArgs e)
 {
     EventChoice?.Invoke(false);
     Close();
 }
Ejemplo n.º 21
0
 public void ChooseEventChoice(EventChoice EC)
 {
     LoadUnit(EC.GetTarget());
 }
Ejemplo n.º 22
0
    private void EventResults(EventType actionEvent, int actionIndex)
    {
        eventResultsSeen = true;
        EventChoice choice = actionEvent.Choices[actionIndex];

        startBattle = false;

        switch (choice.Action)
        {
        case Action.Fight:
        {
            startBattle = true;
            break;
        }

        case Action.Gain:
        {
            if (choice.Gain.Type == EventGain.GainType.Upgrade)
            {
                inventoryManager.AddItem(promisedRewardItem);
                Debug.Log("Got item [" + promisedRewardItem + "] of tier "
                          + promisedRewardItem.UpgradeData.Tier);
                SFXPlayer.Instance.Play(Sound.Hop1, volumeFactor: 0.7f);
            }
            else if (choice.Gain.Type == EventGain.GainType.Floor)
            {
                FloorData fd = new FloorData(
                    ContentManager.Instance.GetRandomFloorType(actionEvent.Tier),
                    ContentManager.Instance.GetRandomWallType(actionEvent.Tier));
                GameManager.Instance.PlayerHome.Floors.Add(fd);
                GameManager.Instance.home.UpdateHome();
                SFXPlayer.Instance.Play(Sound.Repair, volumeFactor: 0.5f);
            }
            else if (choice.Gain.Type == EventGain.GainType.Money)
            {
                GameManager.Instance.ChangeMoney(choice.Gain.Amount);
            }
            else if (choice.Gain.Type == EventGain.GainType.Score)
            {
                GameManager.Instance.ChangeScore(choice.Gain.Amount);
            }
            break;
        }

        case Action.Lose:
        {
            if (choice.Gain.Type == EventGain.GainType.Upgrade)
            {
                // TODO
            }
            else if (choice.Gain.Type == EventGain.GainType.Floor)
            {
                // TODO
            }
            else if (choice.Gain.Type == EventGain.GainType.Money)
            {
                GameManager.Instance.ChangeMoney(-1 * choice.Gain.Amount);
            }
            else if (choice.Gain.Type == EventGain.GainType.Score)
            {
                GameManager.Instance.ChangeScore(-1 * choice.Gain.Amount);
            }
            break;
        }

        case Action.Advance:
        {
            GameManager.Instance.NextRegion();
            break;
        }

        default:
        {
            break;
        }
        }

        ShowConfirmScreen(choice);

        promisedRewardItem = null;
    }
Ejemplo n.º 23
0
    public EventChoice ConvertToEventChoice()
    {
        EventChoice newChoice = new EventChoice();

        return(newChoice);
    }