public static void AddHomeworld(this Character character, HomeWorld homeworld)
 {
     character.HomeWorld    = homeworld;
     character.FateTreshold = homeworld.FateTreshold;
     character.TotalWounds  = homeworld.Wounds;
     character.Aptitudes.Add(homeworld.HomeWorldAptitude);
 }
예제 #2
0
 private void OnLoadCharacter(object obj)
 {
     if (SelectedCharacter != null)
     {
         OpenedCharacter = SelectedCharacter;
         if (SelectedCharacter.HomeWorld == null)
         {
             Window homeWorldWindow = new HomeWorld();
             homeWorldWindow.Show();
             return;
         }
         if (SelectedCharacter.Background == null)
         {
             Window backgroundWindow = new Background();
             backgroundWindow.Show();
             return;
         }
         if (SelectedCharacter.Role == null)
         {
             Window roleWindow = new Role();
             roleWindow.Show();
             return;
         }
         Window characterSheet = new CharacterSheetView();
         characterSheet.Show();
         Window currentWindow = obj as Window;
         currentWindow.Close();
     }
 }
 /// <summary>
 /// Reads the JSON representation exemplar of the HomeWorld class.
 /// </summary>
 /// <param name="writer">The <see cref="T:Newtonsoft.Json.JsonWriter" /> to read from.</param>
 /// <param name="value">Value of object that being write</param>
 /// <param name="serializer">The calling serializer.</param>
 public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
 {
     if (value != null)
     {
         HomeWorld homeworld = value as HomeWorld;
         writer.WriteValue(homeworld.Name);
     }
 }
예제 #4
0
        public static HomeWorld Map(PlanetApi planetApi)
        {
            HomeWorld result = new HomeWorld();

            if (planetApi != null)
            {
                result.name                  = planetApi.name;
                result.population            = planetApi.population;
                result.known_residents_count = planetApi.residents.Count().ToString();
            }

            return(result);
        }
예제 #5
0
        //Homeworlds
        public static List <HomeWorld> PopulateHomeWorlds()
        {
            var FeralWorld = new HomeWorld(1, "FeralWorld", "A feral world", 9, Constants.T);

            FeralWorld.StatsAffectedPositive.Add(Constants.Str);
            FeralWorld.StatsAffectedPositive.Add(Constants.T);
            FeralWorld.StatsAffectedNegative.Add(Constants.Inte);
            HomeWorlds.Add(FeralWorld);

            var HiveWorld = new Characters.HomeWorlds.HomeWorld(2, "HiveWorld", "A hive world", 8, Constants.Per);

            HiveWorld.StatsAffectedPositive.Add(Constants.Ag);
            HiveWorld.StatsAffectedPositive.Add(Constants.Per);
            HiveWorld.StatsAffectedNegative.Add(Constants.Wp);
            HomeWorlds.Add(HiveWorld);

            var HighBorn = new Characters.HomeWorlds.HomeWorld(3, "HighBorn", "A High Born from an ecclessiarchal world.", 9, Constants.Fel);

            HighBorn.StatsAffectedPositive.Add(Constants.Fel);
            HighBorn.StatsAffectedPositive.Add(Constants.Ifl);
            HighBorn.StatsAffectedNegative.Add(Constants.T);
            HomeWorlds.Add(HighBorn);


            var ForgeWorld = new Characters.HomeWorlds.HomeWorld(4, "ForgeWorld", "An industrial forge world", 8, Constants.Inte);

            ForgeWorld.StatsAffectedPositive.Add(Constants.Inte);
            ForgeWorld.StatsAffectedPositive.Add(Constants.T);
            ForgeWorld.StatsAffectedNegative.Add(Constants.Fel);
            HomeWorlds.Add(ForgeWorld);

            var ShrineWorld = new Characters.HomeWorlds.HomeWorld(5, "ShrineWorld", "A shrine world", 7, Constants.Wp);

            ShrineWorld.StatsAffectedPositive.Add(Constants.Fel);
            ShrineWorld.StatsAffectedPositive.Add(Constants.Wp);
            ShrineWorld.StatsAffectedNegative.Add(Constants.Per);
            HomeWorlds.Add(ShrineWorld);

            var VoidBorn = new Characters.HomeWorlds.HomeWorld(6, "VoidBorn", "A void-born", 7, Constants.Inte);

            VoidBorn.StatsAffectedPositive.Add(Constants.Inte);
            VoidBorn.StatsAffectedPositive.Add(Constants.Wp);
            VoidBorn.StatsAffectedNegative.Add(Constants.Str);
            HomeWorlds.Add(VoidBorn);
            return(HomeWorlds);
        }
