public InitialEmotionState(NPC toControl, string currentDialogue)
            : base(toControl, currentDialogue)
        {
            gaveRose = new Reaction();
            gavePendant = new Reaction();
            gaveSeashell = new Reaction();
            randomMessage = new Reaction();

            gaveRose.AddAction(new NPCCallbackAction(SetSeashell));  // DELETE
            gaveRose.AddAction(new NPCCallbackAction(SetPendant)); // DELETE

            gaveRose.AddAction(new NPCTakeItemAction(toControl));
            gaveRose.AddAction(new NPCCallbackAction(SetRose));
            //gaveRose.AddAction(new UpdateDefaultTextAction(toControl, "new default"));
            gaveRose.AddAction(new UpdateCurrentTextAction(toControl, "My bedroom window when I was little had this bed of peach colored roses, they made my room smell wonderful in the summers."));
            _allItemReactions.Add(StringsItem.Apple,  new DispositionDependentReaction(gaveRose)); // change item to rose

            gavePendant.AddAction(new NPCTakeItemAction(toControl));
            gavePendant.AddAction(new NPCCallbackAction(SetPendant));
            gavePendant.AddAction(new UpdateCurrentTextAction(toControl, "I know this seems just like a silly necklace but your father worked for weeks when we were young to buy this for me. It still makes me smile."));
            _allItemReactions.Add("pendant",  new DispositionDependentReaction(gaveRose));

            gaveSeashell.AddAction(new NPCTakeItemAction(toControl));
            gaveSeashell.AddAction(new NPCCallbackAction(SetSeashell));
            gaveSeashell.AddAction(new UpdateCurrentTextAction(toControl, "Your father and I would spend afternoons looking for shells. He loved to find the shiniest ones he could for me."));
            _allItemReactions.Add("seashell",  new DispositionDependentReaction(gaveRose));

            randomMessage.AddAction(new NPCCallbackAction(RandomMessage));

            SetOnOpenInteractionReaction(new DispositionDependentReaction(randomMessage));

            TempFarmerReturnReaction.AddAction(new UpdateCurrentTextAction(toControl, "Blah"));
            TempFarmerReturnReaction.AddAction(new NPCCallbackAction(TempResponse));
            _allChoiceReactions.Add(TempFarmerReturnChoice,new DispositionDependentReaction(TempFarmerReturnReaction));
        }
Esempio n. 2
0
        public static ColorSlider Saturation(VisualDirection direction, float knobWidth, float minVisualLength, 
			Color color, Reaction<float> changed)
        {
            return new ColorSlider (direction, knobWidth, minVisualLength, 0f, 1f, color.GetSaturation (),
                new [] { Color.White, VisualHelpers.ColorFromHSB (color.GetHue (), 1f, color.GetBrightness ()) },
                changed);
        }
Esempio n. 3
0
 public void Register(Reaction newReaction)
 {
     if (!triggeredReactions.Contains(newReaction))
     {
         triggeredReactions.Add(newReaction);
     }
 }
Esempio n. 4
0
    protected override void SetFlagReactions()
    {
        #region Fishing rod stolen
        fishingRodStolenReaction.AddAction(new NPCEmotionUpdateAction(this, new InitialEmotionState(this, "Don't forget to bring my fishing rod back.")));
        fishingRodStolenReaction.AddAction(new ShowOneOffChatAction(this, "Make sure to bring that back in one piece", 2f));
        flagReactions.Add(FlagStrings.StolenFishingRod, fishingRodStolenReaction);
        #endregion

        treasureHuntBeginsReaction.AddAction(new NPCAddScheduleAction(this, treasureHuntSched));
        treasureHuntBeginsReaction.AddAction(new NPCEmotionUpdateAction(this, new InitialEmotionState(this, "Alas! All has been for naught. Well, I guess I shall leave with haste as soon as I can go!")));
        flagReactions.Add(FlagStrings.TreasureHuntBegin, treasureHuntBeginsReaction);

        talkToFortuenTellerFirstReaction.AddAction(new NPCAddScheduleAction(this, returnToDockSchedOne));
        talkToFortuenTellerFirstReaction.AddAction(new NPCAddScheduleAction(this, talkToFortuneTellerFirstSched));
        AddTimeReaction(1000, talkToFortuenTellerFirstReaction);

        talkToFortuenTellerSecondReaction.AddAction(new NPCAddScheduleAction(this, returnToDockSchedTwo));
        talkToFortuenTellerSecondReaction.AddAction(new NPCAddScheduleAction(this, talkToFortuneTellerSecondSched));
        AddTimeReaction(1500, talkToFortuenTellerSecondReaction);

        Reaction rebuildShip = new Reaction();
        rebuildShip.AddAction(new NPCAddScheduleAction(this, TalktoCarpenterSon));
        rebuildShip.AddAction(new NPCAddScheduleAction(this, AfterTalkToCarpenterSon));
        flagReactions.Add(FlagStrings.StartConversationWithSeaCaptainAboutBuildingShip, rebuildShip);
    }
Esempio n. 5
0
 public NumericEdit(float value, bool isInteger, float increment, Reaction<float> changed)
 {
     IsInteger = isInteger;
     Value = isInteger ? value.Round () : value;
     Increment = isInteger ? increment.Round () : increment;
     Changed = changed;
 }
Esempio n. 6
0
    protected override void SetFlagReactions()
    {
        Reaction neutralTowardsPlayer = new Reaction();
        neutralTowardsPlayer.AddAction(new NPCEmotionUpdateAction(this, new NeturalTowardsPlayer(this, "Hi, it has been a long time since we last talked.")));
        neutralTowardsPlayer.AddAction(new NPCCallbackAction(MoveToOriginalLoc));
        neutralTowardsPlayer.AddAction(new NPCCallbackAction(UpdateMoodToNeutral));
        flagReactions.Add(FlagStrings.MusicianFriendsWithPlayer, neutralTowardsPlayer);

        Reaction becomesHappyBecauseSonNotCrazy = new Reaction();
        becomesHappyBecauseSonNotCrazy.AddAction(new NPCEmotionUpdateAction(this,
            new DispleasedWithSon(this, "I am very disapointed by my son's actions, would you be a dear and make sure he stays out of trouble?")));
        flagReactions.Add(FlagStrings.CSONAndCastleFriends, becomesHappyBecauseSonNotCrazy);
        flagReactions.Add(FlagStrings.PlayerAndCastleFriends, becomesHappyBecauseSonNotCrazy);
        flagReactions.Add(FlagStrings.BeachAfterConvoGood, becomesHappyBecauseSonNotCrazy);

        Reaction runAwayFromPlayer = new Reaction();
        runAwayFromPlayer.AddAction(new NPCAddScheduleAction(this, runAway));
        flagReactions.Add("Scared By Player", runAwayFromPlayer);

        Reaction makePlayerGoAway = new Reaction();
        ShowMultipartChatAction multiChat = new ShowMultipartChatAction(this);
        multiChat.AddChat("Leave me alone.", 0.2f);
        multiChat.AddChat("Don't you have any friends? Go Away.", 0.5f);
        makePlayerGoAway.AddAction(multiChat);
        flagReactions.Add(FlagStrings.MusicianYellAtPlayer, makePlayerGoAway);
    }
Esempio n. 7
0
        public ListView(Reaction<IVisualizable> itemClicked, 
			IEnumerable<IVisualizable> items)
        {
            Items = items;
            ItemClicked = itemClicked;
            _mouseRegions = new MouseRegions<IVisualizable> ();
        }
Esempio n. 8
0
        public static ColorSlider Hue(VisualDirection direction, float knobWidth, float minVisualLength, 
			Color color, Reaction<float> changed)
        {
            return new ColorSlider (direction, knobWidth, minVisualLength, 0f, 1f, color.GetHue (),
                new [] {
                    Color.Red, Color.Orange, Color.Yellow, Color.Green, Color.Blue, Color.Indigo,
                    Color.Violet, Color.Red
                }, changed);
        }
Esempio n. 9
0
 /// <summary>
 /// timeToReact must be within 0800 - 2000
 /// </summary>
 public void AddTimeReaction(int timeToReact, Reaction reaction)
 {
     if (timeToReact > 800 && timeToReact < 2000) {
         timeReactions.Add(TruncateTime(timeToReact), reaction);
         TimeReactionManager.instance.Add(this);
     } else {
         Debug.LogWarning("TimeToReact must be within 0800 - 2000");
     }
 }
Esempio n. 10
0
        public InitialEmotionState(NPC toControl, string currentDialogue)
            : base(toControl, currentDialogue)
        {
            gaveRose = new Reaction();
            gavePendant = new Reaction();

            gaveRose.AddAction(new UpdateCurrentTextAction(toControl, "My bedroom window when I was little had this bed of peach colored roses, they made my room smell wonderful in the summers."));
            _allItemReactions.Add("apple",  new DispositionDependentReaction(gaveRose)); // change item to rose
        }
Esempio n. 11
0
    protected override void SetFlagReactions()
    {
        Reaction NewDialogueReaction = new Reaction();
        NewDialogueReaction.AddAction (new NPCCallbackAction(UpdateConversation));
        flagReactions.Add(FlagStrings.ConversationInMiddleFather, NewDialogueReaction);

        Reaction FarmerBecomesLazy = new Reaction();
        FarmerBecomesLazy.AddAction(new NPCAddScheduleAction(this, beALazyFarmer));
        flagReactions.Add(FlagStrings.FarmAfterDialogue, FarmerBecomesLazy);
    }
Esempio n. 12
0
        public Slider(VisualDirection direction, float knobWidth, float minVisualLength, 
			float minValue, float maxValue, float value, Reaction<float> changed)
        {
            Direction = direction;
            KnobWidth = knobWidth;
            MinVisualLength = minVisualLength;
            MinValue = minValue;
            Range = maxValue - minValue;
            Value = value;
            Changed = changed;
        }
Esempio n. 13
0
    public void Apply(GameManager man, Reaction react)
    {
		int randomNumber = UnityEngine.Random.Range (0, 101);
		if (react != null && reactions.ContainsKey (react) && randomNumber <= reactions [react]) {
			actionTrue (man);
            react = null;
			return;
		}
        actionFalse(man);
        react = null;
    }
Esempio n. 14
0
    protected override void SetFlagReactions()
    {
        Reaction castleMarriage = new Reaction();
        castleMarriage.AddAction(new NPCCallbackSetStringAction(MoveForMarriage, this, "castle"));
        //flagReactions.Add(FlagStrings.CastleMarriage, castleMarriage);
        flagReactions.Add(FlagStrings.MarryingCarpenter, castleMarriage);

        Reaction carpenterMarriage = new Reaction();
        carpenterMarriage.AddAction(new NPCCallbackSetStringAction(MoveForMarriage, this, "carpenter"));
        flagReactions.Add(FlagStrings.CastleMarriage, carpenterMarriage);
    }
    protected override void SetFlagReactions()
    {
        Reaction gaveItems = new Reaction();
        //gaveItems.AddAction(new UpdateCurrentTextAction(this, "Unlocked new secret love story!!"));
        //flagReactions.Add(FlagStrings.GiveItems, gaveItems);

        Reaction motherYoungSeeds = new Reaction();
        motherYoungSeeds.AddAction(new UpdateCurrentTextAction(this, "Unlocked new secret love story!!"));
        motherYoungSeeds.AddAction(new NPCCallbackAction(SendText));
        flagReactions.Add(FlagStrings.GiveItems, motherYoungSeeds);
    }
Esempio n. 16
0
    private string className; // For debuging only so you know the current emotion state's name

    #endregion Fields

    #region Constructors

    public EmotionState(NPC npcInState)
    {
        className = this.GetType().FullName;
        _npcInState = npcInState;
        _defaultTextToSay = null;
        _allChoiceReactions = new Dictionary<Choice, DispositionDependentReaction>();
        _allItemReactions = new Dictionary<string, DispositionDependentReaction>();
        Reaction defaultItemReact = new Reaction();
        defaultItemReact.AddAction(new UpdateCurrentTextAction(npcInState, "No thank you."));
        defaultItemReaction = new DispositionDependentReaction(defaultItemReact);
        interactionOpeningReaction = null;
    }
