public async Task <IActionResult> PutMotive([FromRoute] int id, [FromBody] Motive motive)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != motive.Id)
            {
                return(BadRequest());
            }

            motive.UpdatedAt = DateTimeOffset.Now;

            _context.Entry(motive).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MotiveExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok(_context.Motives.Find(id)));
        }
Ejemplo n.º 2
0
    public void Generate()
    {
        int index = -1;

        if (LevelLoader.instance.doneQuest == -1)
        {
            index = RandomNumber.Range(0, 2);
        }
        else
        {
            if (LevelLoader.instance.canSwitch)
            {
                if (LevelLoader.instance.doneQuest == 0)
                {
                    index = 1;
                }
                else
                {
                    index = 0;
                }

                LevelLoader.instance.canSwitch = false;
            }
            else
            {
                index = LevelLoader.instance.doneQuest;
            }
        }

        LevelLoader.instance.doneQuest = index;

        start = listMotives.Motive[index].motives[0];

        CreateQuestTree();
    }
Ejemplo n.º 3
0
 public static void Serialize(string path, Motive target)
 {
     using (StreamWriter fs = new StreamWriter(path))
     {
         new XmlSerializer(typeof (Motive)).Serialize(fs, target);
     }
 }
Ejemplo n.º 4
0
        public override void ClearPregnancyData()
        {
            if (mContractionBroadcast != null)
            {
                mContractionBroadcast.Dispose();
            }

            if (mMom != null)
            {
                mMom.RemoveAlarm(PreggersAlarm);
                UnrequestPregnantWalkStyle();

                if (!mMom.HasBeenDestroyed)
                {
                    if (!mMom.SimDescription.IsVampire)
                    {
                        Motive motive = mMom.Motives.GetMotive(CommodityKind.Hunger);

                        if (motive != null)
                        {
                            motive.PregnantMotiveDecay = false;
                        }
                    }

                    Motive motive2 = mMom.Motives.GetMotive(CommodityKind.Bladder);

                    if (motive2 != null)
                    {
                        motive2.PregnantMotiveDecay = false;
                    }

                    mMom.SimDescription.NullOutPregnancy();
                }
            }
        }
Ejemplo n.º 5
0
    private void End(Motive motive)
    {
        Target.Interrupt(motive);

        OnEnd();
        onEnd?.Invoke(motive);
    }
Ejemplo n.º 6
0
    PickAndPlaceData RememberBlocks()
    {
        var topLayer = Motive.GetTiles(_rect);

        if (topLayer == null)
        {
            Message = "Camera error.";
            return(null);
        }

        if (topLayer.Count == 0)
        {
            _isScanning = false;
            Message     = "Finished scanning, rebuilding.";
            return(BuildBlocks());
        }

        var pick = topLayer.First();

        _pickTiles.Add(pick);
        var place = JengaLocation(_tileCount);

        _tileCount++;
        return(new PickAndPlaceData {
            Pick = pick, Place = place
        });
    }
    private void DrawFileControls()
    {
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("New"))
        {
            if (EditorUtility.DisplayDialog("Are you sure?", "OK", "Cancel"))
            {
                mCurrentMotive = new Motive();
            }
        }
        if (GUILayout.Button("Save"))
        {
            string path = EditorUtility.SaveFilePanel("Save Current Level", "", "NewLevel", "txt");
            if (path.Length != 0)
            {
                Motive.Serialize(path, mCurrentMotive);
            }
        }
        if (GUILayout.Button("Load"))
        {
            string path = EditorUtility.OpenFilePanel("Load New Level", "", "txt");

            if (path.Length != 0)
            {
                mCurrentMotive = Motive.Deserialize(path);
            }

        }
        EditorGUILayout.EndHorizontal();
    }
Ejemplo n.º 8
0
        public IActionResult Edit(int id)
        {
            Motive motive = _data.Motives.Get(id);

            ViewBag.Action = "Editar motivo";
            return(View(motive));
        }
Ejemplo n.º 9
0
    public Motive Transposed(int t, int min, int max)
    {
        Motive newmotive = new Motive(this);

        newmotive.Transpose(t, min, max);
        return(newmotive);
    }
