예제 #1
0
        public static void RetrieveBasicDataEvent(Client player, Client target)
        {
            // Get the basic data
            string age   = target.GetData(EntityData.PLAYER_AGE) + GenRes.years;
            string sex   = target.GetData(EntityData.PLAYER_SEX) == Constants.SEX_MALE ? GenRes.sex_male : GenRes.sex_female;
            string money = target.GetSharedData(EntityData.PLAYER_MONEY) + "$";
            string bank  = target.GetSharedData(EntityData.PLAYER_BANK) + "$";
            string job   = GenRes.unemployed;
            string rank  = string.Empty;

            // Get the job
            JobModel jobModel = Constants.JOB_LIST.Where(j => target.GetData(EntityData.PLAYER_JOB) == j.job).First();

            if (jobModel.job == 0)
            {
                // Get the player's faction
                FactionModel factionModel = Constants.FACTION_RANK_LIST.Where(f => target.GetData(EntityData.PLAYER_FACTION) == f.faction && target.GetData(EntityData.PLAYER_RANK) == f.rank).First();

                if (factionModel.faction > 0)
                {
                    switch (factionModel.faction)
                    {
                    case Constants.FACTION_POLICE:
                        job = GenRes.police_faction;
                        break;

                    case Constants.FACTION_EMERGENCY:
                        job = GenRes.emergency_faction;
                        break;

                    case Constants.FACTION_NEWS:
                        job = GenRes.news_faction;
                        break;

                    case Constants.FACTION_TOWNHALL:
                        job = GenRes.townhall_faction;
                        break;

                    case Constants.FACTION_TAXI_DRIVER:
                        job = GenRes.transport_faction;
                        break;

                    case Constants.FACTION_SHERIFF:
                        job = GenRes.sheriff_faction;
                        break;
                    }

                    // Set player's rank
                    rank = target.GetData(EntityData.PLAYER_SEX) == Constants.SEX_MALE ? factionModel.descriptionMale : factionModel.descriptionFemale;
                }
            }
            else
            {
                // Set the player's job
                job = target.GetData(EntityData.PLAYER_SEX) == Constants.SEX_MALE ? jobModel.descriptionMale : jobModel.descriptionFemale;
            }

            // Show the data for the player
            player.TriggerEvent("showPlayerData", target.Value, target.Name, age, sex, money, bank, job, rank, player == target || player.GetData(EntityData.PLAYER_ADMIN_RANK) > Constants.STAFF_NONE);
        }
예제 #2
0
        public SystemHistoryViewModel(Int64 systemAddress, List <DESystemsForDisplay> deSystemsForDisplay)
        {
            _displayDESystems = deSystemsForDisplay;

            DeLogo    = helper.Convert(DETrackerWPF.Properties.Resources.DELogo);
            Info      = helper.Convert(DETrackerWPF.Properties.Resources.InfoBlue);
            Analytics = helper.Convert(DETrackerWPF.Properties.Resources.analytics);
            EliteBGS  = helper.Convert(DETrackerWPF.Properties.Resources.EliteBGS);

            DESystemsForDisplay selectedSystem = dataAccess.ReadUpdatedSystem(systemAddress.ToString());

            ActiveStarSystem = selectedSystem.StarSystem;
            DisplayHistoryData(selectedSystem, "");

            //if (selectedSystem.SysFaction == null)
            //{
            //  selectedSystem.SysFaction = new SystemFaction();
            //  selectedSystem.SysFaction.Name = string.Empty;
            //}

            HeaderSummary = string.Format("Star System: {0} | Population: {1:###,###,###,###} | Controlling Faction: {2} | Government: {3}\r\nAlligence: {4} | Economies: {5} | Security: {6}",
                                          selectedSystem.StarSystem,
                                          selectedSystem.Population,
                                          selectedSystem.SysFaction.Name, Helper.Clean(selectedSystem.SystemGovernment),
                                          selectedSystem.SystemAllegiance, Helper.Clean(selectedSystem.SystemEconomy) + "/" + Helper.Clean(selectedSystem.SystemSecondEconomy), Helper.Clean(selectedSystem.SystemSecurity));

            // var FactionsInSystem = selectedSystem.FactionHistory[selectedSystem.FactionHistory.Count - 1].Factions.Count;


            Factions.Clear();
            foreach (FullFactionData Faction in selectedSystem.FactionHistory[selectedSystem.FactionHistory.Count - 1].Factions)
            {
                // Dump Pilots' Federation Local Branch
                if (Faction.Name.Contains("Federation Local Branch"))
                {
                    continue;
                }



                FactionModel f = new FactionModel();
                f.FactionName           = Faction.Name;
                f.GovernmentaAllegiance = Faction.Government + " / " + Faction.Allegiance;

                Faction1         = new ObservableCollection <SystemsFactionsHistory>(SystemHistory.Where(x => x.FactionName == Faction.Name));
                f.FactionHistory = new ObservableCollection <DisplayFactionHist>(BuildHistory(Faction1));

                Factions.Add(f);

                // Sort the Headers
                FactionHeadersModel fh = new FactionHeadersModel();
                fh.InfHeader   = "Inf";
                fh.ChgHeader   = "Chg";
                fh.StateHeader = "Active States";
                FactionHeaders.Add(fh);
            }

            // Reverse the faction list so Dark Echo are the first column
            Factions.Reverse();
        }