Esempio n. 17
0
        public ColorMapEdit(float domainMin, float domainMax, float knobWidth, float minVisualLength,
			ColorMap<Vec3> colorMap, Reaction<ColorMap<Vec3>> changed)
            : base(VisualDirection.Horizontal, HAlign.Left, VAlign.Top, false, false, 
				Enumerable.Empty<Control> ())
        {
            _bar = new ColorMapBar (domainMin, domainMax, knobWidth, minVisualLength, colorMap, changed,
                React.By<int?> (ItemSelected));
            _picker = new ColorPicker (VisualDirection.Vertical, knobWidth, minVisualLength - (3f * knobWidth),
                Color.Black, true, React.By<Color> (ColorChanged));
            Controls.AddRange (EnumerableExt.Enumerate<Control> (_bar, _picker)
                .Select (c => new Tuple<Control, Reaction<Control>> (c, null)));
        }
Esempio n. 18
0
    protected override void SetFlagReactions()
    {
        /*Reaction enterHappy = new Reaction();
        enterHappy.AddAction(new ShowOneOffChatAction(this, "I think there's a good spot over here!"));
        enterHappy.AddAction(new NPCAddScheduleAction(this, moveMotherHappyState));
        flagReactions.Add (FlagStrings.EnterHappyState, enterHappy);*/

        /*Reaction moveHome = new Reaction();
        moveHome.AddAction(new ShowOneOffChatAction(this, "Let's go back to the house.", 3f));
        moveHome.AddAction(new NPCAddScheduleAction(this, moveHomeSchedule));
        flagReactions.Add (FlagStrings.MoveHome, moveHome);
        */
        //Add states for apple
        Reaction gaveApple = new Reaction();
        gaveApple.AddAction(new NPCAddScheduleAction(this, gaveAppleSchedule));
        flagReactions.Add(FlagStrings.GaveAppleToMother, gaveApple);
        /*
        Reaction giveSeeds = new Reaction();
        giveSeeds.AddAction(new ShowOneOffChatAction(this, "Here are the leftover seeds.",4f));
        giveSeeds.AddAction(new NPCAddScheduleAction(this, giveSeedsSchedule));
        giveSeeds.AddAction(new NPCEmotionUpdateAction(this, new AskToGardenState(this, "You're such a great help! Do you have more time to help me?")));
        flagReactions.Add (FlagStrings.GiveSeeds, giveSeeds);
        */
        Reaction postRace = new Reaction();
        postRace.AddAction(new ShowOneOffChatAction(this, "Get over here you two!!"));
        postRace.AddAction(new NPCAddScheduleAction(this, postRaceSchedule));
        //postRace.AddAction(new NPCEmotionUpdateAction(this, new DummyState(this)));
        flagReactions.Add (FlagStrings.PostSiblingExplore, postRace);

        Reaction enterMadMother = new Reaction();
        enterMadMother.AddAction(new ShowOneOffChatAction(this, "I can't believe you.", 2f));
        enterMadMother.AddAction(new NPCAddScheduleAction(this, enterMadSchedule));
        flagReactions.Add (FlagStrings.EnterMadState, enterMadMother);

        Reaction exitMadMother = new Reaction();
        exitMadMother.AddAction(new ShowOneOffChatAction(this, "I can't believe you.", 2f));
        exitMadMother.AddAction(new NPCAddScheduleAction(this, exitMadSchedule));
        flagReactions.Add (FlagStrings.ExitMadState, exitMadMother);

        Reaction moveToMusicianReaction = new Reaction();
        moveToMusicianReaction.AddAction(new ShowOneOffChatAction(this, "Finished! Now why don't we take it up to our new neighbors on the cliff!"));
        moveToMusicianReaction.AddAction(new NPCGiveItemAction(this, StringsItem.ApplePie));
        moveToMusicianReaction.AddAction(new NPCGiveItemAction(this, StringsItem.Apple));
        NPCConvoSchedule momToMusician = new NPCConvoSchedule(this, NPCManager.instance.getNPC(StringsNPC.MusicianYoung), new MotherToMusicianYoung(),Schedule.priorityEnum.DoNow);
        momToMusician.SetCanNotInteractWithPlayer();
        moveToMusicianReaction.AddAction(new NPCAddScheduleAction(this, moveToMusicianSchedule));

        moveToMusicianReaction.AddAction(new NPCAddScheduleAction(this, momToMusician));
        flagReactions.Add(FlagStrings.MoveToMusician, moveToMusicianReaction);
    }
Esempio n. 19
0
        public ColorMapBar(float domainMin, float domainMax, float knobWidth, float minVisualLength,
			ColorMap<Vec3> colorMap, Reaction<ColorMap<Vec3>> changed, 
			Reaction<int?> itemSelected)
        {
            if (colorMap.Count > 0 && (colorMap.MinKey < domainMin || colorMap.MaxKey > domainMax))
                throw new ArgumentException ("Color map values out of min/max range.");
            DomainMin = domainMin;
            DomainMax = domainMax;
            BarSize = new SizeF (knobWidth, minVisualLength);
            ColorMap = colorMap;
            Changed = changed;
            ItemSelected = itemSelected;
            _mouseRegions = new MouseRegions<object> ();
        }
Esempio n. 20
0
    void Start()
    {
        motionOrders = motionOrderObjects.motionOrders;

        actionDemoManager = GameObject.FindObjectOfType<ActionDemoManager> ();
        actionManager = GameObject.FindObjectOfType<ActionManager> ();
        reaction = GameObject.FindObjectOfType <Reaction>();
        timeManager = GameObject.FindObjectOfType <TimeGaugeManager> ();

        GameObject musicPlayer = GameObject.FindObjectOfType<StageDirector> ().GetMusicPlayer ();
        music = musicPlayer.transform.FindChild ("Main").GetComponent<AudioSource>();
        actionCheck = false;

        resultLoaded = false;

        GameManager.Instance.ResetScore ();
    }
Esempio n. 21
0
        //Constructor
        public Chemistry(Matter.ElementType[] typeArray, Reaction[] reactArray)
        {
            this._typeArray = typeArray;
            this._reactionArray = reactArray;

            //Link Reactions to appropriate types
            for (int i = 0; i < this._typeArray.Length; i++)
            {
                for (int j = 0; j < this._reactionArray.Length; j++)
                {
                    if (this._typeArray[i].MyName == this._reactionArray[j].Reactant.MyName ||
                        (this._reactionArray[j].IsReversible && this._typeArray[i].MyName == this._reactionArray[j].Product.MyName))
                        this._typeArray[i].AddReaction(this._reactionArray[j]);

                }
            }
        }
Esempio n. 22
0
    protected override void SetFlagReactions()
    {
        conversationWithSonDone = new Reaction();
        conversationWithSonDone.AddAction(new NPCAddScheduleAction(this, WalkSitWhittle));
        conversationWithSonDone.AddAction(new NPCEmotionUpdateAction(this, new ToolboxNotFoundEmotionState(this, "Sorry, my son is busy today.  Hopefully he won't spend the whole day searching for his tools and can practice some carpentry.")));

        flagReactions.Add(FlagStrings.carpenterSonYoungConvoWithDadFinished, conversationWithSonDone);

        /*toolboxGotten = new Reaction();
        toolboxGotten.AddAction(new NPCCallbackAction(PlayerHoldingToolbox));
        toolboxGotten.AddAction(new NPCEmotionUpdateAction(this, new ToolboxFoundEmotionState(this, "Oh? You found my son's toolbox. Go along and give it to him so he can get started.")));
        flagReactions.Add(FlagStrings.ToolboxFoundButNotGiven, toolboxGotten);*/

        toolboxGivenToSonDone = new Reaction();
        toolboxGivenToSonDone.AddAction(new NPCEmotionUpdateAction(this, new ToolboxGivenToSonEmotionState(this, "Thanks for finding my son his toolbox... again.")));
        flagReactions.Add(FlagStrings.carpenterSonYoungGottenTools, toolboxGivenToSonDone);
    }
Esempio n. 23
0
    protected override void SetFlagReactions()
    {
        Reaction NewDialogueReaction = new Reaction();
        NewDialogueReaction.AddAction (new NPCCallbackAction(UpdateConversationInMiddleFarmerMother));
        flagReactions.Add(FlagStrings.ConversationInMiddleFarmerMother, NewDialogueReaction);

        Reaction TellOnReaction = new Reaction();
        TellOnReaction.AddAction (new NPCCallbackAction(UpdateTellOnLighthouse));
        flagReactions.Add(FlagStrings.TellOnLighthouse, TellOnReaction);

        Reaction OpeningConversation = new Reaction();
        OpeningConversation.AddAction(new NPCAddScheduleAction(this, InitialConversation));
        flagReactions.Add(FlagStrings.OpeningConversationFarmerMotherToFarmerFather, OpeningConversation);

        Reaction StartHoeing = new Reaction();
        StartHoeing.AddAction(new NPCAddScheduleAction(this, postOpenningSchedule));
        flagReactions.Add(FlagStrings.FarmAfterDialogue, StartHoeing);
    }
Esempio n. 24
0
    /*
     * THE PLAN
     * CASTLEMAN EMOTION STATES
     * 1. CRAZY STATE - also initial emotion state
     * 	says crazy things
     *
     * 2. ANGRY STATE - time for the rage machine
     *  flagReactions.Add(FlagStrings.PostDatingCarpenter, datingThyEnemy);
     *
     * 3. MARRIED STATE - hoo yeeeeaaaahahhahahahah
     *  flagReactions.Add(FlagStrings.CastleMarriage, castleMarriage);
     *
     * 4. SAD STATE - not married full of regret
     * 	(also totally optional depending on the flags)
     *  flagReactions.Add(FlagStrings.StartTalkingToLighthouse, TalkWithLighthouseFirstTime);   OR FlagStrings.FinishedInitialConversationWithCSONFriend
     *
     * 5. RAN OFF STATE - ran off to get married (optional)
     * 	is no where to be found, as is Lighthouse Girl
     * 	flagReactions.Add(FlagStrings.PostCastleDate, gotTheGirl); but NOT flagReactions.Add(FlagStrings.CastleMarriage, castleMarriage);
     *
    */
    protected override void SetFlagReactions()
    {
        Reaction castleMarriage = new Reaction();
        castleMarriage.AddAction(new NPCCallbackSetStringAction(MoveForMarriage, this, "castle"));
        castleMarriage.AddAction(new NPCEmotionUpdateAction(this, new MarriedEmotionState(this, "Today is a good day.")));
        castleMarriage.AddAction(new NPCChangePortraitAction(this, StringsNPC.Happy));
        flagReactions.Add(FlagStrings.CastleMarriage, castleMarriage);

        Reaction castleSad = new Reaction();
        castleSad.AddAction(new NPCEmotionUpdateAction(this, new SadEmotionState(this, "I missed my chance...")));
        castleSad.AddAction(new NPCChangePortraitAction(this, StringsNPC.Sad));
        flagReactions.Add(FlagStrings.StartTalkingToLighthouse, castleSad);
        flagReactions.Add(FlagStrings.FinishedInitialConversationWithCSONFriend, castleSad);

        Reaction castleAngry = new Reaction();
        castleAngry.AddAction(new NPCChangePortraitAction(this, StringsNPC.Angry));
        castleAngry.AddAction(new NPCEmotionUpdateAction(this, new AngryEmotionState(this, "What are YOU doing here?")));
        flagReactions.Add(FlagStrings.PostDatingCarpenter, castleAngry);
    }