Ejemplo n.º 10
0
    public Motive Transposed(int t)
    {
        Motive newmotive = new Motive(this);

        newmotive.Transpose(t);
        return(newmotive);
    }
Ejemplo n.º 11
0
    public Motive Dilated(int about, int amount)
    {
        Motive newmotive = new Motive(this);

        newmotive.Dilate(about, amount);
        return(newmotive);
    }
Ejemplo n.º 12
0
    public Motive Reversed()
    {
        Motive newmotive = new Motive(this);

        newmotive.Reverse();
        return(newmotive);
    }
Ejemplo n.º 13
0
    public Motive Inverted()
    {
        Motive newmotive = new Motive(this);

        newmotive.Invert();
        return(newmotive);
    }
Ejemplo n.º 14
0
        public IActionResult Edit(Motive motive)
        {
            IEnumerable <Motive> motives          = _data.Motives.List();
            IEnumerable <string> existingCarNames = from c in motives select c.Name;

            string key = nameof(Motive.Name);

            if (ModelState.GetFieldValidationState(key) == ModelValidationState.Valid)
            {
                if (motive.MotiveId == 0 && existingCarNames.Contains(motive.Name))
                {
                    ModelState.AddModelError(key, "Escolha outro nome");
                }
            }

            if (ModelState.IsValid)
            {
                if (motive.MotiveId == 0)
                {
                    _data.Motives.Insert(motive);
                }
                else
                {
                    _data.Motives.Update(motive);
                }
                _data.Save();
                return(RedirectToAction("List"));
            }
            else
            {
                ViewBag.Action = motive.MotiveId == 0 ? "Adicionar motivo" : "Editar motivo";
                return(View("Edit", new Motive()));
            }
        }
Ejemplo n.º 15
0
 public static TabiApiClient.Models.TrackMotive ToTrackMotiveMotiveApiModel(this Motive motive)
 {
     return(new TabiApiClient.Models.TrackMotive()
     {
         LocalTrackId = motive.TrackId,
         Motive = motive.Text,
         Timestamp = motive.Timestamp,
     });
 }
Ejemplo n.º 16
0
 public static TabiApiClient.Models.UserStopMotive ToUserStopMotiveApiModel(this Motive motive)
 {
     return(new TabiApiClient.Models.UserStopMotive()
     {
         LocalStopVisitId = motive.StopVisitId,
         Motive = motive.Text,
         Timestamp = motive.Timestamp,
     });
 }
Ejemplo n.º 17
0
        public static SimInfo.SimOccultInfo GetSimOccultInfo()
        {
            Sim sim = Sim.ActiveActor;

            if (sim == null)
            {
                return(new SimInfo.SimOccultInfo(Sims3.SimIFace.CAS.CASAgeGenderFlags.Human));
            }

            if (sim.OccultManager == null)
            {
                return(new SimInfo.SimOccultInfo(Sims3.SimIFace.CAS.CASAgeGenderFlags.Human));
            }

            SimInfo.SimOccultInfo info = new SimInfo.SimOccultInfo(sim.SimDescription.Species);

            if (sim.SimDescription.IsAlienEvolved)
            {
                AlienUtils.GetAlienOccultInfo(ref info);
            }

            if (sim.OccultManager.mOccultList != null)
            {
                foreach (OccultBaseClass occult in sim.OccultManager.mOccultList)
                {
                    occult.UpdateSimOccultInfo(ref info);
                }

                info.OccultType = sim.OccultManager.CurrentOccultTypes;
            }

            if (sim.Motives != null)
            {
                if (sim.SimDescription.IsWitch)
                {
                    Motive motive = sim.Motives.GetMotive(CommodityKind.MagicFatigue);
                    if (motive != null)
                    {
                        info.MagicMotiveValue = -motive.UIValue;

                        //Common.DebugNotify(delegate { return "MagicFatigue2: " + motive.UIValue; });
                    }
                }
                else if (sim.SimDescription.IsFairy)
                {
                    Motive motive = sim.Motives.GetMotive(CommodityKind.AuraPower);
                    if (motive != null)
                    {
                        info.MagicMotiveValue = motive.UIValue;

                        //Common.DebugNotify(delegate { return "AuraPower2: " + motive.UIValue; });
                    }
                }
            }

            return(info);
        }