예제 #3
0
    public void DisplayBenefits(string factionName)
    {
        FactionModel model = AmbitionApp.GetModel <FactionModel>();
        string       str   = "The " + factionName + "(Level " + model[factionName].Level.ToString() + ")\n";

        str      += model.GetFactionBenefits(factionName);
        text.text = str;
    }
예제 #4
0
 public static void Patch(this FactionModel factionModel, Faction faction, UserModel user)
 {
     if (factionModel == null)
     {
         return;
     }
     factionModel.Name = faction.Name;
     factionModel.Patch(user);
 }
예제 #5
0
    void DisplayButton()
    {
        FactionModel model = AmbitionApp.GetModel <FactionModel>();

        if (infoType == InfoType.Allegiance)
        {
            if (model[faction].Level >= 8)
            {
                text.text   = "";
                image.color = Color.clear;
            }
            else
            {
                if (textController.availableSpymasterTestTheWaters)
                {
                    text.text   = "Learn Current Allegiance (Spymaster - Free!)";
                    image.color = Color.white;
                }
                else if (textController.availableTestTheWaters && GameData.moneyCount >= textController.testTheWatersCost)
                {
                    text.text   = "Learn Current Allegiance (£" + textController.testTheWatersCost + ")";
                    image.color = Color.white;
                }
                else
                {
                    text.text   = "Learn Current Allegiance (£" + textController.testTheWatersCost + ")";
                    image.color = Color.gray;
                }
            }
        }
        else
        {
            if (model[faction].Level >= 6)
            {
                text.text   = "";
                image.color = Color.clear;
            }
            else
            {
                if (textController.availableSpymasterTestTheWaters)
                {
                    text.text   = "Learn Current Power (Spymaster - Free!)";
                    image.color = Color.white;
                }
                else if (textController.availableTestTheWaters && GameData.moneyCount >= textController.testTheWatersCost)
                {
                    text.text   = "Learn Current Power (£" + textController.testTheWatersCost + ")";
                    image.color = Color.white;
                }
                else
                {
                    text.text   = "Learn Current Power (£" + textController.testTheWatersCost + ")";
                    image.color = Color.gray;
                }
            }
        }
    }
예제 #6
0
        private void RpgInit()
        {
            //Debug.LogWarning(nameof(RpgInit));

            //TODO better debugging and logging

            //load initial player
            try
            {
                InitializePlayer();
            }
            catch (Exception e)
            {
                Debug.LogError("Failed to load initial player");
                Debug.LogException(e);
            }

            //hookup factions
            try
            {
                FactionState = FactionModel.CloneFactionModel(FactionModel.BaseModel);
            }
            catch (Exception e)
            {
                Debug.LogError("Failed to load faction model");
                Debug.LogException(e);
            }

            //load initial containers (requires some decoding)
            //we will actually need to load additional containers ex post facto when we add mod support
            try
            {
                var rawContainers = CoreUtils.LoadJson <Dictionary <string, SerializableContainerModel> >(CoreUtils.LoadResource <TextAsset>("Data/RPGDefs/init_containers").text);
                foreach (var key in rawContainers.Keys)
                {
                    var value = rawContainers[key];
                    try
                    {
                        var realContainer = SerializableContainerModel.MakeContainerModel(value);
                        instance.ContainerState.Add(key, realContainer);
                    }
                    catch (Exception e)
                    {
                        Debug.LogError("Failed to load one container");
                        Debug.LogException(e);
                    }
                }
            }
            catch (Exception e)
            {
                Debug.LogError("Failed to load initial container state");
                Debug.LogException(e);
            }

            instance.InitialLoaded = true;
        }
예제 #7
0
        public static void Patch(this CardModel cardModel, Card card,
                                 SerieModel serieModel, FactionModel factionModel, CardTypeModel cardTypeModel, StatusModel statusModel, RuleSetModel ruleSetModel, LicenseModel artworkLicense, UserModel user)
        {
            if (cardModel == null)
            {
                return;
            }
            if (card == null)
            {
                return;
            }
            cardModel.Name            = card.Name;
            cardModel.FirstName       = card.FirstName;
            cardModel.LastName        = card.LastName;
            cardModel.Artist          = card.Artist;
            cardModel.ArtworkLicensor = card.ArtworkLicensor;
            cardModel.RuleText        = card.RuleText;
            cardModel.FlavorText      = card.FlavorText;
            cardModel.SubType         = card.SubType;
            cardModel.Cost            = card.Cost;
            cardModel.Loyalty         = card.Loyalty;
            cardModel.Attack          = card.Attack;
            cardModel.Defense         = card.Defense;
            cardModel.Info            = card.Info;
            cardModel.MarkdownText    = card.MarkdownText;
            cardModel.LanguageCode    = card.Language?.LanguageCode ?? "en";


            if (serieModel != null)
            {
                cardModel.Serie = serieModel;
            }
            if (factionModel != null)
            {
                cardModel.Faction = factionModel;
            }
            if (cardTypeModel != null)
            {
                cardModel.Type = cardTypeModel;
            }
            if (statusModel != null)
            {
                cardModel.Status = statusModel;
            }
            if (ruleSetModel != null)
            {
                cardModel.RuleSet = ruleSetModel;
            }
            if (artworkLicense != null)
            {
                cardModel.ArtworkLicense = artworkLicense;
            }

            cardModel.PatchBase(user);
        }