Esempio n. 25
0
    protected override void SetFlagReactions()
    {
        Choice MuteResponseChoice = new Choice("Is your son mute?", "Oh no! He's just very shy!");
        Reaction MuteResponseReaction = new Reaction();
        MuteResponseReaction.AddAction(new NPCRemoveChoiceAction(this, MuteResponseChoice));
        MuteResponseReaction.AddAction(new UpdateCurrentTextAction(this, "Oh no! He's just very shy!"));
        Reaction IsHeMuteReaction = new Reaction();
        IsHeMuteReaction.AddAction(new NPCAddChoiceAction(this, MuteResponseChoice, new DispositionDependentReaction(MuteResponseReaction)));
        flagReactions.Add(FlagStrings.MusicianCommentOnSon, IsHeMuteReaction);

        Reaction RespondToCMANAndYouFriends = new Reaction();
        RespondToCMANAndYouFriends.AddAction(new NPCAddScheduleAction(this, FinishedTalkingFriends));
        RespondToCMANAndYouFriends.AddAction(new NPCAddScheduleAction(this, TellSonToGoAroundIslandFriends));
        flagReactions.Add(FlagStrings.PlayerAndCastleFriends, RespondToCMANAndYouFriends);

        Reaction RespondToCMANAndYouNOTFriends = new Reaction();
        RespondToCMANAndYouNOTFriends.AddAction(new NPCAddScheduleAction(this, FinishedTalkingNOTFriends));
        RespondToCMANAndYouNOTFriends.AddAction(new NPCAddScheduleAction(this, TellSonToGoAroundIslandNOTFriends));
        flagReactions.Add(FlagStrings.PlayerAndCastleNOTFriends, RespondToCMANAndYouNOTFriends);
    }
Esempio n. 26
0
    protected override void SetFlagReactions()
    {
        Reaction ReactToCastleMan = new Reaction();
        ReactToCastleMan.AddAction(new NPCAddScheduleAction(this, TalkWithCastleman));
        flagReactions.Add(FlagStrings.PlayerAndCastleFriends , ReactToCastleMan);

        Reaction ReactToCastleManNotFriends = new Reaction();
        ReactToCastleManNotFriends.AddAction(new NPCAddScheduleAction(this, TalkWithCastlemanNotFriend));
        flagReactions.Add(FlagStrings.PlayerAndCastleNOTFriends , ReactToCastleManNotFriends);

        CreatedFishingRod = new Reaction();
        //flagReactions.Add(FlagStrings.carpenterSonMakesFishingRod, CreatedFishingRod);
        //CreatedFishingRod.Add

        Reaction ReactToMeetingCSON = new Reaction();
        //ReactToMeetingCSON.AddAction(new NPCCallbackAction(UpdateReactToMeetingCSON));
        flagReactions.Add(FlagStrings.InitialConversationWithCSONNOTFriend, ReactToMeetingCSON);

        Reaction CarpenterSonCompleteWhittle = new Reaction();
    }
Esempio n. 27
0
    protected override void SetFlagReactions()
    {
        Reaction TellOnLighthouseReaction = new Reaction();
        TellOnLighthouseReaction.AddAction(new ShowOneOffChatAction(this, "Git over here girl.", 2f));
        TellOnLighthouseReaction.AddAction(new NPCAddScheduleAction(this, tellOnLighthouseConversationSchedule));
        flagReactions.Add(FlagStrings.TellOnLighthouseConversation, TellOnLighthouseReaction);

        #region Castle man
        Reaction ReactToCastleMan = new Reaction();
        ReactToCastleMan.AddAction(new NPCAddScheduleAction(this, TalkWithCastleman));
        flagReactions.Add(FlagStrings.PlayerAndCastleFriends , ReactToCastleMan);

        Reaction ReactToCastleManNotFriends = new Reaction();
        ReactToCastleManNotFriends.AddAction(new NPCAddScheduleAction(this, TalkWithCastleman));
        flagReactions.Add(FlagStrings.PlayerAndCastleNOTFriends , ReactToCastleManNotFriends);
        #endregion

        Reaction CounterTellOn = new Reaction();
        CounterTellOn.AddAction(new NPCEmotionUpdateAction(this, new EmptyEmotion(this, "Leave me! My dad said he would get you in trouble if you didn't go!")));
        CounterTellOn.AddAction(new NPCAddScheduleAction(this, AttemptToTellOnLighthouse));
        flagReactions.Add(FlagStrings.CounterTellOn, CounterTellOn);

        Reaction ReadyToGoToBeach = new Reaction();
        ReadyToGoToBeach.AddAction(new NPCAddScheduleAction(this, WalkToBeach));
        ReadyToGoToBeach.AddAction(new NPCAddScheduleAction(this, LighthouseGoingToBeach));
        ReadyToGoToBeach.AddAction(new NPCEmotionUpdateAction(this, new EmptyEmotion(this, "Don't bother me I'm off to build sand castles to protect the island!")));
        flagReactions.Add(FlagStrings.GoDownToBeach, ReadyToGoToBeach);

        Reaction MakingApplePieFromApple = new Reaction();
        MakingApplePieFromApple.AddAction(new NPCAddScheduleAction(this, GaveApple));
        flagReactions.Add(FlagStrings.MakePieFromApple, MakingApplePieFromApple);

        Reaction MakingApplePieFromScratch = new Reaction();
        MakingApplePieFromScratch.AddAction(new NPCEmotionUpdateAction(this, new EmptyEmotion(this, "Leave peasant! I have work to attend to!")));
        MakingApplePieFromScratch.AddAction(new NPCAddScheduleAction(this, GaveNothingSchedule));
        flagReactions.Add(FlagStrings.MakePieFromScratch, MakingApplePieFromScratch);

        Reaction RemoveConvoWithCastleman = new Reaction();
        RemoveConvoWithCastleman.AddAction(new NPCCallbackAction(DoRemoveConvoWithCastleman));
        flagReactions.Add(FlagStrings.StartTalkingToLighthouse, RemoveConvoWithCastleman);
    }
Esempio n. 28
0
        public ColorPicker(VisualDirection direction, float knobWidth, float minVisualLength, Color color,
			bool preview, Reaction<Color> changed)
            : base(preview ? direction : direction.Opposite (), HAlign.Left, VAlign.Top, true, false, 
				Enumerable.Empty<Control> ())
        {
            Changed = changed;
            _hue = ColorSlider.Hue (direction, knobWidth, minVisualLength, color,
                React.By<float> (ChangeHue));
            _saturation = ColorSlider.Saturation (direction, knobWidth, minVisualLength, color,
                React.By<float> (ChangeSaturation));
            _brightness = ColorSlider.Brightness (direction, knobWidth, minVisualLength, color,
                React.By<float> (ChangeBrightness));
            var controls = EnumerableExt.Enumerate<Control> (_hue, _saturation, _brightness);
            var contents = preview ?
                EnumerableExt.Enumerate (
                   new Container (direction, HAlign.Center, VAlign.Center, false, false,
                       new Container (direction.Opposite (), HAlign.Left, VAlign.Top, false, false, controls),
                       Label.ColorPreview (() => _value, new SizeF (3.5f * knobWidth, 3.5f * knobWidth)))) :
                controls;
            Controls.AddRange (contents.Select (c => new Tuple<Control, Reaction<Control>> (c, null)));
        }
Esempio n. 29
0
 public static Reaction <T> Blending <T> (this Reaction <T> render,
                                          BlendingFactorSrc source       = BlendingFactorSrc.SrcAlpha,
                                          BlendingFactorDest destination = BlendingFactorDest.OneMinusSrcAlpha)
 {
     return(render.Blending(i => Tuple.Create(source, destination)));
 }
Esempio n. 30
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as AdverseEvent;

            if (dest == null)
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }

            base.CopyTo(dest);
            if (Identifier != null)
            {
                dest.Identifier = (Hl7.Fhir.Model.Identifier)Identifier.DeepCopy();
            }
            if (CategoryElement != null)
            {
                dest.CategoryElement = (Code <Hl7.Fhir.Model.AdverseEvent.AdverseEventCategory>)CategoryElement.DeepCopy();
            }
            if (Type != null)
            {
                dest.Type = (Hl7.Fhir.Model.CodeableConcept)Type.DeepCopy();
            }
            if (Subject != null)
            {
                dest.Subject = (Hl7.Fhir.Model.ResourceReference)Subject.DeepCopy();
            }
            if (DateElement != null)
            {
                dest.DateElement = (Hl7.Fhir.Model.FhirDateTime)DateElement.DeepCopy();
            }
            if (Reaction != null)
            {
                dest.Reaction = new List <Hl7.Fhir.Model.ResourceReference>(Reaction.DeepCopy());
            }
            if (Location != null)
            {
                dest.Location = (Hl7.Fhir.Model.ResourceReference)Location.DeepCopy();
            }
            if (Seriousness != null)
            {
                dest.Seriousness = (Hl7.Fhir.Model.CodeableConcept)Seriousness.DeepCopy();
            }
            if (Outcome != null)
            {
                dest.Outcome = (Hl7.Fhir.Model.CodeableConcept)Outcome.DeepCopy();
            }
            if (Recorder != null)
            {
                dest.Recorder = (Hl7.Fhir.Model.ResourceReference)Recorder.DeepCopy();
            }
            if (EventParticipant != null)
            {
                dest.EventParticipant = (Hl7.Fhir.Model.ResourceReference)EventParticipant.DeepCopy();
            }
            if (DescriptionElement != null)
            {
                dest.DescriptionElement = (Hl7.Fhir.Model.FhirString)DescriptionElement.DeepCopy();
            }
            if (SuspectEntity != null)
            {
                dest.SuspectEntity = new List <Hl7.Fhir.Model.AdverseEvent.SuspectEntityComponent>(SuspectEntity.DeepCopy());
            }
            if (SubjectMedicalHistory != null)
            {
                dest.SubjectMedicalHistory = new List <Hl7.Fhir.Model.ResourceReference>(SubjectMedicalHistory.DeepCopy());
            }
            if (ReferenceDocument != null)
            {
                dest.ReferenceDocument = new List <Hl7.Fhir.Model.ResourceReference>(ReferenceDocument.DeepCopy());
            }
            if (Study != null)
            {
                dest.Study = new List <Hl7.Fhir.Model.ResourceReference>(Study.DeepCopy());
            }
            return(dest);
        }