Ejemplo n.º 18
0
        protected static void UpdateMotives(Sim sim)
        {
            try
            {
                if (sim == null)
                {
                    return;
                }

                if (sim.Motives == null)
                {
                    return;
                }

                if (sim.OccultManager == null)
                {
                    return;
                }

                if (sim.SimDescription.IsMummy)
                {
                    Motive motive = sim.Motives.GetMotive(CommodityKind.Bladder);
                    if (motive != null)
                    {
                        motive.DisableMotive();
                    }

                    motive = sim.Motives.GetMotive(CommodityKind.Energy);
                    if (motive != null)
                    {
                        motive.DisableMotive();
                    }
                }

                if (sim.SimDescription.IsFrankenstein)
                {
                    Motive motive = sim.Motives.GetMotive(CommodityKind.Hygiene);
                    if (motive != null)
                    {
                        motive.DisableMotive();
                    }
                }

                if (sim.SimDescription.IsVampire)
                {
                    Motive motive = sim.Motives.GetMotive(CommodityKind.Fatigue);
                    if (motive != null)
                    {
                        motive.DisableMotive();
                    }
                }
            }
            catch (Exception e)
            {
                Common.Exception(sim, e);
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Gibt ein Bild wieder frei
        /// </summary>
        /// <param name="imageId">ID des Bildes in der Datenbank</param>
        /// <returns>Void</returns>
        private void unlogImage(int imageId)
        {
            Motive bm = db.ImagesSet.OfType <Motive>().Where(p => p.Id == imageId).First();

            bm.readlock  = false;
            bm.writelock = false;

            db.SaveChanges();
        }
Ejemplo n.º 20
0
        protected void ForceSetMax(Motives ths, CommodityKind commodity)
        {
            Motive motive = ths.GetMotive(commodity);

            if ((motive != null) && (motive.Value != motive.Tuning.Max))
            {
                motive.UpdateMotiveBuffs(ths.mSim, commodity, (int)motive.Tuning.Max);
                motive.mValue = motive.Tuning.Max;
            }
        }
Ejemplo n.º 21
0
        public override Motive SaveViewModelToModel()
        {
            Motive initialModel = _motive;

            initialModel.TrackId   = _motive.TrackId;
            initialModel.Text      = Text;
            initialModel.Timestamp = DateTimeOffset.Now;

            return(initialModel);
        }
Ejemplo n.º 22
0
    public override void Interrupt(Motive motive)
    {
        if (routine == null)
        {
            return;
        }

        Routines.Stop(routine);
        routine = null;
    }
Ejemplo n.º 23
0
            public MotiveValue(MotiveID name, Motive value)
            {
                mName = Common.LocalizeEAString("Ui/Caption/HUD/MotivesPanel:Motive" + name.ToString());

                if (value != null)
                {
                    mValue  = (int)value.Value;
                    mExists = true;
                }
            }
Ejemplo n.º 24
0
            public MotiveValue(MotiveID name, Motive value)
            {
                mName = Common.LocalizeEAString("Ui/Caption/HUD/MotivesPanel:Motive" + name.ToString());

                if (value != null)
                {
                    mValue = (int)value.Value;
                    mExists = true;
                }
            }
Ejemplo n.º 25
0
 protected override bool SaveViewModel()
 {
     if (_motiveSelectionViewModel.ShouldSave)
     {
         saved       = true;
         Motive.Text = _motiveSelectionViewModel.SelectedMotiveOption.Id;
         Motive newMotive = Motive.SaveViewModelToModel();
         _repoManager.MotiveRepository.Add(newMotive);
     }
     return(_motiveSelectionViewModel.ShouldSave);
 }
Ejemplo n.º 26
0
 public void SetRestMotive(Motive motive)
 {
     if (motive.MotiveType() == Type.RestMotive)
     {
         m_EnergyScoreMotive = motive;
     }
     else
     {
         Debug.LogError("Rest Motive not assigned for LeaveMotive");
     }
 }
Ejemplo n.º 27
0
    public void Interrupt(Motive motive)
    {
        Buffer.isGameTurn = false;

        isActive = false;
        foreach (var activable in links)
        {
            activable.Deactivate();
        }

        Events.BreakValueRelay <SpellBase, bool>(GameEvent.OnSpellUsed, OnSpellUsed);
    }
Ejemplo n.º 28
0
 protected void Stop(Motive motive)
 {
     if (Target.IsBusy)
     {
         cachedMotive   = motive;
         Target.onFree += DelayedStop;
     }
     else
     {
         End(motive);
     }
 }
 public static void ConfirmAccuse(string CharacterAccused, string item1, string item2, Motive motive)
 {
     Debug.Log("Confirming Accuse");
         if (CheckPlayerWin(CharacterAccused, item1, item2, motive))
         {
             Application.LoadLevel("Framed" + CharacterAccused);
         }
         else
         {
             Application.LoadLevel("FramedPlayer");
         }
 }
Ejemplo n.º 30
0
            public MotiveValue(CommodityKind name, Motive value)
            {
                if (!Common.Localize("CommodityKind:" + name, false, new object[0], out mName))
                {
                    mName = name.ToString();
                }

                if (value != null)
                {
                    mValue = (int)value.Value;
                    mExists = true;
                }
            }
Ejemplo n.º 31
0
            public MotiveValue(CommodityKind name, Motive value)
            {
                if (!Common.Localize("CommodityKind:" + name, false, new object[0], out mName))
                {
                    mName = name.ToString();
                }

                if (value != null)
                {
                    mValue  = (int)value.Value;
                    mExists = true;
                }
            }
Ejemplo n.º 32
0
    public void Interrupt(Motive motive)
    {
        var handler = Repository.Get <RewardHandler>(References.Reward);

        handler.onHideStart -= OnHideStart;
        handler.onDone      -= OnDone;

        if (IsBusy)
        {
            return;
        }
        handler.Hide();
    }
Ejemplo n.º 33
0
        public AbstractMotiveViewModel(Motive motive, IMotiveConfiguration motiveConfiguration)
        {
            _motive = motive ?? throw new ArgumentNullException(nameof(motive));
            _motiveConfiguration = motiveConfiguration ?? throw new ArgumentNullException(nameof(motiveConfiguration));
            ResetViewModel();

            PropertyChanged += (sender, e) =>
            {
                if (e.PropertyName == nameof(Text))
                {
                    OnPropertyChanged(nameof(ConvertedText));
                }
            };
        }
Ejemplo n.º 34
0
        protected static void AlterDecay(Motive motive, bool freeze)
        {
            if (motive == null)
            {
                return;
            }

            if (freeze)
            {
                motive.FreezeDecay(true);
            }
            else
            {
                motive.RestoreDecay();
            }
        }
Ejemplo n.º 35
0
        public int?GetTotalDistancePerMotive(Motive motive)
        {
            QueryOptions <Ride> queryOptions = new QueryOptions <Ride>
            {
                Where = ride => ride.MotiveId == motive.MotiveId
            };
            IEnumerable <Ride> rides = _data.Rides.List(queryOptions);
            int?totalDistance        = 0;

            _helper.PopulateInitialMileage(rides);
            foreach (Ride ride in rides)
            {
                totalDistance += ride.GetDistance();
            }
            return(totalDistance);
        }
    private static bool CheckPlayerWin(string CharacterAccused, string item1, string item2, Motive motive)
    {
        bool accusedIsInList = false;

            if(mPlayerRef == null)
            {
                mPlayerRef = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<MainCharacter>();
            }

            foreach(NonPlayableCharacter character in Characters.Values)
            {
                if(character.CharacterSuspicion >= mPlayerRef.CharacterSuspicion - maxModifier && character.mCharacterName.ToString() == CharacterAccused)
                {
                    Debug.Log(character.mCharacterName + " has more suspicion than the player");
                    if(!charSuspicion.ContainsKey(character))
                        charSuspicion.Add(character, character.CharacterSuspicion);
                    if(!characters.ContainsKey(character.mCharacterName.ToString()))
                        characters.Add(character.mCharacterName.ToString(), character.CharacterSuspicion);
                }
            }

            foreach(var scopedCharacters in charSuspicion)
            {
                if(scopedCharacters.Key.mCharacterName.ToString() == CharacterAccused)
                {
                    accusedIsInList = true;
                    Debug.Log(scopedCharacters.Key.mCharacterName + " is the person being framed");
                    accusedCharacter = scopedCharacters.Key;
                }
            }

            if(!accusedIsInList)
                return false;

            var charComponent = GameManager.Instance.Characters[CharacterAccused];

            var npcComponent = charComponent as NonPlayableCharacter;

            if(npcComponent == null)
                return false;

            if(item1 == npcComponent.Item1.ToString() || item1 == npcComponent.Item2.ToString())
            {
                Debug.Log(accusedCharacter.mCharacterName + ": matched the first item, 5 points!");
                accusedCharacter.ModifySuspicion(item1Modifier);
            }
            else
            {
                mPlayerRef.ModifySuspicion(item1Modifier);
            }

            if(item2 == npcComponent.Item1.ToString() || item2 == npcComponent.Item2.ToString())
            {
                Debug.Log(accusedCharacter.mCharacterName + ": matched the second item, 5 points!");
                accusedCharacter.ModifySuspicion(item2Modifier);
            }
            else
            {
                mPlayerRef.ModifySuspicion(item2Modifier);
            }

            if(motive == npcComponent.mCharacterMotive)
            {
                Debug.Log(accusedCharacter.mCharacterName + ": matched the motive, 10 points!");
                accusedCharacter.ModifySuspicion(motiveModifier);
            }
            else
            {
                mPlayerRef.ModifySuspicion(motiveModifier);
            }

            if(mPlayerRef.CharacterSuspicion < accusedCharacter.CharacterSuspicion)
            {
                return true;
            }
            else
            {
                return false;
            }
    }
    //****************************************************************************
    //****************************************************************************
    void Start()
    {
        //mDoors = GameObject.FindGameObjectsWithTag("Door");
        var body = gameObject.AddComponent<Rigidbody>();
        body.isKinematic = true;
        body.useGravity = false;
        GameObject temp = GameObject.FindGameObjectWithTag("MainCamera");
        if(temp != null)
        {
            characterRef = temp.GetComponentInChildren<MainCharacter>();
        }
        base.Start();
        mCharacterMotive        = MotiveManager.GetMotive(mCharacterName);
        mConversationRef        = gameObject.GetComponent<Conversation>();
        //Debug.Log(gameObject.name + " Conversation status: " + mConversationRef);
        mNavController          = gameObject.GetComponent<Navigation>();

        GameManager.Instance.RegisterMotive(mCharacterName.ToString(),mCharacterMotive);
        GameManager.Instance.SpawnItem(Item1);
        GameManager.Instance.SpawnItem(Item2);
        mCaught1 = Conversation.LoadConvo(mCaughtItem1Convo);
        mCaught2 = Conversation.LoadConvo(mCaughtItem2Convo);
        mDefault = Conversation.LoadConvo(mDefaultConvo);
        DiarySpawner.SpawnDiary(mCharacterName.ToString());
        Inputbase.Instance.OnActionButtonPressedHandle += StartConverstaion;
        mAnimationRef = GetComponentInChildren<Animation>();

        if(gameObject.GetComponent<AccusePlayerInteraction>() != null)
        {
            mAnimationRef.Play(mIdleAnimation);
        }
        else
            mAnimationRef.Play(mWalkAnimation);
        //Debug.Log("Animation ref status: " + mAnimationRef);
    }
 public void RegisterMotive(string NPCName, Motive motive)
 {
     if (!motives.ContainsKey(NPCName)) motives.Add(NPCName, motive);
 }
 static void Init()
 {
     MotiveEditor window = GetWindow<MotiveEditor>();
     window.maxSize = new Vector2(250,300);
     mCurrentMotive = new Motive();
 }