예제 #8
0
 public bool BordersEnemy(FactionModel faction)
 {
     foreach (HexModel neighbor in Neighbors)
     {
         if (neighbor.ContainsEnemy(faction))
         {
             return(true);
         }
     }
     return(false);
 }
예제 #9
0
        public RpgModule()
        {
            LoadGameParams();

            FactionModel.Load();
            InventoryModel.Load();
            QuestModel.Load();

            //install gameplay config panel
            ConfigModule.Instance.RegisterConfigPanel("GameplayOptionsPanel", 500, CoreUtils.LoadResource <GameObject>("UI/GameplayOptionsPanel"));
        }
예제 #10
0
        public static string GetPlayerFactionRank(Client player)
        {
            string rankString = string.Empty;
            int    faction    = player.GetData(EntityData.PLAYER_FACTION);
            int    rank       = player.GetData(EntityData.PLAYER_RANK);

            // Get the player faction
            FactionModel factionModel = Constants.FACTION_RANK_LIST.Where(fact => fact.faction == faction && fact.rank == rank).FirstOrDefault();

            return(factionModel == null ? string.Empty : (player.GetData(EntityData.PLAYER_SEX) == Constants.SEX_MALE ? factionModel.descriptionMale : factionModel.descriptionFemale));
        }
예제 #11
0
        public static Faction FromDal(this FactionModel factionModel)
        {
            if (factionModel == null)
            {
                return(null);
            }
            var result = new Faction
            {
                Id   = factionModel.FactionId,
                Name = factionModel.Name
            };

            return(result.SyncBase(factionModel));
        }
예제 #12
0
        public static List <FactionModel> CreateAllFactionsForEdit(List <object[]> data)
        {
            List <FactionModel> items = new List <FactionModel>();

            foreach (var row in data)
            {
                FactionModel item = new FactionModel
                {
                    Id   = row[0].ConvertTo <int>(),
                    Name = row[1].ConvertTo <string>()
                };
                items.Add(item);
            }
            return(items);
        }
예제 #13
0
 public static void Patch(this CardModel cardModel, Card card,
                          SerieModel serieModel, FactionModel factionModel, CardTypeModel cardTypeModel, StatusModel statusModel, RuleSetModel ruleSetModel, UserModel user)
 {
     if (cardModel == null)
     {
         return;
     }
     if (card == null)
     {
         return;
     }
     cardModel.Name       = card.Name;
     cardModel.FirstName  = card.FirstName;
     cardModel.LastName   = card.LastName;
     cardModel.Artist     = card.Artist;
     cardModel.RuleText   = card.RuleText;
     cardModel.FlavorText = card.FlavorText;
     cardModel.SubType    = card.SubType;
     cardModel.Cost       = card.Cost;
     cardModel.Loyalty    = card.Loyalty;
     cardModel.Attack     = card.Attack;
     cardModel.Defense    = card.Defense;
     cardModel.Info       = card.Info;
     cardModel.LayoutText = card.LayoutText;
     if (serieModel != null)
     {
         cardModel.Serie = serieModel;
     }
     if (factionModel != null)
     {
         cardModel.Faction = factionModel;
     }
     if (cardTypeModel != null)
     {
         cardModel.Type = cardTypeModel;
     }
     if (statusModel != null)
     {
         cardModel.Status = statusModel;
     }
     if (ruleSetModel != null)
     {
         cardModel.RuleSet = ruleSetModel;
     }
     cardModel.Patch(user);
 }
예제 #14
0
        void CollectEntities()
        {
            // Incidents already taken care of
            FactionModel factions = AmbitionApp.GetModel <FactionModel>();

            _entities["factions"]  = new ConsoleEntity(factions);
            _entities["game"]      = new ConsoleEntity(AmbitionApp.GetModel <GameModel>());
            _entities["calendar"]  = new ConsoleEntity(AmbitionApp.GetModel <CalendarModel>());
            _entities["inventory"] = new ConsoleEntity(AmbitionApp.GetModel <InventoryModel>());

            foreach (FactionVO faction in factions.Factions.Values)
            {
                _entities["faction." + faction.Type.ToString().ToLower()] =
                    new ConsoleEntity(faction, (args) => InvokeFaction(faction, args));
            }

            _entities["uflow"]      = new ConsoleEntity(AmbitionApp.GetService <UFlowSvc>());
            _entities["servants"]   = new ConsoleEntity(AmbitionApp.GetModel <ServantModel>());
            _entities["characters"] = new ConsoleEntity(AmbitionApp.GetModel <CharacterModel>());
        }
예제 #15
0
        public FactionModel CreateFaction(string name, Guid guid)
        {
            var faction = Context.Factions.FindByGuid(guid);

            if (faction == null)
            {
                var utcNow = DateTime.UtcNow;
                faction = new FactionModel
                {
                    Name             = name,
                    Guid             = guid,
                    LastModifiedTime = utcNow,
                    CreateTime       = utcNow,
                    Creator          = ServiceUser,
                    LastModifiedBy   = ServiceUser
                };
                Context.Factions.Add(faction);
                Context.SaveChanges();
            }
            return(faction);
        }
예제 #16
0
    public Sprite GetSpriteByFaction(FactionModel faction)
    {
        Sprite factionSprite = Resources.Load(faction.FactionImgUrl) as Sprite;

        return(factionSprite);
    }