Esempio n. 31
0
 public static Reaction <T> Viewport <T> (this Reaction <T> render, GameWindow window)
 {
     return(render.Viewport(i => new Vec2i(window.ClientSize.Width, window.ClientSize.Height)));
 }
        /// <summary>
        /// Creates a new Autorun reaction.
        /// </summary>
        /// <param name="sharedState">The shared state to operate on.</param>
        /// <param name="expression">The expression that should autorun.</param>
        /// <param name="autorunOptions">An <see cref="AutorunOptions"/> instance with options.</param>
        /// <returns>An <see cref="IDisposable"/> instance that can be used to tear down the Autorun reaction.</returns>
        public static IDisposable Autorun(this ISharedState sharedState, Action <Reaction> expression, AutorunOptions autorunOptions = null)
        {
            if (sharedState is null)
            {
                throw new ArgumentNullException(nameof(sharedState));
            }

            if (expression is null)
            {
                throw new ArgumentNullException(nameof(expression));
            }

            if (autorunOptions is null)
            {
                autorunOptions = new AutorunOptions();
            }

            var name = autorunOptions.Name ?? $"Autorun@{sharedState.GetUniqueId()}";

            var runSync = autorunOptions.Scheduler == null && autorunOptions.Delay == 0;

            Reaction reaction = null;

#pragma warning disable CA2000  // Dispose objects before losing scope
#pragma warning disable IDE0067 // Dispose objects before losing scope
            if (runSync)
            {
                // normal autorun
                reaction = new Reaction(
                    sharedState,
                    name,
                    () =>
                {
                    ReactionRunner().GetAwaiter().GetResult();
                }, autorunOptions.ErrorHandler);
            }
            else
            {
                var scheduler = CreateSchedulerFromOptions(autorunOptions, ReactionRunner);

                // debounced autorun
                var isScheduled = false;

                reaction = reaction = new Reaction(
                    sharedState,
                    name,
                    () =>
                {
                    if (!isScheduled)
                    {
                        isScheduled = true;
                        scheduler().GetAwaiter().GetResult();
                    }
                },
                    autorunOptions.ErrorHandler);
            }
#pragma warning restore IDE0067 // Dispose objects before losing scope
#pragma warning restore CA2000  // Dispose objects before losing scope

            Task ReactionRunner()
            {
                if (reaction.IsDisposed)
                {
                    return(Task.CompletedTask);
                }

                reaction.Track(() => expression(reaction));
                return(Task.CompletedTask);
            }

            reaction.Schedule();
            return(new DisposableDelegate(() => reaction.Dispose()));
        }
        /// <summary>
        /// Creates a reaction that operates on data of type T.
        /// </summary>
        /// <typeparam name="T">The type the reaction operates on.</typeparam>
        /// <param name="sharedState">The shared state to use.</param>
        /// <param name="expression">The expression that delivers a value.</param>
        /// <param name="effect">The effect that is executed when the value changes.</param>
        /// <param name="reactionOptions">The options to use for the reaction.</param>
        /// <returns>An <see cref="IDisposable"/> instance that can be used to stop the reaction.</returns>
        public static IDisposable Reaction <T>(this ISharedState sharedState, Func <Reaction, T> expression, Action <T, Reaction> effect, ReactionOptions <T> reactionOptions = null)
        {
            if (sharedState is null)
            {
                throw new ArgumentNullException(nameof(sharedState));
            }

            if (expression is null)
            {
                throw new ArgumentNullException(nameof(expression));
            }

            if (effect is null)
            {
                throw new ArgumentNullException(nameof(effect));
            }

            if (reactionOptions is null)
            {
                reactionOptions = new ReactionOptions <T>();
            }

            var name   = reactionOptions.Name ?? $"Reaction@{sharedState.GetUniqueId()}";
            var action = sharedState.CreateAction(
                name + "effect",
                reactionOptions.Context,
                reactionOptions.ErrorHandler != null ? WrapErrorHandler(reactionOptions.ErrorHandler, effect) : effect);
            var runSync = reactionOptions.Scheduler == null && reactionOptions.Delay == 0;

            var      firstTime   = true;
            var      isScheduled = false;
            T        value       = default;
            Reaction reaction    = null;

            var equals =
                reactionOptions.EqualityComparer != null ?
                new Func <T, T, bool>(reactionOptions.EqualityComparer.Equals) :
                new Func <T, T, bool>((x, y) => Equals(x, y));

            var scheduler = CreateSchedulerFromOptions(reactionOptions, ReactionRunner);

#pragma warning disable CA2000  // Dispose objects before losing scope
#pragma warning disable IDE0067 // Dispose objects before losing scope
            reaction = new Reaction(
                sharedState,
                name,
                () =>
            {
                if (firstTime || runSync)
                {
                    ReactionRunner().GetAwaiter().GetResult();
                }
                else if (!isScheduled)
                {
                    isScheduled = true;
                    scheduler().GetAwaiter().GetResult();
                }
            }, reactionOptions.ErrorHandler);
#pragma warning restore IDE0067 // Dispose objects before losing scope
#pragma warning restore CA2000  // Dispose objects before losing scope

            Task ReactionRunner()
            {
                isScheduled = false; // Q: move into reaction runner?
                if (reaction.IsDisposed)
                {
                    return(Task.CompletedTask);
                }

                var changed = false;

                reaction.Track(() =>
                {
                    var nextValue = expression(reaction);
                    changed       = firstTime || !equals(value, nextValue);
                    value         = nextValue;
                });
                if (firstTime && reactionOptions.FireImmediately)
                {
                    action(value, reaction);
                }

                if (!firstTime && changed)
                {
                    action(value, reaction);
                }

                if (firstTime)
                {
                    firstTime = false;
                }

                return(Task.CompletedTask);
            }

            reaction.Schedule();
            return(new DisposableDelegate(() => reaction.Dispose()));
        }
 public void Update(Reaction reaction)
 {
     _context.Entry(reaction).State = EntityState.Modified;
     _context.SaveChanges();
 }
Esempio n. 35
0
    public static int Main(string[] args)
    {
        if (args.Length != 2)
        {
            Console.Write(Environment.NewLine + "Usage: unsetNotes <input-filename> <output-filename>" + Environment.NewLine + Environment.NewLine);
            return(1);
        }


        int          i, j;
        string       filename = args[0];
        SBMLDocument document;


        document = libsbml.readSBML(filename);


        int errors = (int)document.getNumErrors();

        if (errors > 0)
        {
            document.printErrors();

            return(errors);
        }

        Model m = document.getModel();

        m.unsetNotes();

        for (i = 0; i < m.getNumReactions(); i++)
        {
            Reaction re = m.getReaction(i);
            re.unsetNotes();

            for (j = 0; j < re.getNumReactants(); j++)
            {
                SpeciesReference rt = re.getReactant(j);
                rt.unsetNotes();
            }

            for (j = 0; j < re.getNumProducts(); j++)
            {
                SpeciesReference rt = re.getProduct(j);
                rt.unsetNotes();
            }

            for (j = 0; j < re.getNumModifiers(); j++)
            {
                ModifierSpeciesReference md = re.getModifier(j);
                md.unsetNotes();
            }

            if (re.isSetKineticLaw())
            {
                KineticLaw kl = re.getKineticLaw();
                kl.unsetNotes();

                for (j = 0; j < kl.getNumParameters(); j++)
                {
                    Parameter pa = kl.getParameter(j);
                    pa.unsetNotes();
                }
            }
        }

        for (i = 0; i < m.getNumSpecies(); i++)
        {
            Species sp = m.getSpecies(i);
            sp.unsetNotes();
        }

        for (i = 0; i < m.getNumCompartments(); i++)
        {
            Compartment sp = m.getCompartment(i);
            sp.unsetNotes();
        }

        for (i = 0; i < m.getNumFunctionDefinitions(); i++)
        {
            FunctionDefinition sp = m.getFunctionDefinition(i);
            sp.unsetNotes();
        }

        for (i = 0; i < m.getNumUnitDefinitions(); i++)
        {
            UnitDefinition sp = m.getUnitDefinition(i);
            sp.unsetNotes();
        }

        for (i = 0; i < m.getNumParameters(); i++)
        {
            Parameter sp = m.getParameter(i);
            sp.unsetNotes();
        }

        for (i = 0; i < m.getNumRules(); i++)
        {
            Rule sp = m.getRule(i);
            sp.unsetNotes();
        }

        for (i = 0; i < m.getNumInitialAssignments(); i++)
        {
            InitialAssignment sp = m.getInitialAssignment(i);
            sp.unsetNotes();
        }

        for (i = 0; i < m.getNumEvents(); i++)
        {
            Event sp = m.getEvent(i);
            sp.unsetNotes();

            for (j = 0; j < sp.getNumEventAssignments(); j++)
            {
                EventAssignment ea = sp.getEventAssignment(j);
                ea.unsetNotes();
            }
        }

        for (i = 0; i < m.getNumSpeciesTypes(); i++)
        {
            SpeciesType sp = m.getSpeciesType(i);
            sp.unsetNotes();
        }

        for (i = 0; i < m.getNumConstraints(); i++)
        {
            Constraint sp = m.getConstraint(i);
            sp.unsetNotes();
        }

        libsbml.writeSBML(document, args[1]);

        return(errors);
    }
Esempio n. 36
0
        private static int Main(string[] args)
        {
            var retval = 0;
            var sbmlns = new SBMLNamespaces(3, 1, "comp", 1);

            // create the document
            var document = new SBMLDocument(sbmlns);

            //Create our submodel
            var compdoc = (CompSBMLDocumentPlugin)(document.getPlugin("comp"));

            compdoc.setRequired(true);
            var mod1 = compdoc.createModelDefinition();

            mod1.setId("enzyme");
            mod1.setName("enzyme");
            var comp = mod1.createCompartment();

            comp.setSpatialDimensions(3);
            comp.setConstant(true);
            comp.setId("comp");
            comp.setSize(1L);
            var spec = new Species(3, 1);

            spec.setCompartment("comp");
            spec.setHasOnlySubstanceUnits(false);
            spec.setConstant(false);
            spec.setBoundaryCondition(false);
            spec.setId("S");
            mod1.addSpecies(spec);
            spec.setId("E");
            mod1.addSpecies(spec);
            spec.setId("D");
            mod1.addSpecies(spec);
            spec.setId("ES");
            mod1.addSpecies(spec);
            var rxn = new Reaction(3, 1);

            rxn.setReversible(true);
            rxn.setFast(false);
            var rxn2 = new Reaction(rxn);

            rxn.setId("J0");
            rxn2.setId("J1");
            var sr = new SpeciesReference(3, 1);

            sr.setConstant(true);
            sr.setStoichiometry(1);
            sr.setSpecies("S");
            rxn.addReactant(sr);
            sr.setSpecies("E");
            rxn.addReactant(sr);
            rxn2.addProduct(sr);
            sr.setSpecies("ES");
            rxn.addProduct(sr);
            rxn2.addReactant(sr);
            sr.setSpecies("D");
            rxn2.addProduct(sr);

            mod1.addReaction(rxn);
            mod1.addReaction(rxn2);

            // create the Model
            var model = document.createModel();

            model.setId("aggregate");

            // Create a submodel
            var mplugin = (CompModelPlugin)(model.getPlugin("comp"));
            var submod1 = mplugin.createSubmodel();

            submod1.setId("submod1");
            submod1.setModelRef("enzyme");

            var submod2 = new Submodel();

            submod2.setId("submod2");
            submod2.setModelRef("enzyme");
            mplugin.addSubmodel(submod2);

            libsbml.writeSBMLToFile(document, "enzyme_model.xml");
            document = libsbml.readSBMLFromFile("enzyme_model.xml");
            if (document == null)
            {
                Console.WriteLine("Error reading back in file.");
                retval = -1;
            }
            else
            {
                document.setConsistencyChecks(libsbml.LIBSBML_CAT_UNITS_CONSISTENCY, false);
                document.checkConsistency();
                if (document.getErrorLog().getNumFailsWithSeverity(2) > 0 ||
                    document.getErrorLog().getNumFailsWithSeverity(3) > 0)
                {
                    var stream = new OStringStream();
                    document.printErrors(stream);
                    Console.WriteLine("Errors encoutered when round-tripping  SBML file: \n" +
                                      stream.str());
                    retval = -1;
                }
                libsbml.writeSBMLToFile(document, "enzyme_model_rt.xml");
            }
            return(retval);
        }