예제 #6
0
파일: Agent.cs 프로젝트: Kopachelli/Indigo
        /// <summary>
        /// ITypicalAgent
        /// </summary>
        public virtual void StateRecompute()
        {
            logger.Trace("Base state recomputing for {0}", this);

            PerformFeedback();
            CurrentState.Reduct();

            if (CurrentState.Health.CurrentUnitValue == this.CurrentState.Health.MinValue)
            {
                HomeWorld.AskWorldForEuthanasia(this);
            }
            foreach (ActionAbstract act in CurrentVision.CurrentViewActions)
            {
                CurrentMemory.StoreAction(act.Subject, act);
            }

            logger.Debug("Base state recomputed for {0}", this.Name);
            logger.Trace("{0}", this);
        }
예제 #7
0
        private void OnNewCharacter(object obj)
        {
            Character newCharacter = new Character();

            try
            {
                CharactersList.Characters.Add(newCharacter);
                CharactersList.CharactersIO.SaveData(CharactersList.Characters);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                Application.Current.Shutdown();
            }
            OpenedCharacter = newCharacter;
            Window homeWorldWindow = new HomeWorld();

            homeWorldWindow.Show();
        }
예제 #8
0
        private void OnEventReceived(SeerEvent seerEvent)
        {
            try
            {
                // make sure it's valid to begin with and from a backend.
                if (!seerEvent.IsValid() || 10 > (int)seerEvent.EventSource)
                {
                    return;
                }

                seerEvent.Game = this;

                // pass exceptions up immediately
                if (seerEvent is BackendExceptionEvent backendExceptionEvent)
                {
                    BmpSeer.Instance.PublishEvent(backendExceptionEvent);
                    return;
                }

                // deduplicate if needed
                if (seerEvent.DedupeThreshold > 0)
                {
                    if (_eventDedupeHistory.ContainsKey(seerEvent.EventType) && _eventDedupeHistory[seerEvent.EventType] + seerEvent.DedupeThreshold >= seerEvent.TimeStamp)
                    {
                        return;
                    }
                    _eventDedupeHistory[seerEvent.EventType] = seerEvent.TimeStamp;
                }

                switch (seerEvent)
                {
                case ActorIdChanged actorId:
                    if (ActorId != actorId.ActorId)
                    {
                        ActorId = actorId.ActorId;
                        BmpSeer.Instance.PublishEvent(actorId);
                    }
                    break;

                case ChatLog chatLogEvent:
                    // Currently unused.
                    break;

                case ChatStatusChanged chatStatus:
                    if (ChatStatus != chatStatus.ChatStatus)
                    {
                        ChatStatus = chatStatus.ChatStatus;
                        BmpSeer.Instance.PublishEvent(chatStatus);
                    }
                    break;

                case ConfigIdChanged configId:
                    if (!ConfigId.Equals(configId.ConfigId))
                    {
                        ConfigId = configId.ConfigId;
                        BmpSeer.Instance.PublishEvent(configId);
                    }
                    break;

                case EnsembleRejected ensembleRejected:
                    BmpSeer.Instance.PublishEvent(ensembleRejected);
                    break;

                case EnsembleRequested ensembleRequested:
                    BmpSeer.Instance.PublishEvent(ensembleRequested);
                    break;

                case EnsembleStarted ensembleStarted:
                    BmpSeer.Instance.PublishEvent(ensembleStarted);
                    break;

                // Currently unused. Currently unavailable from Machina backend.
                // case EnsembleStopped ensembleStopped:
                //    Seer.Instance.PublishEvent(ensembleStopped);
                //    break;

                case InstrumentHeldChanged instrumentHeld:
                    if (!InstrumentHeld.Equals(instrumentHeld.InstrumentHeld))
                    {
                        InstrumentHeld = instrumentHeld.InstrumentHeld;
                        BmpSeer.Instance.PublishEvent(instrumentHeld);
                    }
                    break;

                case IsBardChanged isBard:
                    if (IsBard != isBard.IsBard)
                    {
                        IsBard = isBard.IsBard;
                        BmpSeer.Instance.PublishEvent(isBard);
                    }
                    break;

                case KeyMapChanged keyMap:
                    if (!NavigationMenuKeys.Equals(keyMap.NavigationMenuKeys) ||
                        !InstrumentToneMenuKeys.Equals(keyMap.InstrumentToneMenuKeys) ||
                        !InstrumentKeys.Equals(keyMap.InstrumentKeys) ||
                        !InstrumentToneKeys.Equals(keyMap.InstrumentToneKeys) ||
                        !NoteKeys.Equals(keyMap.NoteKeys))
                    {
                        NavigationMenuKeys     = keyMap.NavigationMenuKeys;
                        InstrumentToneMenuKeys = keyMap.InstrumentToneMenuKeys;
                        InstrumentKeys         = keyMap.InstrumentKeys;
                        InstrumentToneKeys     = keyMap.InstrumentToneKeys;
                        NoteKeys = keyMap.NoteKeys;
                        BmpSeer.Instance.PublishEvent(keyMap);
                    }
                    break;

                case PartyMembersChanged partyMembers:
                    if (!PartyMembers.KeysEquals(partyMembers.PartyMembers))
                    {
                        PartyMembers = partyMembers.PartyMembers;
                        BmpSeer.Instance.PublishEvent(partyMembers);
                    }
                    break;

                case PlayerNameChanged playerName:
                    if (!PlayerName.Equals(playerName.PlayerName))
                    {
                        PlayerName = playerName.PlayerName;
                        BmpSeer.Instance.PublishEvent(playerName);
                    }
                    break;

                case HomeWorldChanged homeWorld:
                    if (!HomeWorld.Equals(homeWorld.HomeWorld))
                    {
                        HomeWorld = homeWorld.HomeWorld;
                        BmpSeer.Instance.PublishEvent(homeWorld);
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                BmpSeer.Instance.PublishEvent(new GameExceptionEvent(this, Pid, ex));
            }
        }
예제 #9
0
파일: Agent.cs 프로젝트: Kopachelli/Indigo
        /// <summary>
        /// Calculate the best decision of action to satisfy need
        /// </summary>
        /// <param name="argNeed">need, that must be satisfied</param>
        protected virtual void MakeAction(Need argNeed)
        {
            Exception      worldResponseToAction = new Exception(); //World response if the action is accepted.
            ActionAbstract newAction             = null;            //New action to create

            if (argNeed.SatisfyingActions.Count == 0)
            {
                logger.Error("Number of Action to satisfy need {0} is 0", argNeed);
                return;
            }

            foreach (Type act in argNeed.SatisfyingActions)
            {
                Attribute actionInfo = Attribute.GetCustomAttribute(act, typeof(ActionInfoAttribute));                  // getting attributes for this class
                if (actionInfo == null)
                {
                    logger.Error("Failed to get action info attribute for {0}", act.GetType());
                    return;
                }
                ActionInfoAttribute currentInfo = actionInfo as ActionInfoAttribute;                 //Converting attribute to ActionInfo

                if (currentInfo.RequiresObject)
                {
                    foreach (Agent ag in Inventory.ItemList.Concat(CurrentVision.CurrentViewAgents))
                    {
                        if (!currentInfo.AcceptedObjects.Contains(ag.GetType()))
                        {
                            continue;
                        }
                        if (Distance(this, ag) > Math.Sqrt(2))
                        {
                            actionInfo = Attribute.GetCustomAttribute(typeof(ActionGo), typeof(ActionInfoAttribute));                              // getting attributes for this class
                            if (actionInfo == null)
                            {
                                logger.Error("Failed to get action info attribute for ActionGo");
                                return;
                            }
                            currentInfo           = actionInfo as ActionInfoAttribute;
                            newAction             = ActionsManager.GetActionForCurrentParticipants(typeof(ActionGo), currentInfo, this, null, ag.CurrentLocation.Coords);
                            worldResponseToAction = HomeWorld.AskWorldForAction(newAction);
                            if (worldResponseToAction == null)
                            {
                                break;
                            }
                        }
                        newAction             = ActionsManager.GetActionForCurrentParticipants(act, currentInfo, this, ag);
                        worldResponseToAction = HomeWorld.AskWorldForAction(newAction);
                        if (worldResponseToAction == null)
                        {
                            break;
                        }
                    }
                }
                else
                {
                    newAction             = ActionsManager.GetActionForCurrentParticipants(act, currentInfo, this, null);
                    worldResponseToAction = HomeWorld.AskWorldForAction(newAction);
                }

                if (worldResponseToAction == null)
                {
                    logger.Debug("Made action for {0}: {1}", this.Name, newAction.Name);
                    break;
                }
            }
        }
예제 #10
0
 public Character()
 {
     homeworld = new HomeWorld();
 }