예제 #17
0
        public void TakeDamage(ActorHitInfo data)
        {
            if (!data.HarmFriendly)
            {
                string hitFaction = data.OriginatorFaction;
                if (!string.IsNullOrEmpty(hitFaction))
                {
                    FactionRelationStatus relation = FactionModel.GetRelation(hitFaction, Faction); //this looks backwards but it's because we're checking if the Bullet is-friendly-to the Actor
                    if (relation == FactionRelationStatus.Friendly)
                    {
                        return; //no friendly fire
                    }
                }
            }

            //damage model is very stupid right now, we will make it better later
            float dt          = data.DamageType < DamageThreshold.Length ? DamageThreshold[(int)data.DamageType] : 0f;
            float dr          = data.DamageType < DamageThreshold.Length ? DamageResistance[(int)data.DamageType] : 0f;
            float damageTaken = RpgValues.DamageTaken(data.Damage, data.DamagePierce, dt, dr);

            if (data.HitLocation == (int)ActorBodyPart.Head)
            {
                damageTaken *= 2.0f;
            }
            else if (data.HitLocation == (int)ActorBodyPart.LeftArm || data.HitLocation == (int)ActorBodyPart.LeftLeg || data.HitLocation == (int)ActorBodyPart.RightArm || data.HitLocation == (int)ActorBodyPart.RightLeg)
            {
                damageTaken *= 0.75f;
            }

            damageTaken *= (1f / ConfigState.Instance.GetGameplayConfig().Difficulty.ActorStrength);

            if (!Invincible)
            {
                Health -= damageTaken;
            }

            if (CurrentAiState == ActorAiState.Dead) //abort if we're already dead
            {
                return;
            }

            bool didTakePain = UnityEngine.Random.Range(0f, 1f) < PainChance; //shouldn't this be weighted by damage?

            if (Defensive && data.Originator != null && data.Originator != this)
            {
                FactionRelationStatus relation = FactionRelationStatus.Neutral;
                if (data.Originator is PlayerController)
                {
                    relation = FactionModel.GetRelation(Faction, "Player");
                }
                else if (data.Originator is ActorController)
                {
                    relation = FactionModel.GetRelation(Faction, ((ActorController)data.Originator).Faction);
                }

                if (relation != FactionRelationStatus.Friendly || Infighting)
                {
                    Target  = data.Originator.transform;
                    BeenHit = true;

                    if (DisableInteractionOnHit && InteractionComponent != null)
                    {
                        InteractionComponent.InteractionDisabledByHit = true;
                    }

                    if (FeelPain && didTakePain)
                    {
                        if (CurrentAiState != ActorAiState.Hurting)
                        {
                            EnterState(ActorAiState.Hurting);
                        }
                        else
                        {
                            EnterState(ActorAiState.Chasing);
                        }
                    }
                }
                else if (CurrentAiState != ActorAiState.Hurting)
                {
                    EnterState(ActorAiState.Hurting);
                }
            }
            else if (FeelPain && didTakePain && CurrentAiState != ActorAiState.Hurting)
            {
                EnterState(ActorAiState.Hurting);
            }
        }