Esempio n. 37
0
    static void Main(string[] args)
    {
        SBMLNamespaces sbmlns   = new SBMLNamespaces(3, 1, "fbc", 1);
        SBMLDocument   document = new SBMLDocument(sbmlns);

        // create the Model

        Model model = document.createModel();

        // create the Compartment

        Compartment compartment = model.createCompartment();

        compartment.setId("compartment");
        compartment.setConstant(true);
        compartment.setSize(1);

        // create the Species

        Species species = model.createSpecies();

        species.setId("Node1");
        species.setCompartment("compartment");
        species.setConstant(false);
        species.setHasOnlySubstanceUnits(false);
        species.setBoundaryCondition(false);

        species = model.createSpecies();
        species.setId("Node2");
        species.setCompartment("compartment");
        species.setConstant(false);
        species.setHasOnlySubstanceUnits(false);
        species.setConstant(false);
        species.setHasOnlySubstanceUnits(false);
        species.setBoundaryCondition(false);

        species = model.createSpecies();
        species.setId("Node3");
        species.setCompartment("compartment");
        species.setConstant(false);
        species.setHasOnlySubstanceUnits(false);
        species.setBoundaryCondition(false);

        species = model.createSpecies();
        species.setId("Node4");
        species.setCompartment("compartment");
        species.setConstant(false);
        species.setHasOnlySubstanceUnits(false);
        species.setBoundaryCondition(false);

        species = model.createSpecies();
        species.setId("Node5");
        species.setCompartment("compartment");
        species.setConstant(false);
        species.setHasOnlySubstanceUnits(false);
        species.setBoundaryCondition(false);

        species = model.createSpecies();
        species.setId("Node6");
        species.setCompartment("compartment");
        species.setConstant(false);
        species.setHasOnlySubstanceUnits(false);
        species.setBoundaryCondition(false);

        species = model.createSpecies();
        species.setId("Node7");
        species.setCompartment("compartment");
        species.setConstant(false);
        species.setHasOnlySubstanceUnits(false);
        species.setBoundaryCondition(false);

        species = model.createSpecies();
        species.setId("Node8");
        species.setCompartment("compartment");
        species.setConstant(false);
        species.setHasOnlySubstanceUnits(false);
        species.setBoundaryCondition(false);

        species = model.createSpecies();
        species.setId("Node0");
        species.setCompartment("compartment");
        species.setConstant(false);
        species.setHasOnlySubstanceUnits(false);
        species.setBoundaryCondition(true);

        species = model.createSpecies();
        species.setId("Node9");
        species.setCompartment("compartment");
        species.setConstant(false);
        species.setHasOnlySubstanceUnits(false);
        species.setBoundaryCondition(true);

        Reaction reaction = model.createReaction();

        reaction.setId("J0");
        reaction.setReversible(false);
        reaction.setFast(false);
        SpeciesReference reactant = reaction.createReactant();

        reactant.setSpecies("Node0");
        reactant.setStoichiometry(1);
        reactant.setConstant(true);
        SpeciesReference product = reaction.createProduct();

        product.setSpecies("Node1");
        product.setStoichiometry(1);
        product.setConstant(true);

        reaction = model.createReaction();
        reaction.setId("J1");
        reaction.setReversible(false);
        reaction.setFast(false);
        reactant = reaction.createReactant();
        reactant.setSpecies("Node1");
        reactant.setStoichiometry(1);
        reactant.setConstant(true);
        product = reaction.createProduct();
        product.setSpecies("Node2");
        product.setStoichiometry(1);
        product.setConstant(true);

        reaction = model.createReaction();
        reaction.setId("J2");
        reaction.setReversible(false);
        reaction.setFast(false);
        reactant = reaction.createReactant();
        reactant.setSpecies("Node2");
        reactant.setStoichiometry(1);
        reactant.setConstant(true);
        product = reaction.createProduct();
        product.setSpecies("Node3");
        product.setStoichiometry(1);
        product.setConstant(true);

        reaction = model.createReaction();
        reaction.setId("J3");
        reaction.setReversible(false);
        reaction.setFast(false);
        reactant = reaction.createReactant();
        reactant.setSpecies("Node1");
        reactant.setStoichiometry(1);
        reactant.setConstant(true);
        product = reaction.createProduct();
        product.setSpecies("Node4");
        product.setStoichiometry(1);
        product.setConstant(true);

        reaction = model.createReaction();
        reaction.setId("J4");
        reaction.setReversible(false);
        reaction.setFast(false);
        reactant = reaction.createReactant();
        reactant.setSpecies("Node4");
        reactant.setStoichiometry(1);
        reactant.setConstant(true);
        product = reaction.createProduct();
        product.setSpecies("Node3");
        product.setStoichiometry(1);
        product.setConstant(true);

        reaction = model.createReaction();
        reaction.setId("J5");
        reaction.setReversible(false);
        reaction.setFast(false);
        reactant = reaction.createReactant();
        reactant.setSpecies("Node3");
        reactant.setStoichiometry(1);
        reactant.setConstant(true);
        product = reaction.createProduct();
        product.setSpecies("Node5");
        product.setStoichiometry(1);
        product.setConstant(true);

        reaction = model.createReaction();
        reaction.setId("J6");
        reaction.setReversible(false);
        reaction.setFast(false);
        reactant = reaction.createReactant();
        reactant.setSpecies("Node5");
        reactant.setStoichiometry(1);
        reactant.setConstant(true);
        product = reaction.createProduct();
        product.setSpecies("Node6");
        product.setStoichiometry(1);
        product.setConstant(true);

        reaction = model.createReaction();
        reaction.setId("J7");
        reaction.setReversible(false);
        reaction.setFast(false);
        reactant = reaction.createReactant();
        reactant.setSpecies("Node6");
        reactant.setStoichiometry(1);
        reactant.setConstant(true);
        product = reaction.createProduct();
        product.setSpecies("Node7");
        product.setStoichiometry(1);
        product.setConstant(true);

        reaction = model.createReaction();
        reaction.setId("J8");
        reaction.setReversible(false);
        reaction.setFast(false);
        reactant = reaction.createReactant();
        reactant.setSpecies("Node5");
        reactant.setStoichiometry(1);
        reactant.setConstant(true);
        product = reaction.createProduct();
        product.setSpecies("Node8");
        product.setStoichiometry(1);
        product.setConstant(true);

        reaction = model.createReaction();
        reaction.setId("J9");
        reaction.setReversible(false);
        reaction.setFast(false);
        reactant = reaction.createReactant();
        reactant.setSpecies("Node8");
        reactant.setStoichiometry(1);
        reactant.setConstant(true);
        product = reaction.createProduct();
        product.setSpecies("Node7");
        product.setStoichiometry(1);
        product.setConstant(true);

        reaction = model.createReaction();
        reaction.setId("J10");
        reaction.setReversible(false);
        reaction.setFast(false);
        reactant = reaction.createReactant();
        reactant.setSpecies("Node7");
        reactant.setStoichiometry(1);
        reactant.setConstant(true);
        product = reaction.createProduct();
        product.setSpecies("Node9");
        product.setStoichiometry(1);
        product.setConstant(true);


        //
        // Get a FbcModelPlugin object plugged in the model object.
        //
        // The type of the returned value of SBase::getPlugin() function is SBasePlugin, and
        // thus the value needs to be casted for the corresponding derived class.
        //
        FbcModelPlugin mplugin = (FbcModelPlugin)(model.getPlugin("fbc"));

        FluxBound bound = mplugin.createFluxBound();

        bound.setId("bound1");
        bound.setReaction("J0");
        bound.setOperation("equal");
        bound.setValue(10);

        Objective objective = mplugin.createObjective();

        objective.setId("obj1");
        objective.setType("maximize");

        // mark obj1 as active objective
        mplugin.setActiveObjectiveId("obj1");

        FluxObjective fluxObjective = objective.createFluxObjective();

        fluxObjective.setReaction("J8");
        fluxObjective.setCoefficient(1);

        libsbml.writeSBMLToFile(document, "fbc_example1.xml");
    }
Esempio n. 38
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="reaction"></param>
 /// <returns></returns>
 public abstract void React(Reaction reaction);
Esempio n. 39
0
 private void DoReactions()
 {
     Reaction.React(_mixture);
 }
Esempio n. 40
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="reaction"></param>
 /// <returns></returns>
 public abstract EnvironmentState ReactAndCollectState(Reaction reaction);
Esempio n. 41
0
 public void addRemoveReaction(Reaction r)
 {
     remove_reaction += r;
 }
Esempio n. 42
0
 public static Reaction <T> BindSamplers <T> (this Reaction <T> render, IDictionary <Sampler, Texture> bindings)
 {
     return(render.BindSamplers(i => bindings));
 }
 public void tearDown()
 {
     R = null;
 }
Esempio n. 44
0
        private static int Main(string[] args)
        {
            var retval = 0;
            var sbmlns = new SBMLNamespaces(3, 1, "comp", 1);

            // create the document
            var document = new SBMLDocument(sbmlns);

            //Define the external model definition
            var compdoc = (CompSBMLDocumentPlugin)(document.getPlugin("comp"));

            compdoc.setRequired(true);
            var extmod = compdoc.createExternalModelDefinition();

            extmod.setId("ExtMod1");
            extmod.setSource("enzyme_model.xml");
            extmod.setModelRef("enzyme");

            //Define the 'simple' model
            var mod1 = compdoc.createModelDefinition();

            mod1.setId("simple");
            var comp = mod1.createCompartment();

            comp.setSpatialDimensions(3);
            comp.setConstant(true);
            comp.setId("comp");
            comp.setSize(1L);

            var spec = new Species(sbmlns);

            //We have to construct it this way because we get the comp plugin from it later.
            spec.setCompartment("comp");
            spec.setHasOnlySubstanceUnits(false);
            spec.setConstant(false);
            spec.setBoundaryCondition(false);
            spec.setId("S");
            spec.setInitialConcentration(5);
            mod1.addSpecies(spec);
            spec.setId("D");
            spec.setInitialConcentration(10);
            mod1.addSpecies(spec);

            var rxn = new Reaction(3, 1);

            rxn.setReversible(true);
            rxn.setFast(false);
            rxn.setId("J0");

            var sr = new SpeciesReference(3, 1);

            sr.setConstant(true);
            sr.setStoichiometry(1);
            sr.setSpecies("S");
            rxn.addReactant(sr);
            sr.setSpecies("D");
            rxn.addProduct(sr);

            mod1.addReaction(rxn);

            var mod1plug = (CompModelPlugin)(mod1.getPlugin("comp"));
            var port     = new Port();

            port.setId("S_port");
            port.setIdRef("S");
            mod1plug.addPort(port);

            var port2 = mod1plug.createPort();

            port2.setId("D_port");
            port2.setIdRef("D");

            port.setId("comp_port");
            port.setIdRef("comp");
            mod1plug.addPort(port);

            port.setId("J0_port");
            port.setIdRef("J0");
            mod1plug.addPort(port);

            // create the Model
            var model = document.createModel();

            model.setId("complexified");

            // Set the submodels
            var mplugin = (CompModelPlugin)(model.getPlugin("comp"));
            var submod1 = mplugin.createSubmodel();

            submod1.setId("A");
            submod1.setModelRef("ExtMod1");
            var submod2 = mplugin.createSubmodel();

            submod2.setId("B");
            submod2.setModelRef("simple");
            var del = submod2.createDeletion();

            del.setPortRef("J0_port");

            // Synchronize the compartments
            var mcomp = model.createCompartment();

            mcomp.setSpatialDimensions(3);
            mcomp.setConstant(true);
            mcomp.setId("comp");
            mcomp.setSize(1L);
            var compartplug = (CompSBasePlugin)(mcomp.getPlugin("comp"));
            var re          = new ReplacedElement();

            re.setIdRef("comp");
            re.setSubmodelRef("A");
            compartplug.addReplacedElement(re);
            re.setSubmodelRef("B");
            re.unsetIdRef();
            re.setPortRef("comp_port");
            compartplug.addReplacedElement(re);

            //Synchronize the species
            spec.setId("S");
            spec.setInitialConcentration(5);
            var specplug = (CompSBasePlugin)(spec.getPlugin("comp"));
            var sre      = specplug.createReplacedElement();

            sre.setSubmodelRef("A");
            sre.setIdRef("S");
            var sre2 = specplug.createReplacedElement();

            sre2.setSubmodelRef("B");
            sre2.setPortRef("S_port");
            model.addSpecies(spec);

            spec.setId("D");
            spec.setInitialConcentration(10);
            sre.setIdRef("D");
            sre2.setPortRef("D_port");
            model.addSpecies(spec);

            libsbml.writeSBMLToFile(document, "spec_example3.xml");
            document = libsbml.readSBMLFromFile("spec_example3.xml");
            if (document == null)
            {
                Console.WriteLine("Error reading back in file.");

                retval = -1;
            }
            else
            {
                document.setConsistencyChecks(libsbml.LIBSBML_CAT_UNITS_CONSISTENCY, false);
                document.checkConsistency();
                if (document.getErrorLog().getNumFailsWithSeverity(2) > 0 ||
                    document.getErrorLog().getNumFailsWithSeverity(3) > 0)
                {
                    var stream = new OStringStream();
                    document.printErrors(stream);
                    Console.WriteLine("Errors encoutered when round-tripping  SBML file: \n" +
                                      stream.str());
                    retval = -1;
                }
                libsbml.writeSBMLToFile(document, "spec_example3_rt.xml");
            }
            return(retval);
        }
Esempio n. 45
0
        /// <summary>
        /// Creates an reaction that observes and runs the given predicate function
        /// until it returns true. Once that happens, the returned task is completed
        /// and the reaction is deactivated.<br/>
        /// <br/>
        /// The task will fail if the predicate throws an exception.
        /// </summary>
        /// <param name="p">An observed predicate function.</param>
        /// <param name="cancellationToken">Token for reaction cancellation.</param>
        /// <param name="debugName">Debug name for this reaction.</param>
        /// <returns>Task that completes when the predicate returns true or predicate function throws exception.</returns>
        /// <example>
        ///
        /// var counter = Atom.Value(1);
        ///
        /// await Atom.When(() => counter.Value == 10);
        /// Debug.Log("Counter value equals 10");
        ///
        /// </example>
        public static Task When(
            Func <bool> p,
            CancellationToken cancellationToken = default,
            string debugName = null)
        {
            var taskCompletionSource = new TaskCompletionSource <object>();

            Reaction watcher = null;
            CancellationTokenRegistration?cancellationTokenRegistration = null;

            void Dispose()
            {
                taskCompletionSource.TrySetCanceled();
                // ReSharper disable once AccessToModifiedClosure
                cancellationTokenRegistration?.Dispose();
                // ReSharper disable once AccessToModifiedClosure
                watcher?.Deactivate();
                watcher = null;
            }

            watcher = new ReactionAtom(debugName, () =>
            {
                Exception exception = null;
                try
                {
                    if (!p())
                    {
                        return;
                    }
                }
                catch (Exception e)
                {
                    exception = e;
                }

                using (NoWatch)
                {
                    if (exception != null)
                    {
                        taskCompletionSource.TrySetException(exception);
                    }
                    else
                    {
                        taskCompletionSource.TrySetResult(null);
                    }

                    Dispose();
                }
            });

            if (cancellationToken.IsCancellationRequested)
            {
                Dispose();
            }
            else
            {
                watcher.Activate();

                if (cancellationToken.CanBeCanceled)
                {
                    cancellationTokenRegistration = cancellationToken.Register(Dispose, true);
                }
            }

            return(taskCompletionSource.Task);
        }
Esempio n. 46
0
 protected override void FireReaction(Reaction reaction, int delta)
 {
     throw new ApplicationException("HybridSSA doesn't implement FireReaction(reaction, delta).");
 }
 public void Add(Reaction Reaction)
 {
     _context.Add(Reaction);
     _context.SaveChanges();
 }
 private void DeleteReaction(Reaction reaction)
 {
     // 行削除
     db.Reactions.Remove(reaction);
     db.SaveChanges();
 }
Esempio n. 49
0
 public void BeforeTest()
 {
     Reaction.Reset();
 }
Esempio n. 50
0
 public static Reaction <T> Culling <T> (this Reaction <T> render, CullFaceMode mode = CullFaceMode.Back,
                                         FrontFaceDirection frontFace = FrontFaceDirection.Cw)
 {
     return(render.Culling(i => Tuple.Create(mode, frontFace)));
 }
Esempio n. 51
0
 public static Reaction <T> SwapBuffers <T> (this Reaction <T> render, GameWindow window)
 {
     return(render.SwapBuffers(i => window));
 }
Esempio n. 52
0
        public CrazyTalkEmotionState(NPC toControl, string currentDialogue)
            : base(toControl, currentDialogue)
        {
            randomMessage = new Reaction();

            randomMessage.AddAction(new NPCCallbackAction(RandomMessage));
            SetOnOpenInteractionReaction(new DispositionDependentReaction(randomMessage));

            stringList[0] = "...";
            stringList[1] = "...I want you not";
            stringList[2] = "Hey... Want to be friends...?";
            stringList[3] = "I need no one...no...one...";
            stringCounter = 4;
        }