예제 #18
0
    // Use this for initialization
    void Start()
    {
        FactionModel Imperium = new FactionModel()
        {
            FactionColor      = new Color(.1f, .5f, .1f),
            FactionName       = "Imperium of Man",
            MainPlayerFaction = true,
        };

        FactionModel KimernaPdf = new FactionModel()
        {
            FactionColor = new Color(.5f, .5f, .8f),
            FactionName  = "Kimerna PDF",
        };

        FactionModel ChaosRaiders = new FactionModel()
        {
            FactionColor = new Color(.9f, .1f, .1f),
            FactionName  = "Chaos Raiders",
        };

        Imperium.Allies = new List <FactionModel>()
        {
            KimernaPdf
        };
        Imperium.Enemies = new List <FactionModel>()
        {
            ChaosRaiders
        };

        KimernaPdf.Allies = new List <FactionModel>()
        {
            Imperium
        };
        KimernaPdf.Enemies = new List <FactionModel>()
        {
            ChaosRaiders
        };

        ChaosRaiders.Allies = new List <FactionModel>()
        {
        };
        ChaosRaiders.Enemies = new List <FactionModel>()
        {
            KimernaPdf, Imperium
        };

        HexModel[][] Galaxy = new HexModel[][]
        {
            new [] { SpaceHex, SpaceHex, SpaceHex, SpaceHex, SpaceHex, SpaceHex, SpaceHex, SpaceHex, SpaceHex, SpaceHex },
            new [] { SpaceHex, SpaceHex, SpaceHex, SpaceHex, SpaceHex, SpaceHex, SpaceHex, SpaceHex, SpaceHex, SpaceHex },
            new [] { SpaceHex, SpaceHex, SpaceHex, SpaceHex, SpaceHex, SpaceHex, SpaceHex, SpaceHex, SpaceHex, SpaceHex },
            new [] { SpaceHex, SpaceHex, SpaceHex, SpaceHex, SpaceHex, SpaceHex, SpaceHex, SpaceHex, SpaceHex, SpaceHex },
            new [] { SpaceHex, SpaceHex, WarpStormHex, SpaceHex, WarpStormHex, WarpStormHex, SpaceHex, SpaceHex, WarpStormHex, SpaceHex },
            new [] { SpaceHex, WarpStormHex, WarpStormHex, SpaceHex, SpaceHex, SpaceHex, SpaceHex, SpaceHex, WarpStormHex, SpaceHex },
            new [] { SpaceHex, WarpStormHex, WarpStormHex, SpaceHex, SpaceHex, SpaceHex, SpaceHex, WarpStormHex, WarpStormHex, SpaceHex },
        };

        HexModel[][] KimernaMap = new HexModel[][]
        {
            new[] { ForestHex, ForestHex, GrassHex, GrassHex, GrassHex, OceanHex, OceanHex },
            new[] { ForestHex, ForestHex, GrassHex, GrassHex, GrassHex, OceanHex, OceanHex },
            new[] { ForestHex, GrassHex, CityHex, GrassHex, ForestHex, ForestHex, OceanHex },
            new[] { GrassHex, GrassHex, CityHex, GrassHex, ForestHex, ForestHex, OceanHex },
            new[] { GrassHex, GrassHex, GrassHex, GrassHex, GrassHex, ForestHex, OceanHex },
            new[] { GrassHex, ForestHex, GrassHex, GrassHex, CityHex, OceanHex, OceanHex },
            new[] { GrassHex, ForestHex, ForestHex, ForestHex, GrassHex, OceanHex, OceanHex },
            new[] { GrassHex, ForestHex, MountainHex, MountainHex, GrassHex, OceanHex, OceanHex },
            new[] { GrassHex, MountainHex, MountainHex, ForestHex, MountainHex, OceanHex, OceanHex }
        };

        PlanetModel KimernaPlanet = new PlanetModel(KimernaMap)
        {
            PlanetName = "Kimerna",
            PlanetSize = 0.5f
        };

        Galaxy[2][3].Occupants.Add(KimernaPlanet);

        var T503 = ImperialGuard;

        T503.UnitName = "Thracian 503<sup>rd</sup>";
        T503.Faction  = Imperium;
        KimernaMap[0][4].Occupants.Add(T503);

        var T513 = ImperialArmor;

        T513.UnitName = "Thracian 513<sup>th</sup>";
        T513.Faction  = Imperium;
        KimernaMap[0][3].Occupants.Add(T513);

        var T523 = ImperialArtillery;

        T523.UnitName = "Thracian 523<sup>rd</sup>";
        T523.Faction  = Imperium;
        KimernaMap[0][2].Occupants.Add(T523);

        var T1224 = ImperialGuard;

        T1224.UnitName = "Thracian 1224<sup>th</sup>";
        T1224.Faction  = Imperium;
        KimernaMap[0][1].Occupants.Add(T1224);


        var KimernaKnights = ImperialRoughRider;

        KimernaKnights.UnitName = "4<sup>th</sup> Kimernas Lancers";
        KimernaKnights.Faction  = KimernaPdf;
        KimernaMap[5][0].Occupants.Add(KimernaKnights);

        var K_PDF_35 = ImperialPDF;

        K_PDF_35.UnitName = "35<sup>th</sup> Kimernas PDF";
        K_PDF_35.Faction  = KimernaPdf;
        KimernaMap[5][1].Occupants.Add(K_PDF_35);

        var K_PDF_15 = ImperialPDF;

        K_PDF_15.UnitName = "15<sup>th</sup> Kimernas PDF";
        K_PDF_15.Faction  = KimernaPdf;
        KimernaMap[6][0].Occupants.Add(K_PDF_15);



        var Gorlak = TraitorRoughRider;

        Gorlak.UnitName   = "Gorlak's Reavers";
        Gorlak.HealthCurr = 2.9f;
        Gorlak.Faction    = ChaosRaiders;
        KimernaMap[2][3].Occupants.Add(Gorlak);

        var DoK8 = TraitorGuard;

        DoK8.UnitName = "8<sup>th</sup> Desciples of Karnor";
        DoK8.Faction  = ChaosRaiders;
        KimernaMap[2][2].Occupants.Add(DoK8);

        var K_PDF_67 = ImperialPDF;

        K_PDF_67.UnitName = "67<sup>th</sup> Kimernas PDF";
        K_PDF_67.Faction  = ChaosRaiders;
        KimernaMap[3][2].Occupants.Add(K_PDF_67);

        var K_PDF_4 = ImperialPDF;

        K_PDF_4.UnitName = "4<sup>th</sup> Kimernas PDF";
        K_PDF_4.Faction  = ChaosRaiders;
        KimernaMap[3][1].Occupants.Add(K_PDF_4);

        var K_PDF_16 = ImperialPDF;

        K_PDF_16.UnitName = "16<sup>th</sup> Kimernas PDF";
        K_PDF_16.Faction  = ChaosRaiders;
        KimernaMap[5][4].Occupants.Add(K_PDF_16);

        Instantiator.InstantiateMap(Galaxy);
    }
예제 #19
0
 private void LoadFactionModels()
 {
     FactionModel.Load();
 }
 public FactionModel GetFactionByID(int id)
 {
     return(FactionModel.FromDbObject(_entities.factions.FirstOrDefault(x => x.pk_id == id)));
 }
 public FactionModel GetFactionByName(string factionName)
 {
     return(FactionModel.FromDbObject(_entities.factions.FirstOrDefault(x => x.name.Equals(factionName))));
 }