Esempio n. 53
0
        public static AppState Reduce(AppState state, object bAction)
        {
            switch (bAction)
            {
            case AddCountAction action: {
                state.Count += action.number;
                PlayerPrefs.SetInt("count", value: state.Count);
                PlayerPrefs.Save();
                break;
            }

            case LoginChangeEmailAction action: {
                state.loginState.email = action.changeText;
                break;
            }

            case LoginChangePasswordAction action: {
                state.loginState.password = action.changeText;
                break;
            }

            case ShowChatWindowAction action: {
                state.eventState.showChatWindow = action.show;
                break;
            }

            case ChatWindowStatusAction action: {
                state.eventState.openChatWindow = action.status;
                break;
            }

            case StartLoginByEmailAction _: {
                state.loginState.loading = true;
                break;
            }

            case LoginByEmailSuccessAction action: {
                state.loginState.loading          = false;
                state.loginState.loginInfo        = action.loginInfo;
                state.loginState.isLoggedIn       = true;
                state.articleState.articleHistory =
                    HistoryManager.articleHistoryList(userId: action.loginInfo.userId);
                state.eventState.eventHistory       = HistoryManager.eventHistoryList(userId: action.loginInfo.userId);
                state.searchState.searchHistoryList =
                    HistoryManager.searchHistoryList(userId: action.loginInfo.userId);
                state.articleState.blockArticleList =
                    HistoryManager.blockArticleList(userId: action.loginInfo.userId);
                EventBus.publish(sName: EventBusConstant.login_success, new List <object>());
                break;
            }

            case LoginByEmailFailureAction _: {
                state.loginState.loading = false;
                break;
            }

            case LoginByWechatAction action: {
                state.loginState.loading = true;
                break;
            }

            case LoginByWechatSuccessAction action: {
                state.loginState.loading          = false;
                state.loginState.loginInfo        = action.loginInfo;
                state.loginState.isLoggedIn       = true;
                state.articleState.articleHistory =
                    HistoryManager.articleHistoryList(userId: action.loginInfo.userId);
                state.eventState.eventHistory       = HistoryManager.eventHistoryList(userId: action.loginInfo.userId);
                state.searchState.searchHistoryList =
                    HistoryManager.searchHistoryList(userId: action.loginInfo.userId);
                EventBus.publish(sName: EventBusConstant.login_success, new List <object>());
                break;
            }

            case LoginByWechatFailureAction action: {
                state.loginState.loading = false;
                break;
            }

            case LogoutAction _: {
                HttpManager.clearCookie();
                state.loginState.loginInfo  = new LoginInfo();
                state.loginState.isLoggedIn = false;
                UserInfoManager.clearUserInfo();
                state.articleState.articleHistory   = HistoryManager.articleHistoryList();
                state.eventState.eventHistory       = HistoryManager.eventHistoryList();
                state.searchState.searchHistoryList = HistoryManager.searchHistoryList();
                state.articleState.blockArticleList = HistoryManager.blockArticleList();
                break;
            }

            case CleanEmailAndPasswordAction action: {
                state.loginState.email    = "";
                state.loginState.password = "";
                break;
            }

            case JumpToCreateUnityIdAction _: {
                break;
            }

            case StartFetchArticlesAction _: {
                state.articleState.articlesLoading = true;
                break;
            }

            case FetchArticleSuccessAction action: {
                if (action.offset == 0)
                {
                    state.articleState.articleList.Clear();
                }

                foreach (var article in action.articleList)
                {
                    state.articleState.articleList.Add(item: article.id);
                    if (!state.articleState.articleDict.ContainsKey(key: article.id))
                    {
                        state.articleState.articleDict.Add(key: article.id, value: article);
                    }
                }

                state.articleState.hottestHasMore  = action.hottestHasMore;
                state.articleState.articlesLoading = false;
                break;
            }

            case FetchArticleFailureAction _: {
                state.articleState.articlesLoading = false;
                break;
            }

            case StartFetchArticleDetailAction _: {
                state.articleState.articleDetailLoading = true;
                break;
            }

            case FetchArticleDetailSuccessAction action: {
                state.articleState.articleDetailLoading = false;
                var article = action.articleDetail.projectData;
                article.like                = action.articleDetail.like;
                article.edit                = action.articleDetail.edit;
                article.projects            = action.articleDetail.projects;
                article.channelId           = action.articleDetail.channelId;
                article.contentMap          = action.articleDetail.contentMap;
                article.hasMore             = action.articleDetail.comments.hasMore;
                article.isNotFirst          = true;
                article.currOldestMessageId = action.articleDetail.comments.currOldestMessageId;
                var dict = state.articleState.articleDict;
                if (dict.ContainsKey(key: article.id))
                {
                    state.articleState.articleDict[key : article.id] = article;
                }
                else
                {
                    state.articleState.articleDict.Add(key: article.id, value: article);
                }

                break;
            }

            case FetchArticleDetailFailureAction _: {
                state.articleState.articleDetailLoading = false;
                break;
            }

            case SaveArticleHistoryAction action: {
                var article  = action.article;
                var fullName = "";
                if (article.ownerType == "user")
                {
                    var userDict = state.userState.userDict;
                    if (article.userId != null && userDict.ContainsKey(key: article.userId))
                    {
                        fullName = userDict[key : article.userId].fullName;
                    }
                }

                if (article.ownerType == "team")
                {
                    var teamDict = state.teamState.teamDict;
                    if (article.teamId != null && teamDict.ContainsKey(key: article.teamId))
                    {
                        fullName = teamDict[key : article.teamId].name;
                    }
                }

                article.fullName = fullName;
                var articleHistoryList = HistoryManager.saveArticleHistory(article: article,
                                                                           state.loginState.isLoggedIn ? state.loginState.loginInfo.userId : null);
                state.articleState.articleHistory = articleHistoryList;
                break;
            }

            case DeleteArticleHistoryAction action: {
                var articleHistoryList = HistoryManager.deleteArticleHistory(articleId: action.articleId,
                                                                             state.loginState.isLoggedIn ? state.loginState.loginInfo.userId : null);
                state.articleState.articleHistory = articleHistoryList;
                break;
            }

            case DeleteAllArticleHistoryAction _: {
                state.articleState.articleHistory = new List <Article>();
                HistoryManager.deleteAllArticleHistory(state.loginState.isLoggedIn
                        ? state.loginState.loginInfo.userId
                        : null);
                break;
            }

            case LikeArticleAction _: {
                break;
            }

            case LikeArticleSuccessAction action: {
                if (state.articleState.articleDict.ContainsKey(key: action.articleId))
                {
                    state.articleState.articleDict[key : action.articleId].like = true;
                }

                break;
            }

            case BlockArticleAction action: {
                var blockArticleList =
                    HistoryManager.saveBlockArticleList(articleId: action.articleId,
                                                        userId: state.loginState.loginInfo.userId);
                state.articleState.blockArticleList = blockArticleList;
                break;
            }

            case StartFetchArticleCommentsAction _: {
                break;
            }

            case FetchArticleCommentsSuccessAction action: {
                var channelMessageList = new Dictionary <string, List <string> >();
                var channelMessageDict = new Dictionary <string, Dictionary <string, Message> >();

                // action.commentsResponse.parents.ForEach(message => { messageItem[message.id] = message; });
                channelMessageList.Add(key: action.channelId, value: action.itemIds);
                channelMessageDict.Add(key: action.channelId, value: action.messageItems);

                if (action.channelId.isNotEmpty())
                {
                    foreach (var dict in state.articleState.articleDict)
                    {
                        if (dict.Value.channelId == action.channelId)
                        {
                            dict.Value.hasMore             = action.hasMore;
                            dict.Value.currOldestMessageId = action.currOldestMessageId;
                        }
                    }
                }

                foreach (var keyValuePair in channelMessageList)
                {
                    if (state.messageState.channelMessageList.ContainsKey(key: keyValuePair.Key))
                    {
                        var oldList = state.messageState.channelMessageList[key : keyValuePair.Key];
                        if (action.isRefreshList)
                        {
                            oldList.Clear();
                        }

                        oldList.AddRange(collection: keyValuePair.Value);
                        state.messageState.channelMessageList[key : keyValuePair.Key] = oldList;
                    }
                    else
                    {
                        state.messageState.channelMessageList.Add(key: keyValuePair.Key, value: keyValuePair.Value);
                    }
                }

                foreach (var keyValuePair in channelMessageDict)
                {
                    if (state.messageState.channelMessageDict.ContainsKey(key: keyValuePair.Key))
                    {
                        var oldDict = state.messageState.channelMessageDict[key : keyValuePair.Key];
                        var newDict = keyValuePair.Value;
                        foreach (var valuePair in newDict)
                        {
                            if (oldDict.ContainsKey(key: valuePair.Key))
                            {
                                oldDict[key : valuePair.Key] = valuePair.Value;
                            }
                            else
                            {
                                oldDict.Add(key: valuePair.Key, value: valuePair.Value);
                            }
                        }

                        state.messageState.channelMessageDict[key : keyValuePair.Key] = oldDict;
                    }
                    else
                    {
                        state.messageState.channelMessageDict.Add(key: keyValuePair.Key, value: keyValuePair.Value);
                    }
                }

                break;
            }

            case StartLikeCommentAction _: {
                break;
            }

            case LikeCommentSuccessAction action: {
                var user = new User();
                user.id = state.loginState.loginInfo.userId;
                var reaction = new Reaction();
                reaction.user = user;
                action.message.reactions.Add(item: reaction);
                state.messageState.channelMessageDict[key : action.message.channelId][key : action.message.id] =
                    action.message;
                break;
            }

            case LikeCommentFailureAction _: {
                break;
            }

            case StartRemoveLikeCommentAction action: {
                break;
            }

            case RemoveLikeCommentSuccessAction action: {
                var reactions = action.message.reactions;
                foreach (var reaction in reactions)
                {
                    if (reaction.user.id == state.loginState.loginInfo.userId)
                    {
                        action.message.reactions.Remove(item: reaction);
                        break;
                    }
                }

                state.messageState.channelMessageDict[key : action.message.channelId][key : action.message.id] =
                    action.message;
                break;
            }

            case StartSendCommentAction action: {
                break;
            }

            case SendCommentSuccessAction action: {
                if (state.messageState.channelMessageList.ContainsKey(key: action.message.channelId))
                {
                    var list = state.messageState.channelMessageList[key : action.message.channelId];
                    list.Insert(0, item: action.message.id);
                    state.messageState.channelMessageList[key : action.message.channelId] = list;
                }
                else
                {
                    state.messageState.channelMessageList.Add(key: action.message.channelId,
                                                              new List <string> {
                            action.message.id
                        });
                }

                if (state.messageState.channelMessageDict.ContainsKey(key: action.message.channelId))
                {
                    var dict = state.messageState.channelMessageDict[key : action.message.channelId];
                    dict.Add(key: action.message.id, value: action.message);
                    state.messageState.channelMessageDict[key : action.message.channelId] = dict;
                }
                else
                {
                    state.messageState.channelMessageDict.Add(
                        key: action.message.channelId,
                        new Dictionary <string, Message> {
                            { action.message.id, action.message }
                        }
                        );
                }

                break;
            }

            case StartFetchEventOngoingAction _: {
                state.eventState.eventsOngoingLoading = true;
                break;
            }

            case StartFetchEventCompletedAction _: {
                state.eventState.eventsCompletedLoading = true;
                break;
            }

            case FetchEventsFailureAction action: {
                if (action.pageNumber == 1)
                {
                    if (action.tab == "ongoing")
                    {
                        state.eventState.eventsOngoingLoading = false;
                        state.eventState.pageNumber           = action.pageNumber;
                    }
                    else
                    {
                        state.eventState.eventsCompletedLoading = false;
                        state.eventState.completedPageNumber    = action.pageNumber;
                    }
                }

                break;
            }

            case FetchEventsSuccessAction action: {
                if (action.tab == "ongoing")
                {
                    state.eventState.eventsOngoingLoading = false;
                    state.eventState.pageNumber           = action.pageNumber;
                    state.eventState.ongoingEventTotal    = action.eventsResponse.events.total;
                }
                else
                {
                    state.eventState.eventsCompletedLoading = false;
                    state.eventState.completedPageNumber    = action.pageNumber;
                    state.eventState.completedEventTotal    = action.eventsResponse.events.total;
                }

                if (action.pageNumber == 1)
                {
                    if (action.tab == "ongoing")
                    {
                        state.eventState.ongoingEvents.Clear();
                    }
                    else
                    {
                        state.eventState.completedEvents.Clear();
                    }
                }

                action.eventsResponse.events.items.ForEach(eventObj => {
//                        if (eventObj.mode == "online") return;
                        if (action.tab == "ongoing")
                        {
                            if (!state.eventState.ongoingEvents.Contains(item: eventObj.id))
                            {
                                state.eventState.ongoingEvents.Add(item: eventObj.id);
                            }
                        }
                        else
                        {
                            if (!state.eventState.completedEvents.Contains(item: eventObj.id))
                            {
                                state.eventState.completedEvents.Add(item: eventObj.id);
                            }
                        }

                        if (state.eventState.eventsDict.ContainsKey(key: eventObj.id))
                        {
                            state.eventState.eventsDict[key: eventObj.id] = eventObj;
                        }
                        else
                        {
                            state.eventState.eventsDict.Add(key: eventObj.id, value: eventObj);
                        }
                    });
                break;
            }

            case StartFetchEventDetailAction _: {
                state.eventState.eventDetailLoading = true;
                break;
            }

            case FetchEventDetailSuccessAction action: {
                state.eventState.eventDetailLoading = false;
                state.eventState.channelId          = action.eventObj.channelId;
                if (state.eventState.eventsDict.ContainsKey(key: action.eventObj.id))
                {
                    state.eventState.eventsDict[key : action.eventObj.id] = action.eventObj;
                }
                else
                {
                    state.eventState.eventsDict.Add(key: action.eventObj.id, value: action.eventObj);
                }

                break;
            }

            case FetchEventDetailFailedAction _: {
                state.eventState.eventDetailLoading = false;
                break;
            }

            case SaveEventHistoryAction action: {
                var eventObj = action.eventObj;
                var place    = "";
                if (eventObj.mode == "offline")
                {
                    var placeDict = state.placeState.placeDict;
                    if (eventObj.placeId != null && placeDict.ContainsKey(key: eventObj.placeId))
                    {
                        place = placeDict[key : eventObj.placeId].name;
                    }
                }

                eventObj.place = place;
                if (eventObj.mode.isEmpty())
                {
                    eventObj.mode = action.eventType == EventType.online ? "online" : "offline";
                }

                var eventHistoryList = HistoryManager.saveEventHistoryList(eventObj: eventObj,
                                                                           state.loginState.isLoggedIn ? state.loginState.loginInfo.userId : null);
                state.eventState.eventHistory = eventHistoryList;
                break;
            }

            case DeleteEventHistoryAction action: {
                var eventHistoryList = HistoryManager.deleteEventHistoryList(eventId: action.eventId,
                                                                             state.loginState.isLoggedIn ? state.loginState.loginInfo.userId : null);
                state.eventState.eventHistory = eventHistoryList;
                break;
            }

            case DeleteAllEventHistoryAction action: {
                state.eventState.eventHistory = new List <IEvent>();
                HistoryManager.deleteAllEventHistory(
                    state.loginState.isLoggedIn ? state.loginState.loginInfo.userId : null);
                break;
            }

            case StartJoinEventAction _: {
                state.eventState.joinEventLoading = true;
                break;
            }

            case JoinEventSuccessAction action: {
                state.eventState.joinEventLoading = false;
                var eventObj = state.eventState.eventsDict[key : action.eventId];
                eventObj.userIsCheckedIn = true;
                state.eventState.eventsDict[key : action.eventId] = eventObj;
                break;
            }

            case JoinEventFailureAction _: {
                state.eventState.joinEventLoading = false;
                break;
            }

            case StartFetchNotificationsAction _: {
                state.notificationState.loading = true;
                break;
            }

            case FetchNotificationsSuccessAction action: {
                state.notificationState.pageTotal     = action.pageTotal;
                state.notificationState.notifications = action.notifications;
                state.notificationState.mentions      = action.mentions;
                state.notificationState.loading       = false;
                break;
            }

            case FetchNotificationsFailureAction _: {
                state.notificationState.loading = false;
                break;
            }

            case StartReportItemAction _: {
                state.reportState.loading = true;
                break;
            }

            case ReportItemSuccessAction _: {
                state.reportState.loading = false;
                break;
            }

            case ReportItemFailureAction _: {
                state.reportState.loading = false;
                break;
            }

            case StartFetchMyFutureEventsAction _: {
                state.mineState.futureListLoading = true;
                break;
            }

            case FetchMyFutureEventsSuccessAction action: {
                state.mineState.futureListLoading = false;
                state.mineState.futureEventTotal  = action.eventsResponse.events.total;
                var offlineItems = action.eventsResponse.events.items.FindAll(item => item.mode != "online");
                if (action.pageNumber == 1)
                {
                    state.mineState.futureEventsList = offlineItems;
                }
                else
                {
                    var results = state.mineState.futureEventsList;
                    results.AddRange(collection: offlineItems);
                    state.mineState.futureEventsList = results;
                }

                break;
            }

            case FetchMyFutureEventsFailureAction _: {
                state.mineState.futureListLoading = false;
                break;
            }

            case StartFetchMyPastEventsAction _: {
                state.mineState.pastListLoading = true;
                break;
            }

            case FetchMyPastEventsSuccessAction action: {
                state.mineState.pastListLoading = false;
                state.mineState.pastEventTotal  = action.eventsResponse.events.total;
                var offlineItems = action.eventsResponse.events.items;
                if (action.pageNumber == 1)
                {
                    state.mineState.pastEventsList = offlineItems;
                }
                else
                {
                    var results = state.mineState.pastEventsList;
                    results.AddRange(collection: offlineItems);
                    state.mineState.pastEventsList = results;
                }

                break;
            }

            case FetchMyPastEventsFailureAction _: {
                state.mineState.pastListLoading = false;
                break;
            }

            case StartFetchMessagesAction _: {
                state.messageState.messageLoading = true;
                break;
            }

            case FetchMessagesSuccessAction action: {
                if (action.messageIds != null && action.messageIds.Count > 0 &&
                    action.messageDict != null && action.messageDict.Count > 0)
                {
                    var channelMessageList = state.messageState.channelMessageList;
                    var channelMessageDict = state.messageState.channelMessageDict;
                    if (channelMessageList.ContainsKey(key: action.channelId))
                    {
                        channelMessageList[key : action.channelId] = action.messageIds;
                    }
                    else
                    {
                        channelMessageList.Add(key: action.channelId, value: action.messageIds);
                    }

                    if (channelMessageDict.ContainsKey(key: action.channelId))
                    {
                        channelMessageDict[key : action.channelId] = action.messageDict;
                    }
                    else
                    {
                        channelMessageDict.Add(key: action.channelId, value: action.messageDict);
                    }

                    state.messageState.channelMessageList  = channelMessageList;
                    state.messageState.channelMessageDict  = channelMessageDict;
                    state.messageState.hasMore             = action.hasMore;
                    state.messageState.currOldestMessageId = action.currOldestMessageId;
                }

                state.messageState.messageLoading = false;
                break;
            }

            case FetchMessagesFailureAction _: {
                state.messageState.messageLoading = false;
                break;
            }

            case StartSendMessageAction _: {
                state.messageState.sendMessageLoading = true;
                break;
            }

            case SendMessageSuccessAction action: {
                var channelMessageList = state.messageState.channelMessageList;
                var channelMessageDict = state.messageState.channelMessageDict;
                var messageIds         = new List <string>();
                if (channelMessageList.ContainsKey(key: action.channelId))
                {
                    messageIds = channelMessageList[key : action.channelId];
                }

                var messageDict = new Dictionary <string, Message>();
                if (channelMessageDict.ContainsKey(key: action.channelId))
                {
                    messageDict = channelMessageDict[key : action.channelId];
                }

                messageIds.Insert(0, item: action.nonce);
                if (channelMessageList.ContainsKey(key: action.channelId))
                {
                    channelMessageList[key : action.channelId] = messageIds;
                }
                else
                {
                    channelMessageList.Add(key: action.channelId, value: messageIds);
                }

                var previewMsg = new Message {
                    id      = action.nonce,
                    content = action.content,
                    author  = new User {
                        id       = state.loginState.loginInfo.userId,
                        fullName = state.loginState.loginInfo.userFullName
                    }
                };
                _nonce.Add(item: action.nonce);
                if (messageDict.ContainsKey(key: action.nonce))
                {
                    messageDict[key : action.nonce] = previewMsg;
                }
                else
                {
                    messageDict.Add(key: action.nonce, value: previewMsg);
                }

                state.messageState.channelMessageList = channelMessageList;
                state.messageState.channelMessageDict = channelMessageDict;
                state.messageState.sendMessageLoading = false;
                break;
            }

            case SendMessageFailureAction _: {
                state.messageState.sendMessageLoading = false;
                break;
            }

            case UserMapAction action: {
                var userDict = state.userState.userDict;
                foreach (var keyValuePair in action.userMap)
                {
                    if (userDict.ContainsKey(key: keyValuePair.Key))
                    {
                        userDict[key : keyValuePair.Key] = keyValuePair.Value;
                    }
                    else
                    {
                        userDict.Add(key: keyValuePair.Key, value: keyValuePair.Value);
                    }
                }

                state.userState.userDict = userDict;
                break;
            }

            case TeamMapAction action: {
                var teamDict = state.teamState.teamDict;
                foreach (var keyValuePair in action.teamMap)
                {
                    if (teamDict.ContainsKey(key: keyValuePair.Key))
                    {
                        teamDict[key : keyValuePair.Key] = keyValuePair.Value;
                    }
                    else
                    {
                        teamDict.Add(key: keyValuePair.Key, value: keyValuePair.Value);
                    }
                }

                state.teamState.teamDict = teamDict;
                break;
            }

            case PlaceMapAction action: {
                var placeDict = state.placeState.placeDict;
                foreach (var keyValuePair in action.placeMap)
                {
                    if (placeDict.ContainsKey(key: keyValuePair.Key))
                    {
                        placeDict[key : keyValuePair.Key] = keyValuePair.Value;
                    }
                    else
                    {
                        placeDict.Add(key: keyValuePair.Key, value: keyValuePair.Value);
                    }
                }

                state.placeState.placeDict = placeDict;
                break;
            }

            case PopularSearchSuccessAction action: {
                state.popularSearchState.popularSearchs = action.popularSearch;
                break;
            }

            case StartSearchArticleAction _: {
                state.searchState.loading = true;
                break;
            }

            case SearchArticleSuccessAction action: {
                state.searchState.loading     = false;
                state.searchState.keyword     = action.keyword;
                state.searchState.currentPage = action.searchResponse.currentPage;
                state.searchState.pages       = action.searchResponse.pages;
                if (action.pageNumber == 0)
                {
                    state.searchState.searchArticles = action.searchResponse.projects;
                }
                else
                {
                    var searchArticles = state.searchState.searchArticles;
                    searchArticles.AddRange(collection: action.searchResponse.projects);
                    state.searchState.searchArticles = searchArticles;
                }

                break;
            }

            case SearchArticleFailureAction action: {
                state.searchState.loading = false;
                state.searchState.keyword = action.keyword;
                break;
            }

            case ClearSearchArticleResultAction action: {
                state.searchState.keyword        = "";
                state.searchState.searchArticles = new List <Article>();
                break;
            }

            case SaveSearchHistoryAction action: {
                var searchHistoryList = HistoryManager.saveSearchHistoryList(keyword: action.keyword,
                                                                             state.loginState.isLoggedIn ? state.loginState.loginInfo.userId : null);
                state.searchState.searchHistoryList = searchHistoryList;
                break;
            }

            case DeleteSearchHistoryAction action: {
                var searchHistoryList = HistoryManager.deleteSearchHistoryList(keyword: action.keyword,
                                                                               state.loginState.isLoggedIn ? state.loginState.loginInfo.userId : null);
                state.searchState.searchHistoryList = searchHistoryList;
                break;
            }

            case DeleteAllSearchHistoryAction action: {
                state.searchState.searchHistoryList = new List <string>();
                HistoryManager.deleteAllSearchHistory(state.loginState.isLoggedIn
                        ? state.loginState.loginInfo.userId
                        : null);
                break;
            }

            case MainNavigatorPushToArticleDetailAction action: {
                if (action.articleId != null)
                {
                    Router.navigator.push(new PageRouteBuilder(
                                              pageBuilder: (context, animation, secondaryAnimation) =>
                                              new ArticleDetailScreenConnector(articleId: action.articleId),
                                              transitionsBuilder: (context1, animation, secondaryAnimation, child) =>
                                              new PushPageTransition(
                                                  routeAnimation: animation,
                                                  child: child
                                                  ))
                                          );
                }

                break;
            }

            case MainNavigatorPushToEventDetailAction action: {
                if (action.eventId != null)
                {
                    Router.navigator.push(new PageRouteBuilder(
                                              pageBuilder: (context, animation, secondaryAnimation) => {
                            if (action.eventType == EventType.offline)
                            {
                                return(new EventOfflineDetailScreenConnector(eventId: action.eventId));
                            }

                            return(new EventOnlineDetailScreenConnector(eventId: action.eventId));
                        },
                                              transitionsBuilder: (context1, animation, secondaryAnimation, child) =>
                                              new PushPageTransition(
                                                  routeAnimation: animation,
                                                  child: child
                                                  ))
                                          );
                }

                break;
            }

            case MainNavigatorPushToReportAction action: {
                Router.navigator.push(new PageRouteBuilder(
                                          pageBuilder: (context, animation, secondaryAnimation) =>
                                          new ReportScreenConnector(reportId: action.reportId, reportType: action.reportType),
                                          transitionsBuilder: (context1, animation, secondaryAnimation, child) =>
                                          new PushPageTransition(
                                              routeAnimation: animation,
                                              child: child
                                              )
                                          )
                                      );

                break;
            }

            case MainNavigatorPushToAction action: {
                Router.navigator.pushNamed(routeName: action.routeName);
                break;
            }

            case MainNavigatorPushToRouteAction action: {
                Router.navigator.push(route: action.route);
                break;
            }

            case MainNavigatorPopAction action: {
                for (var i = 0; i < action.index; i++)
                {
                    if (Router.navigator.canPop())
                    {
                        Router.navigator.pop();
                    }
                }

                break;
            }

            case LoginNavigatorPushToBindUnityAction _: {
                LoginScreen.navigator.push(new PageRouteBuilder(
                                               pageBuilder: (context, animation, secondaryAnimation) =>
                                               new BindUnityScreenConnector(fromPage: FromPage.login),
                                               transitionsBuilder: (context1, animation, secondaryAnimation, child) => new PushPageTransition(
                                                   routeAnimation: animation,
                                                   child: child
                                                   ))
                                           );
                break;
            }

            case LoginNavigatorPushToAction action: {
                LoginScreen.navigator.pushNamed(routeName: action.routeName);
                break;
            }

            case LoginNavigatorPopAction action: {
                for (var i = 0; i < action.index; i++)
                {
                    if (LoginScreen.navigator.canPop())
                    {
                        LoginScreen.navigator.pop();
                    }
                }

                break;
            }

            case OpenUrlAction action: {
                if (action.url != null || action.url.Length > 0)
                {
                    Application.OpenURL(url: action.url);
                }

                break;
            }

            case CopyTextAction action: {
                Clipboard.setData(new ClipboardData(text: action.text));
                break;
            }

            case MainNavigatorPushToWebViewAction action: {
                if (action.url != null)
                {
                    Router.navigator.push(new PageRouteBuilder(
                                              pageBuilder: (context, animation, secondaryAnimation) =>
                                              new WebViewScreen(url: action.url),
                                              transitionsBuilder: (context1, animation, secondaryAnimation, child) =>
                                              new PushPageTransition(
                                                  routeAnimation: animation,
                                                  child: child
                                                  ))
                                          );
                }

                break;
            }

            case PlayVideoAction action: {
                if (action.url != null)
                {
                    Router.navigator.push(new PageRouteBuilder(
                                              pageBuilder: (context, animation, secondaryAnimation) =>
                                              new VideoViewScreen(url: action.url),
                                              transitionsBuilder: (context1, animation, secondaryAnimation, child) =>
                                              new PushPageTransition(
                                                  routeAnimation: animation,
                                                  child: child
                                                  ))
                                          );
                }

                break;
            }

            case FetchReviewUrlSuccessAction action: {
                state.settingState.reviewUrl    = action.url;
                state.settingState.hasReviewUrl = action.url.isNotEmpty();
                break;
            }

            case FetchReviewUrlFailureAction _: {
                state.settingState.reviewUrl    = "";
                state.settingState.hasReviewUrl = false;
                break;
            }

            case SettingClearCacheAction _: {
                state.articleState.articleHistory   = new List <Article>();
                state.eventState.eventHistory       = new List <IEvent>();
                state.searchState.searchHistoryList = new List <string>();
                HistoryManager.deleteAllArticleHistory(state.loginState.isLoggedIn
                        ? state.loginState.loginInfo.userId
                        : null);
                HistoryManager.deleteAllEventHistory(state.loginState.isLoggedIn
                        ? state.loginState.loginInfo.userId
                        : null);
                HistoryManager.deleteAllSearchHistory(state.loginState.isLoggedIn
                        ? state.loginState.loginInfo.userId
                        : null);
                break;
            }
            }

            return(state);
        }