예제 #22
0
        public void TakeDamage(ActorHitInfo data)
        {
            if (MetaState.Instance.SessionFlags.Contains("GodMode") || GameState.Instance.PlayerFlags.Contains(PlayerFlags.Invulnerable) || IsDying)
            {
                return;
            }

            if (!data.HarmFriendly)
            {
                string hitFaction = data.OriginatorFaction;
                if (!string.IsNullOrEmpty(hitFaction))
                {
                    FactionRelationStatus relation = FactionModel.GetRelation(hitFaction, PredefinedFaction.Player.ToString()); //this looks backwards but it's because we're checking if the Bullet is-friendly-to the Actor
                    if (relation == FactionRelationStatus.Friendly)
                    {
                        return; //no friendly fire
                    }
                }
            }

            if (DamageHandler != null)
            {
                var hitOut = DamageHandler(data);
                if (hitOut.HasValue)
                {
                    data = hitOut.Value;
                }
                else
                {
                    return;
                }
            }

            CharacterModel playerModel = GameState.Instance.PlayerRpgState;

            var(damageToShields, damageToArmor, damageToCharacter) = RpgValues.DamageRatio(data.Damage, data.DamagePierce, playerModel);

            float oldShields = playerModel.Shields;

            playerModel.Shields -= damageToShields;

            if (oldShields > 0 && playerModel.Shields <= 0)
            {
                MessageInterface.PushToBus(new QdmsFlagMessage("PlayerShieldsLost"));
                ShieldComponent.Ref()?.SignalLostShields();
            }

            var(dt, dr) = playerModel.GetDamageThresholdAndResistance(data.DamageType);
            float damageTaken = RpgValues.DamageTaken(damageToArmor, damageToCharacter, dt, dr);

            if (data.HitLocation == (int)ActorBodyPart.Head)
            {
                damageTaken *= 2.0f;
            }
            else if (data.HitLocation == (int)ActorBodyPart.LeftArm || data.HitLocation == (int)ActorBodyPart.LeftLeg || data.HitLocation == (int)ActorBodyPart.RightArm || data.HitLocation == (int)ActorBodyPart.RightLeg)
            {
                damageTaken *= 0.75f;
            }

            playerModel.Health -= damageTaken;

            if (damageTaken > PainSoundThreshold)
            {
                if (PainSound != null && !PainSound.isPlaying)
                {
                    PainSound.Play();
                }
            }

            if (damageToShields > 0 || damageTaken > 0)
            {
                ShieldComponent.Ref()?.SignalTookDamage(damageToShields, damageTaken);

                var damageValues = new Dictionary <string, object>()
                {
                    { "DamageTaken", damageTaken },
                    { "DamageToShields", damageToShields },
                    { "DamageToArmor", damageToArmor },
                    { "DamageToCharacter", damageToCharacter }
                };
                MessageInterface.PushToBus(new QdmsKeyValueMessage(damageValues, "PlayerTookDamage"));
            }
        }