Esempio n. 54
0
 public static Reaction <T> DepthTest <T> (this Reaction <T> render,
                                           DepthFunction depthFunction = DepthFunction.Less)
 {
     return(render.DepthTest(i => depthFunction));
 }
Esempio n. 55
0
 public static Reaction <T> Texture <T> (this Reaction <T> render, Texture texture)
 {
     return(render.Texture(i => texture));
 }
Esempio n. 56
0
 public static Reaction <T> Program <T> (this Reaction <T> render, GLProgram program)
 {
     return(render.Program(i => program));
 }
Esempio n. 57
0
        /// <summary>
        /// Calculates support reactions for the given load case and deformation vector.
        /// </summary>
        private void CalculateReactions(AnalysisCase analysisCase, Vector<double> reactions)
        {
            analysisCase.Reactions.Clear();

            for (int i = 0; i < nodes.Count; i++)
            {
                int j = nodes[i].Index;
                if (nodes[i].Restraints != DOF.Free)
                {
                    Reaction r = new Reaction(nodes[i], reactions[j * 3], reactions[j * 3 + 1], reactions[j * 3 + 2]);
                    analysisCase.Reactions.Add(r);
                }
            }
        }
Esempio n. 58
0
 public static Reaction <T> DrawBuffer <T> (this Reaction <T> render, DrawBufferMode mode)
 {
     return(render.DrawBuffer(i => mode));
 }
Esempio n. 59
0
 public Place addPutReaction(Reaction r)
 {
     put_reaction += r;
     return(this);
 }
Esempio n. 60
0
 public static Reaction <T> Viewport <T> (this Reaction <T> render, Vec2i size)
 {
     return(render.Viewport(i => size));
 }