예제 #23
0
        private void SelectTarget()
        {
            var gameplayConfig = ConfigState.Instance.GetGameplayConfig();

            if (TotalTickCount % SearchInterval * (1f / gameplayConfig.Difficulty.ActorAggression) != 0)
            {
                return;
            }

            var detectionDifficultyFactor = 1f / gameplayConfig.Difficulty.ActorPerception;

            //check player first since it's (relatively) cheap
            if (FactionModel.GetRelation(Faction, "Player") == FactionRelationStatus.Hostile && !MetaState.Instance.SessionFlags.Contains("NoTarget") && !GameState.Instance.PlayerFlags.Contains(PlayerFlags.NoTarget))
            {
                var playerObj = WorldUtils.GetPlayerObject();
                if (playerObj != null && RpgWorldUtils.TargetIsAlive(playerObj.transform))
                {
                    PlayerController pc = playerObj.GetComponent <PlayerController>();

                    if ((playerObj.transform.position - transform.position).magnitude <= SearchRadius &&
                        UnityEngine.Random.Range(0f, 1f * detectionDifficultyFactor) <= RpgValues.DetectionChance(GameState.Instance.PlayerRpgState, pc.MovementComponent.IsCrouching, pc.MovementComponent.IsRunning))
                    {
                        if (UseLineOfSight)
                        {
                            //additional check
                            RaycastHit hitinfo;
                            if (Physics.Raycast(transform.position + new Vector3(0, 1.0f, 0), (playerObj.transform.position - transform.position), out hitinfo))
                            {
                                if (hitinfo.collider.gameObject == playerObj)
                                {
                                    Target = playerObj.transform;
                                    return;
                                }
                            }
                        }
                        else
                        {
                            //otherwise, close enough
                            Target = playerObj.transform;
                            return;
                        }
                    }
                }
            }

            //if(TargetNpc)
            {
                //var sw = System.Diagnostics.Stopwatch.StartNew();

                //new code should be faster if n is large but it may not bear out in practice, and it probably allocs more dedotated wam

                var colliders = Physics.OverlapSphere(transform.position, SearchRadius, LayerMask.GetMask("Default", "ActorHitbox"));
                HashSet <ActorController> potentialTargets = new HashSet <ActorController>();

                foreach (var collider in colliders)
                {
                    var actorController = collider.GetComponent <ActorController>();
                    if (actorController != null)
                    {
                        potentialTargets.Add(actorController);
                        break;
                    }

                    var hitboxComponent = collider.GetComponent <IHitboxComponent>();
                    if (hitboxComponent != null && hitboxComponent.ParentController is ActorController hitboxAC)
                    {
                        potentialTargets.Add(hitboxAC);
                        break;
                    }
                }


                //old stupid code: should work well enough as long as n is small and your computer is fast enough
                //IEnumerable<ActorController> potentialTargets = transform.root.GetComponentsInChildren<ActorController>();

                foreach (var potentialTarget in potentialTargets)
                {
                    if (RpgWorldUtils.TargetIsAlive(potentialTarget.transform) &&
                        (potentialTarget.transform.position - transform.position).magnitude <= SearchRadius &&
                        FactionModel.GetRelation(Faction, potentialTarget.Faction) == FactionRelationStatus.Hostile &&
                        !(potentialTarget == this))
                    {
                        //roll some dice
                        if (potentialTarget.Detectability < 1 && UnityEngine.Random.Range(0f, 1f * detectionDifficultyFactor) > potentialTarget.Detectability) //probably correct
                        {
                            continue;
                        }

                        if (UseLineOfSight)
                        {
                            //additional check
                            RaycastHit hitinfo;
                            if (Physics.Raycast(transform.position + new Vector3(0, 1.0f, 0), (potentialTarget.transform.position - transform.position), out hitinfo))
                            {
                                if (hitinfo.collider.gameObject == potentialTarget.gameObject)
                                {
                                    Target = potentialTarget.transform;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            //otherwise, close enough
                            Target = potentialTarget.transform;
                            break;
                        }
                    }
                }

                //sw.Stop();
                //Debug.Log($"Target lookup: {sw.Elapsed.TotalMilliseconds:F4} ms");
            }

            if (!RpgWorldUtils.TargetIsAlive(Target))
            {
                Target = null;
            }
        }
예제 #24
0
        public void TakeDamage(ActorHitInfo data)
        {
            //damage model is very stupid right now, we will make it better later
            float dt          = data.DamageType < DamageThreshold.Length ? DamageThreshold[(int)data.DamageType] : 0f;
            float dr          = data.DamageType < DamageThreshold.Length ? DamageResistance[(int)data.DamageType] : 0f;
            float damageTaken = RpgValues.DamageTaken(data.Damage, data.DamagePierce, dt, dr);

            if (data.HitLocation == (int)ActorBodyPart.Head)
            {
                damageTaken *= 2.0f;
            }
            else if (data.HitLocation == (int)ActorBodyPart.LeftArm || data.HitLocation == (int)ActorBodyPart.LeftLeg || data.HitLocation == (int)ActorBodyPart.RightArm || data.HitLocation == (int)ActorBodyPart.RightLeg)
            {
                damageTaken *= 0.75f;
            }

            damageTaken *= (1f / ConfigState.Instance.GetGameplayConfig().Difficulty.ActorStrength);

            if (!Invincible)
            {
                Health -= damageTaken;
            }

            /*
             * if(!string.IsNullOrEmpty(data.HitPuff))
             * {
             *  Debug.Log($"Spawning hitpuff \"{data.HitPuff}\" at {data.HitCoords}");
             *  Vector3 hitCoords = data.HitCoords.HasValue ? data.HitCoords.Value : transform.position;
             *  WorldUtils.SpawnEffect(data.HitPuff, hitCoords, transform.eulerAngles, null);
             * }
             * else if(!string.IsNullOrEmpty(DefaultHitPuff))
             * {
             *  Vector3 hitCoords = data.HitCoords.HasValue ? data.HitCoords.Value : transform.position;
             *  WorldUtils.SpawnEffect(DefaultHitPuff, hitCoords, transform.eulerAngles, null);
             * }
             */
            //we no longer spawn hitpuffs here

            if (CurrentAiState == ActorAiState.Dead) //abort if we're already dead
            {
                return;
            }

            bool didTakePain = UnityEngine.Random.Range(0f, 1f) < PainChance;

            if (Defensive && data.Originator != null && data.Originator != this)
            {
                FactionRelationStatus relation = FactionRelationStatus.Neutral;
                if (data.Originator is PlayerController)
                {
                    relation = FactionModel.GetRelation(Faction, "Player");
                }
                else if (data.Originator is ActorController)
                {
                    relation = FactionModel.GetRelation(Faction, ((ActorController)data.Originator).Faction);
                }

                if (relation != FactionRelationStatus.Friendly || Infighting)
                {
                    Target  = data.Originator.transform;
                    BeenHit = true;

                    if (DisableInteractionOnHit && InteractionComponent != null)
                    {
                        InteractionComponent.InteractionDisabledByHit = true;
                    }

                    if (FeelPain && didTakePain)
                    {
                        EnterState(ActorAiState.Hurting);
                    }
                    else
                    {
                        EnterState(ActorAiState.Chasing);
                    }
                }
                else
                {
                    EnterState(ActorAiState.Hurting);
                }
            }
            else if (FeelPain && didTakePain)
            {
                EnterState(ActorAiState.Hurting);
            }
        }
예제 #25
0
    public MoveOptions PossibleMoves(float movePoints, FactionModel faction)
    {
        MoveOptions possibleMoves = new MoveOptions();

        SortedDupList <HexModel> moveFrontier = new SortedDupList <HexModel>();

        moveFrontier.Insert(this, movePoints);

        while (moveFrontier.Count > 0)
        {
            HexModel currHex = moveFrontier.TopValue();
            float    currHexMoveRemaining = moveFrontier.TopKey();
            possibleMoves.Movable[currHex] = currHexMoveRemaining;
            if (!currHex.ContainsEnemy(faction))
            {
                foreach (HexModel neighbor in currHex.Neighbors)
                {
                    if (neighbor.MoveDifficulty >= 0 && !moveFrontier.ContainsValue(neighbor) &&
                        !possibleMoves.Movable.ContainsKey(neighbor) &&
                        currHexMoveRemaining - neighbor.MoveDifficulty >= 0)
                    {
                        if (currHex.BordersEnemy(faction) && !neighbor.ContainsEnemy(faction) && !neighbor.ContainsAlly(faction) && neighbor.BordersEnemy(faction))
                        {
                            continue;
                        }
                        if (currHex.ContainsAlly(faction) && currHex != this && neighbor.ContainsEnemy(faction))
                        {
                            continue;
                        }
                        moveFrontier.Insert(neighbor, currHexMoveRemaining - neighbor.MoveDifficulty);
                    }
                }
            }
            moveFrontier.Pop();
        }

        List <HexModel> hexesWithUnits = new List <HexModel>();

        foreach (HexModel hex in possibleMoves.Movable.Keys)
        {
            if (hex.ContainsUnit())
            {
                hexesWithUnits.Add(hex);
            }
        }
        foreach (HexModel hexToRemove in hexesWithUnits)
        {
            float reachableVal = possibleMoves.Movable[hexToRemove];
            possibleMoves.Movable.Remove(hexToRemove);
            if (hexToRemove.ContainsEnemy(faction))
            {
                if (Neighbors.Contains(hexToRemove))
                {
                    possibleMoves.Attackable[hexToRemove] = reachableVal;
                }
                else
                {
                    possibleMoves.PotentialAttacks[hexToRemove] = reachableVal;
                }
            }
        }

        return(possibleMoves);
    }
예제 #26
0
 public override void OnAddonLoaded(AddonLoadData data)
 {
     FactionModel.LoadFromAddon(data);
     InventoryModel.LoadFromAddon(data);
     QuestModel.LoadFromAddon(data);
 }
예제 #27
0
 public bool ContainsEnemy(FactionModel faction)
 {
     return(ContainsUnit() && MapController.Model.GetUnit(Coord).Faction.Enemies.Contains(faction));
 }
예제 #28
0
        public List <FactionModel> GetAllFactionList()
        {
            List <FactionModel> factionList = new List <FactionModel>();

            #region allFactions
            FactionModel wanFaMen = new FactionModel()
            {
                FactionId          = 1,
                FactionName        = "万法门",
                FactionImgUrl      = "FactionCardBackground",
                FactionDescription = "单身者的门派(确信)"
            };
            factionList.Add(wanFaMen);

            FactionModel yuanLiMen = new FactionModel()
            {
                FactionId          = 2,
                FactionName        = "元力门",
                FactionImgUrl      = "FactionCardBackground",
                FactionDescription = "万有引力"
            };
            factionList.Add(yuanLiMen);

            FactionModel tianLingLing = new FactionModel()
            {
                FactionId          = 3,
                FactionName        = "天灵岭",
                FactionImgUrl      = "FactionCardBackground",
                FactionDescription = "天演图录"
            };
            factionList.Add(tianLingLing);

            FactionModel fenTianFu = new FactionModel()
            {
                FactionId          = 4,
                FactionName        = "焚天府",
                FactionImgUrl      = "FactionCardBackground",
                FactionDescription = "热学"
            };
            factionList.Add(fenTianFu);

            FactionModel guangHuaDian = new FactionModel()
            {
                FactionId          = 5,
                FactionName        = "光华殿",
                FactionImgUrl      = "FactionCardBackground",
                FactionDescription = "光学"
            };
            factionList.Add(guangHuaDian);

            FactionModel piaoMiaogGong = new FactionModel()
            {
                FactionId          = 6,
                FactionName        = "飘渺宫",
                FactionImgUrl      = "FactionCardBackground",
                FactionDescription = "量子力学"
            };
            factionList.Add(piaoMiaogGong);

            FactionModel benLeiGe = new FactionModel()
            {
                FactionId          = 7,
                FactionName        = "奔雷阁",
                FactionImgUrl      = "FactionCardBackground",
                FactionDescription = "电学"
            };
            factionList.Add(benLeiGe);

            FactionModel fenJinGu = new FactionModel()
            {
                FactionId          = 8,
                FactionName        = "焚金谷",
                FactionImgUrl      = "FactionCardBackground",
                FactionDescription = "化学"
            };
            factionList.Add(fenJinGu);

            FactionModel xinYueXianYuan = new FactionModel()
            {
                FactionId          = 9,
                FactionName        = "辛岳仙院",
                FactionImgUrl      = "FactionCardBackground",
                FactionDescription = "新手村"
            };
            factionList.Add(xinYueXianYuan);

            #endregion

            return(factionList);
        }
예제 #29
0
 public bool ContainsNonAlliedUnit(FactionModel faction)
 {
     return(ContainsUnit() &&
            !(MapController.Model.GetUnit(Coord).Faction == faction || MapController.Model.GetUnit(Coord).Faction.Allies.Contains(faction)));
 }