public frmChangeFaction(Factions currentFaction) { InitializeComponent(); foreach (var faction in Enum.GetNames(typeof(Factions))) cmbFaction.Items.Add(faction); cmbFaction.SelectedIndex = cmbFaction.FindString(currentFaction.ToString()); }
public frmGetFaction(Factions defaultFaction, string playerName) { InitializeComponent(); this.Text = "Faction for " + playerName; foreach (var faction in Enum.GetNames(typeof(Factions))) cmbFaction.Items.Add(faction); cmbFaction.SelectedIndex = cmbFaction.FindString(defaultFaction.ToString()); }
public static IEnumerator<Faction> GetAllEnemies(Factions myFaction) { var val = AllFactions .Where(kvp => (kvp.Key != myFaction)) .Select(kvp => kvp.Value) .Combine<Faction, List<Faction>>(); val.MoveNext(); return val; }
public Creature(int x, int y, string name, int visionRadius, int maxHealth, double hpRegenRate, string displayString, Color displayColor, Factions faction) : base(x, y) { this.name = name; this.visionRadius = visionRadius; this.maxHealth = maxHealth; this.health = maxHealth; this.hpRegenRate = hpRegenRate; this.displayString = displayString; this.displayColor = displayColor; map[x, y].creature = this; this.faction = faction; }
public bool AreWeAlly(Character other) { return(Factions.Any(other.Factions.Contains)); }
public acegiak_Song MakeItCultural(acegiak_Song song, string faction) { if (song.Themes != null) { List <string> songwords = new List <string> { "song", "tune", "lullabye", "sound", "call", "tone" }; string FactionFancy = Factions.get(faction).DisplayName; string theme = song.Themes.GetRandomElement(); string themeShort = theme.Replace("the ", "").Replace("ing", ""); switch (Stat.Rnd2.Next(8)) { case 0: song.Name = Grammar.Adjectify(FactionFancy) + " " + theme.Replace("the ", "") + " " + songwords.GetRandomElement(); break; case 1: song.Name = theme.Replace("the ", "") + " " + songwords.GetRandomElement() + " of " + FactionInfo.getFormattedName(faction); break; case 2: song.Name = Grammar.Adjectify(themeShort) + " " + songwords.GetRandomElement() + " of " + FactionInfo.getFormattedName(faction); break; case 3: song.Name = Grammar.Adjectify(FactionFancy) + " " + songwords.GetRandomElement() + " of " + theme; break; case 4: song.Name = Grammar.MakePossessive(FactionFancy) + " " + songwords.GetRandomElement() + " of " + theme; break; case 5: song.Name = Grammar.MakePossessive(FactionFancy) + " " + song.Themes.GetRandomElement() + " " + songwords.GetRandomElement(); break; case 6: song.Name = Grammar.MakePossessive(FactionFancy) + " " + Grammar.Adjectify(song.Themes.GetRandomElement()) + " " + songwords.GetRandomElement(); break; case 7: song.Name = Grammar.Adjectify(themeShort) + " " + songwords.GetRandomElement() + " of " + FactionInfo.getFormattedName(faction); break; } song.Name = Grammar.MakeTitleCase(song.Name); } List <List <float> > noteData = new List <List <float> >(); foreach (string note in song.Notes.Split(';')) { List <float> notefloats = new List <float>(); foreach (string notebit in note.Split(',')) { if (notebit.Length > 0) { float f = acegiak_AudioSequencer.ParseFloat(notebit); notefloats.Add(f); } } noteData.Add(notefloats); } noteData = noteTransform(noteData, FactionTags(faction)); List <string> notebits = new List <string>(); foreach (List <float> floatlist in noteData) { List <string> fromfloats = new List <string>(); foreach (float f in floatlist) { fromfloats.Add(f.ToString()); } string joinedfloats = String.Join(",", fromfloats.ToArray()); notebits.Add(joinedfloats); } song.Notes = String.Join(";", notebits.ToArray()); return(song); }
protected override void process(Entity entity) { Projectile projectile = (Projectile)p_ProjectileMapper.get(entity); projectile.ElapsedTime += ecs_instance.ElapsedTime; //is it time for the projectile to die? if (projectile.ElapsedTime >= projectile.LifeTime) { ecs_instance.delete_entity(entity); return; } Position position = (Position)p_PositionMapper.get(entity); Velocity velocity = (Velocity)p_VelocityMapper.get(entity); Heading heading = (Heading)p_HeadingMapper.get(entity); SpatialPartition spatial = (SpatialPartition)p_SpatialMapper.get(p_Spatial); Vector2 pos = position.Pos; //List<Entity> locals = spatial.QuadTree.retrieveContentsAtLocation(pos); List <Entity> locals = spatial.QuadTree.findAllWithinRange(pos, 32); //anything retrieved? if (locals != null) { //anyone aruond? if (locals.Count > 0) { //for all the locals see if we should do anything for (int i = 0; i < locals.Count; i++) { //dont interact with whom fired you if (locals[i] == projectile.Originator) { continue; } Life life = (Life)p_LifeMapper.get(locals[i]); //if no life, uh, don't check for it... if (life == null) { continue; } //if target is dead, dont worry if (!life.IsAlive) { continue; } //is there an interaction available? Interactable interaction = (Interactable)p_InteractionMapper.get(locals[i]); if (interaction != null) { //get this local's position Position localPosition = (Position)p_PositionMapper.get(locals[i]); //are we close to it? //23 - minimal radial distance for collision to occur if (Vector2.Distance(pos + position.Offset, localPosition.Pos + localPosition.Offset) < 23) { //can we do anything to it? if (interaction.SupportedInteractions.PROJECTILE_COLLIDABLE && interaction.SupportedInteractions.ATTACKABLE) { Factions lfactions = (Factions)p_FactionMapper.get(locals[i]); Factions pfactions = (Factions)p_FactionMapper.get(projectile.Originator); if (lfactions.OwnerFaction.FactionType == pfactions.OwnerFaction.FactionType) { continue; } //UtilFactory.createAttack(projectile.Originator, locals[i], AttackType.Projectile); ActionDef def = GameConfig.ActionDefs["RANGED_DMG"]; ActionFactory.createAction(def, projectile.Originator, locals[i]); //destory yourself ecs_instance.delete_entity(entity); return; } } } } } } MapCollidable mapCollide = (MapCollidable)p_MapCollidableMapper.get(entity); if (mapCollide != null) { if (mapCollide.Collided) { /* * Vector2 norm = mapCollide.ResponseVector; * norm.Normalize(); * Vector2 reflect = Vector2.Reflect(heading.getHeading(), norm); * reflect.Normalize(); * * //Transform trans = (Transform)p_TransformMapper.get(entity); * * //trans.Rotation = -VectorHelper.getAngle2(new Vector2(1,0), reflect); * * heading.setHeading(reflect); */ UtilFactory.createSound("audio\\effects\\hitwall", true, 0.5f); ecs_instance.delete_entity(entity); } } pos += heading.getHeading() * velocity.Vel; position.Pos = pos; }
public override void WriteDataXML(XElement ele, ElderScrollsPlugin master) { XElement subEle; if (EditorID != null) { ele.TryPathTo("EditorID", true, out subEle); EditorID.WriteXML(subEle, master); } if (ObjectBounds != null) { ele.TryPathTo("ObjectBounds", true, out subEle); ObjectBounds.WriteXML(subEle, master); } if (Name != null) { ele.TryPathTo("Name", true, out subEle); Name.WriteXML(subEle, master); } if (Model != null) { ele.TryPathTo("Model", true, out subEle); Model.WriteXML(subEle, master); } if (ActorEffects != null) { ele.TryPathTo("ActorEffects", true, out subEle); List <string> xmlNames = new List <string> { "ActorEffect" }; int i = 0; ActorEffects.Sort(); foreach (var entry in ActorEffects) { i = i % xmlNames.Count(); XElement newEle = new XElement(xmlNames[i]); entry.WriteXML(newEle, master); subEle.Add(newEle); i++; } } if (UnarmedAttackEffect != null) { ele.TryPathTo("Unarmed/AttackEffect", true, out subEle); UnarmedAttackEffect.WriteXML(subEle, master); } if (UnarmedAttackAnimation != null) { ele.TryPathTo("Unarmed/AttackAnimation", true, out subEle); UnarmedAttackAnimation.WriteXML(subEle, master); } if (Models != null) { ele.TryPathTo("Models", true, out subEle); Models.WriteXML(subEle, master); } if (TextureHashes != null) { ele.TryPathTo("TextureHashes", true, out subEle); TextureHashes.WriteXML(subEle, master); } if (BaseStats != null) { ele.TryPathTo("BaseStats", true, out subEle); BaseStats.WriteXML(subEle, master); } if (Factions != null) { ele.TryPathTo("Factions", true, out subEle); List <string> xmlNames = new List <string> { "Faction" }; int i = 0; Factions.Sort(); foreach (var entry in Factions) { i = i % xmlNames.Count(); XElement newEle = new XElement(xmlNames[i]); entry.WriteXML(newEle, master); subEle.Add(newEle); i++; } } if (DeathItem != null) { ele.TryPathTo("DeathItem", true, out subEle); DeathItem.WriteXML(subEle, master); } if (VoiceType != null) { ele.TryPathTo("VoiceType", true, out subEle); VoiceType.WriteXML(subEle, master); } if (Template != null) { ele.TryPathTo("Template", true, out subEle); Template.WriteXML(subEle, master); } if (Destructable != null) { ele.TryPathTo("Destructable", true, out subEle); Destructable.WriteXML(subEle, master); } if (Script != null) { ele.TryPathTo("Script", true, out subEle); Script.WriteXML(subEle, master); } if (Contents != null) { ele.TryPathTo("Contents", true, out subEle); List <string> xmlNames = new List <string> { "Item" }; int i = 0; Contents.Sort(); foreach (var entry in Contents) { i = i % xmlNames.Count(); XElement newEle = new XElement(xmlNames[i]); entry.WriteXML(newEle, master); subEle.Add(newEle); i++; } } if (AIData != null) { ele.TryPathTo("AIData", true, out subEle); AIData.WriteXML(subEle, master); } if (Packages != null) { ele.TryPathTo("Packages", true, out subEle); List <string> xmlNames = new List <string> { "Package" }; int i = 0; foreach (var entry in Packages) { i = i % xmlNames.Count(); XElement newEle = new XElement(xmlNames[i]); entry.WriteXML(newEle, master); subEle.Add(newEle); i++; } } if (Animations != null) { ele.TryPathTo("Animations", true, out subEle); Animations.WriteXML(subEle, master); } if (Data != null) { ele.TryPathTo("Data", true, out subEle); Data.WriteXML(subEle, master); } if (AttackReach != null) { ele.TryPathTo("AttackReach", true, out subEle); AttackReach.WriteXML(subEle, master); } if (CombatStyle != null) { ele.TryPathTo("CombatStyle", true, out subEle); CombatStyle.WriteXML(subEle, master); } if (BodyPartData != null) { ele.TryPathTo("BodyPartData", true, out subEle); BodyPartData.WriteXML(subEle, master); } if (TurningSpeed != null) { ele.TryPathTo("TurningSpeed", true, out subEle); TurningSpeed.WriteXML(subEle, master); } if (BaseScale != null) { ele.TryPathTo("BaseScale", true, out subEle); BaseScale.WriteXML(subEle, master); } if (FootWeight != null) { ele.TryPathTo("FootWeight", true, out subEle); FootWeight.WriteXML(subEle, master); } if (ImpactMaterialType != null) { ele.TryPathTo("ImpactMaterialType", true, out subEle); ImpactMaterialType.WriteXML(subEle, master); } if (SoundLevel != null) { ele.TryPathTo("SoundLevel", true, out subEle); SoundLevel.WriteXML(subEle, master); } if (SoundTemplate != null) { ele.TryPathTo("SoundTemplate", true, out subEle); SoundTemplate.WriteXML(subEle, master); } if (SoundData != null) { ele.TryPathTo("SoundData", true, out subEle); List <string> xmlNames = new List <string> { "Sound" }; int i = 0; foreach (var entry in SoundData) { i = i % xmlNames.Count(); XElement newEle = new XElement(xmlNames[i]); entry.WriteXML(newEle, master); subEle.Add(newEle); i++; } } if (ImpactDataset != null) { ele.TryPathTo("ImpactDataset", true, out subEle); ImpactDataset.WriteXML(subEle, master); } if (MeleeWeaponList != null) { ele.TryPathTo("MeleeWeaponList", true, out subEle); MeleeWeaponList.WriteXML(subEle, master); } }
public override void Deserialize( GenericReader gr ) { int version = gr.ReadInt(); // id = gr.ReadInt(); UInt64 g = gr.ReadInt64(); SpawnerLink = null;//(BaseSpawner)MobileList.TempSpawner[ g ]; int esu = 0; int ech = 0; esu = gr.ReadInt(); ech = gr.ReadInt(); name = gr.ReadString(); if ( version > 0 ) classe = (Classes)gr.ReadInt(); talent = gr.ReadInt(); Level = gr.ReadInt(); model = gr.ReadInt(); exp = (uint)gr.ReadInt(); guildId = (uint)gr.ReadInt(); petLevel = (uint)gr.ReadInt(); petCreatureFamily = (uint)gr.ReadInt(); petDisplayId = (uint)gr.ReadInt(); speed = gr.ReadFloat(); size = gr.ReadFloat(); faction = (Factions)gr.ReadInt(); str = gr.ReadInt(); agility = gr.ReadInt(); stamina = gr.ReadInt(); iq = gr.ReadInt(); spirit = gr.ReadInt(); baseStr = gr.ReadFloat(); baseAgility = gr.ReadFloat(); baseStamina = gr.ReadFloat(); baseIq = gr.ReadFloat(); baseSpirit = gr.ReadFloat(); walkSpeed = gr.ReadFloat(); if ( walkSpeed == 0 ) walkSpeed = 4.7777f; runSpeed = gr.ReadFloat(); if ( runSpeed == 0 ) runSpeed = 7f; swimSpeed = gr.ReadFloat(); if ( swimSpeed == 0 ) swimSpeed = 4.72f; swimBackSpeed = gr.ReadFloat(); if ( swimBackSpeed == 0 ) swimBackSpeed = 2.5f; hitPoints = gr.ReadInt(); mana = gr.ReadInt(); energy = gr.ReadInt(); rage = gr.ReadInt(); focus = gr.ReadInt(); baseHitPoints = gr.ReadInt(); baseMana = gr.ReadInt(); baseEnergy = gr.ReadInt(); baseRage = gr.ReadInt(); baseFocus = gr.ReadInt(); block = gr.ReadInt(); armor = gr.ReadInt(); resistHoly = gr.ReadInt(); resistFire = gr.ReadInt(); resistNature = gr.ReadInt(); resistFrost = gr.ReadInt(); resistShadow = gr.ReadInt(); resistArcane = gr.ReadInt(); int nSkills = gr.ReadInt(); for(int t = 0;t < nSkills;t++ ) { ushort skill = (ushort)gr.ReadShort(); allSkills[ skill ] = Skill.Deserialize( gr, t ); } int nSpells = gr.ReadInt(); for(int t = 0;t < nSpells;t++ ) { ushort spell = (ushort)gr.ReadShort(); byte place = gr.ReadByte(); knownAbilities[ (int)spell ] = (int)place; /* if ( TalentDescription.IsTalent( (int)spell ) ) { if ( onInitialiseTalent[ (int)spell ] != null ) { ( onInitialiseTalent[ (int)spell ] as TalentHandlers.TalentHandler )( Abilities.abilities[ (int)spell ], this ); } // this.AddPermanentAura( Abilities.abilities[ (int)spell ], new Aura() ); // permanentAura.Add( spell ); }*/ } int nTalentList = gr.ReadInt(); for(int t = 0;t < nTalentList;t++ ) { int spell = gr.ReadInt(); int lev = gr.ReadInt(); talentList[ spell ] = (int)lev; } if ( gr.ReadInt() != 0 ) freeze = true; int nit = gr.ReadInt(); for(int t = 0;t < nit;t++ ) { int n = gr.ReadInt(); if ( n == 1 ) items[ t ] = Item.Load( gr ); else items[ t ] = null; } if ( gr.ReadInt() != 0 ) movementChange = true; manaType = gr.ReadInt(); professions = gr.ReadByte(); standState = (StandStates)gr.ReadInt(); base.Deserialize( gr ); moveVector = new MoveVector( this, X, Y, Z ); // if ( this is BaseSpawner ) // MobileList.TempSpawner[ Guid ] = this; if ( esu != 0 ) MobileList.TempSummon[ Guid ] = this; if ( ech != 0 ) MobileList.TempSummon[ Guid ] = this; //movementTimer = new MovementTimer( this ); }
private List <MechModel> GetMoreInformationMechs(Factions faction, string weight) { return(choosableModels.Where(m => m.MechFaction == faction && m.GetMechWeight().Equals(weight)) .OrderBy(m => m.MechModelName) .ToList()); }
public override bool FireEvent(Event E) { if (E.ID == "CommandReadEmotions") { Cell C = PickDestinationCell(12, AllowVis.Any, false); if (C == null) { return(false); } if (ParentObject.pPhysics.CurrentCell.DistanceTo(C) > 12) { if (ParentObject.IsPlayer()) { Popup.Show("That it out of range (maximum 12)", true); } return(false); } ReadEmotionsActivatedAbility.Cooldown = 0; this.UseEnergy(1000); string output = string.Empty; foreach (GameObject gameObject in C.GetObjectsWithPart("Brain")) { output = "Reading the brain of " + gameObject.DisplayName; XRLCore.Core.Game.Player.Messages.Add(output); GameObjectBlueprint myGOB = gameObject.GetBlueprint(); output = gameObject.DisplayName + " is a " + myGOB.Inherits; XRLCore.Core.Game.Player.Messages.Add(output); string targetsFaction = gameObject.pBrain.GetPrimaryFaction(); output = gameObject.DisplayName + " primary faction is " + Faction.getFormattedName(targetsFaction); XRLCore.Core.Game.Player.Messages.Add(output); foreach (KeyValuePair <string, Faction> item in Factions.FactionList) { bool modified = false; int factionAmount = Factions.GetFeelingFactionToFaction(targetsFaction, item.Value.Name); if (gameObject.pBrain.FactionFeelings.ContainsKey(item.Value.Name)) { factionAmount = gameObject.pBrain.FactionFeelings[item.Value.Name]; modified = true; } if (factionAmount == 0) { continue; } if (factionAmount > 0 && showFriendy == false) { continue; } output = Faction.getFormattedName(item.Value.Name); if (factionAmount < 0) { output = "&rattack " + output + "&y"; } else { output = "&gignore " + output + "&y"; } output = gameObject.DisplayName + " will " + output + " faction members"; if (showNumbers) { if (factionAmount < 0) { if (modified) { output += ": [&r" + factionAmount + "&y]"; } else { output += ": &r" + factionAmount + "&y"; } } else { if (modified) { output += ": [&g" + factionAmount + "&y]"; } else { output += ": &g" + factionAmount + "&y"; } } } output += "."; XRLCore.Core.Game.Player.Messages.Add(output); } } } return(true); }
public override void Load(Queue<string> saveStrings) { base.Load(saveStrings); this.name = saveStrings.Dequeue(); this.visionRadius = Convert.ToInt32(saveStrings.Dequeue()); this.maxHealth = Convert.ToInt32(saveStrings.Dequeue()); this.health = Convert.ToDouble(saveStrings.Dequeue()); this.hpRegenRate = Convert.ToDouble(saveStrings.Dequeue()); this.displayString = saveStrings.Dequeue(); this.displayColor = new Color() { PackedValue = Convert.ToUInt32(saveStrings.Dequeue()) }; map[x, y].creature = this; this.faction = (Factions)Enum.Parse(typeof(Factions),saveStrings.Dequeue()); this.gold = Convert.ToInt32(saveStrings.Dequeue()); }
public CellInfo(Factions faction, int techLevel) { // Assign directly to fields, to avoid setting the dirty flag. _faction = faction; _techLevel = techLevel; }
public override bool FireEvent(Event E) { // Stop if this creature already gives reputation. if (ParentObject.GetPart("GivesRep") != null) { return(base.FireEvent(E)); } // Stop of this creature is the player. if (ParentObject.IsPlayer()) { return(base.FireEvent(E)); } // Add the Factions if (E.ID == "FactionsAdded") { int index = 0; // Get Parent Factions foreach (KeyValuePair <string, int> item in ParentObject.pBrain.FactionMembership) { parentFactions.Add(item.Key); } if (parentFactions.Count <= 0) { return(false); } // Format the Parent Factions list into text descriptionPostfix += "&C-----&y\nLoved by"; foreach (string parentFaction in parentFactions) { descriptionPostfix += " &C" + Faction.getFormattedName(parentFaction) + "&y,"; } descriptionPostfix = descriptionPostfix.Remove(descriptionPostfix.Length - 1); descriptionPostfix += "&y.\n"; if (parentFactions.Count > 1) { int locationOf = descriptionPostfix.LastIndexOf(","); descriptionPostfix = descriptionPostfix.Insert(locationOf + 1, " and"); } // Pick 1-3 Factions to Like/Dislike/Hate int maxFactions = Rules.Stat.Random(1, 3); // Adjust the feelings towards other Factions Brain myBrain = ParentObject.GetPart("Brain") as Brain; string myFaction = myBrain.GetPrimaryFaction(); for (index = 1; index <= maxFactions; index++) { int randPercent = Rules.Stat.Random(1, 100); int factionChange = -100; if (randPercent <= 10) { factionChange = 100; } else if (randPercent <= 55) { factionChange = 0; } string FoF = GenerateFriendOrFoe.getRandomFaction(ParentObject); factionChange += Factions.GetFeelingFactionToFaction(myFaction, FoF); if (factionChange > 100) { factionChange = 100; } if (factionChange < -100) { factionChange = -100; } AddOrChangeFactionFeelings(myBrain, FoF, factionChange); } Dictionary <string, int> tempRelatedFactions = new Dictionary <string, int>(); // Add all the factions with a significant amount to the list. foreach (KeyValuePair <string, Faction> item in Factions.FactionList) { if (item.Value.Name == myFaction) { continue; } if (item.Value.bVisible == false) { continue; } int factionAmount = Factions.GetFeelingFactionToFaction(myFaction, item.Value.Name); if (myBrain.FactionFeelings.ContainsKey(item.Value.Name)) { factionAmount = myBrain.FactionFeelings[item.Value.Name]; } if (factionAmount < 0 || factionAmount > 50) { tempRelatedFactions.Add(item.Value.Name, factionAmount); } } for (index = 1; index <= maxFactions; index++) { if (tempRelatedFactions.Count <= 0) { break; } KeyValuePair <string, int> item = tempRelatedFactions.GetRandomElement((System.Random)null); if (item.Value > 50) { string reason = GenerateFriendOrFoe.getLikeReason(); relatedFactions.Add(new FriendorFoe(item.Key, "friend", reason)); } else { string reason = GenerateFriendOrFoe.getHateReason(); relatedFactions.Add(new FriendorFoe(item.Key, "dislike", reason)); } tempRelatedFactions.Remove(item.Key); } // Count and sort the factions by category (friend, dislike, hate) if (relatedFactions.Count <= 0) { return(true); } int friendCount = 0; int hateCount = 0; string friendString = "\nAdmired by "; string hateString = "\nHated by"; foreach (FriendorFoe relatedFaction in relatedFactions) { if (relatedFaction.status == "friend") { friendString += " &C" + Faction.getFormattedName(relatedFaction.faction) + "&y,"; friendCount += 1; } else { hateString += " &C" + Faction.getFormattedName(relatedFaction.faction) + "&y,"; hateCount += 1; } } if (friendCount > 0) { friendString = friendString.Remove(friendString.Length - 1); friendString += "&y.\n"; if (friendCount > 1) { int locationOf = friendString.LastIndexOf(","); friendString = friendString.Insert(locationOf + 1, " and"); } descriptionPostfix += friendString; } if (hateCount > 0) { hateString = hateString.Remove(hateString.Length - 1); hateString += "&y.\n"; if (hateCount > 1) { int locationOf = hateString.LastIndexOf(","); hateString = hateString.Insert(locationOf + 1, " and"); } descriptionPostfix += hateString; } return(true); } else if (E.ID == "BeforeDeathRemoval") { // Give/Take Reputation when the creature is killed. GameObject myKiller = E.GetParameter("Killer") as GameObject; if (myKiller == null) { return(true); } // Did the player kill this Creature? if (myKiller.IsPlayer()) { // Adjust the players reputation. Reputation myReputation = XRLCore.Core.Game.PlayerReputation; foreach (KeyValuePair <string, int> item in ParentObject.pBrain.FactionMembership) { // Calculate an adjust 'weight' // 1) Does the player have a positive or negative relationship to this faction. // - Player has a positive relationship to this creature their reputation drops more. // (You are friendly they are not going to like that.) // - Player has a negitive relationship to this creature their reputation drops less. // (You are already hated, they are not going to hate you that much more) // - This should be the major factor in the equation. // 2) Is the creature greater or lesser level than the player. // - More difficult creatures offer more reputation. // - Easier creatures offer less reputation. // - This should be a minor adjustment. // Get the current reputation. int currentRep = myReputation.get(item.Key); //MessageQueue.AddPlayerMessage("currentRep " + currentRep); // Scale the reputation based on the current reputation. float fRep = 0; //if (currentRep > 0) fRep = repValue * (currentRep / repScale); //else if (currentRep < 0) fRep = repValue / (-currentRep / repScale); if (currentRep > -gravitateOffset) { fRep = repValue * ((currentRep + gravitateOffset) / repScale); } else if (currentRep < -gravitateOffset) { fRep = repValue / (-(currentRep + gravitateOffset) / repScale); } //MessageQueue.AddPlayerMessage("fRep " + fRep); // Get the level differences. int creatureLevel = ParentObject.Statistics["Level"].Value; int playerLevel = XRLCore.Core.Game.Player.Body.Statistics["Level"].Value; // Scale the reputation based on the player vs creature levels. int dLevel = creatureLevel - playerLevel; if (dLevel > 0) { fRep = fRep * (dLevel / levelScale); } else if (dLevel < 0) { fRep = fRep / (-dLevel / levelScale); } //MessageQueue.AddPlayerMessage("fRep " + fRep); currentRep = (int)Math.Floor(fRep); //MessageQueue.AddPlayerMessage("currentRep " + currentRep); // Only modify if the reputation change is not 0. if (currentRep != 0) { myReputation.modify(item.Key, -currentRep, false); } } foreach (FriendorFoe relatedFaction in relatedFactions) { // Get the current reputation. int currentRep = myReputation.get(relatedFaction.faction); //MessageQueue.AddPlayerMessage("currentRep " + currentRep); // Scale the reputation based on the current reputation. float fRep = 0; //if (currentRep > 0) fRep = repValue * (currentRep / repScale); //else if (currentRep < 0) fRep = repValue / (-currentRep / repScale); if (currentRep > -gravitateOffset) { fRep = repValue * ((currentRep + gravitateOffset) / repScale); } else if (currentRep < -gravitateOffset) { fRep = repValue / (-(currentRep + gravitateOffset) / repScale); } //MessageQueue.AddPlayerMessage("fRep " + fRep); // Get the level differences. int creatureLevel = ParentObject.Statistics["Level"].Value; int playerLevel = XRLCore.Core.Game.Player.Body.Statistics["Level"].Value; // Scale the reputation based on the player vs creature levels. int dLevel = creatureLevel - playerLevel; if (dLevel > 0) { fRep = fRep * (dLevel / levelScale); } else if (dLevel < 0) { fRep = fRep / (-dLevel / levelScale); } //MessageQueue.AddPlayerMessage("fRep " + fRep); fRep = fRep / relationScale; currentRep = (int)Math.Floor(fRep); //MessageQueue.AddPlayerMessage("currentRep " + currentRep); if (relatedFaction.status == "liked") { // Only modify if the reputation change is not 0. if (currentRep != 0) { myReputation.modify(relatedFaction.faction, -currentRep, false); } } else { // Only modify if the reputation change is not 0. if (currentRep != 0) { myReputation.modify(relatedFaction.faction, currentRep, false); } } } } else { /* Removed for Now; Where to adjust reputation for creature on creature combat */ } return(true); } else if (E.ID == "GetShortDescription") { E.AddParameter("Postfix", E.GetParameter("Postfix") + descriptionPostfix); } return(base.FireEvent(E)); }
public ICollection <Planet> GetClaimablePlanets() { return(Factions.SelectMany(f => GetClaimablePlanets(f)).ToArray()); }
public static void SetReaction( Factions from, Factions to, float val ) { reactions[ (int)from, (int)to ] = val; reactions[ (int)to, (int)from ] = val; }
public static void WriteReference(GenericWriter writer, Faction fact) { int idx = Factions.IndexOf(fact); writer.WriteEncodedInt((int)(idx + 1)); }
void InitFactions() { int count = 0; string filepath = Application.dataPath + "/Resources/Data Files/factiondata.xml"; XDocument factionXML = XDocument.Load(filepath); // Creates an array of factions. var factionNames = from factionName in factionXML.Root.Elements("FactionAttributes") select new { factionName_XML = (string)factionName.Element("name"), factionID_XML = (int)factionName.Element("id"), //TODO: Need to turn this into array. factionRelations_XML = factionName.Element("relations").Descendants("id").ToArray()//(string[])(from rel in factionName.Descendants("relations") select (string)rel.Value).ToArray<string>()//(int[])factionName.Element("relations") }; // // foreach ( var factionName in factionNames) ++count; foreach ( var factionName in factionNames) { int cnt = factionName.factionRelations_XML.Length; //Debug.Log(factionName.factionName_XML + " Relations Count :: " + cnt); Factions f = new Factions(); f.index = relationsListDictionary.Count; f.otherFactionsName = new string[count]; f.otherFactionsRelation = new int[count]; int others = 0; f.FactionName = factionName.factionName_XML; //Debug.Log(factionName.factionRelations_XML); // Adds Rivals, not self to other list. foreach (var factionName2 in factionNames) { if (factionName.factionID_XML == factionName2.factionID_XML) continue; f.relations.Add(factionName2.factionName_XML, (int)factionName.factionRelations_XML[others]); //Debug.Log(f.relations[factionName2.factionName_XML]); //f.otherFactionsName[(int)factionName2.factionID_XML] = factionName2.factionName_XML; //f.otherFactionsRelation[(int)factionName2.factionID_XML] = factionName.factionRelations_XML[(int)factionName2.factionID_XML]; //Debug.Log(f.FactionName + " adds: " + factionName2.factionName_XML); ++others; } XDocument shipXML = XDocument.Load(Application.dataPath + "/Resources/Ships/" + f.FactionName + "/shipdata.xml"); f.typeOfShips = shipXML.Descendants("Attributes").Count(); //Debug.Log (f.FactionName); relationsListDictionary.Add(f.FactionName, f); } }
//setter for faction to commuicate with the other cells or local variables. public void setfac(Factions fac) { this.fac = fac; }
static void AddFaction(GameObject obj, Factions type) { Faction faction = obj.AddComponent <Faction>(); faction.type = type; }
public static void CreatePlayerInst() { string name; string className = ""; string raceName = ""; Factions faction = Factions.Admin; int alignment = 0; int gold = 0; int hp = 0; bool validRace = false; bool validClass = false; bool validFaction = false; Console.WriteLine("Give me your name."); Console.Write("> "); name = CapWord.FirstCharToUpper(Console.ReadLine()); while (validClass == false) { Console.WriteLine("What class would you like to be?"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("Warrior, Mage, Thief > "); className = Console.ReadLine().ToLower(); Console.ForegroundColor = ConsoleColor.White; if (className == "warrior") { gold = 100; validClass = true; } else if (className == "mage") { gold = 150; validClass = true; } else if (className == "thief") { gold = 200; validClass = true; } else { Console.WriteLine("Not a valid class"); } } while (validRace == false) { Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("What race would you like?"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("Human, Elf, Dwarf > "); raceName = Console.ReadLine().ToLower(); if (raceName == "human") { validRace = true; hp = 100; } else if (raceName == "elf") { validRace = true; hp = 80; } else if (raceName == "dwarf") { validRace = true; hp = 120; } else { Console.WriteLine("Not a Valid entry."); } } while (validFaction == false) { Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("To what faction do you belong?"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("Hero, Villion > "); string strFaction = CapWord.FirstCharToUpper(Console.ReadLine()); if (strFaction == Factions.Hero.ToString() || strFaction == Factions.Villain.ToString() || strFaction == Factions.Admin.ToString()) { faction = (Factions)Enum.Parse(typeof(Factions), strFaction, true); validFaction = true; } } Console.ForegroundColor = ConsoleColor.White; Player._player = new Player(name, CapWord.FirstCharToUpper(className), CapWord.FirstCharToUpper(raceName), gold, hp, hp, (Weapon)World.WeaponByID(103), false, true, faction, alignment); Console.WriteLine("Creating character data, please wait!"); SaveData.SaveGameData(Player._player); }
public override void ReadDataXML(XElement ele, ElderScrollsPlugin master) { XElement subEle; if (ele.TryPathTo("EditorID", false, out subEle)) { if (EditorID == null) { EditorID = new SimpleSubrecord <String>(); } EditorID.ReadXML(subEle, master); } if (ele.TryPathTo("ObjectBounds", false, out subEle)) { if (ObjectBounds == null) { ObjectBounds = new ObjectBounds(); } ObjectBounds.ReadXML(subEle, master); } if (ele.TryPathTo("Name", false, out subEle)) { if (Name == null) { Name = new SimpleSubrecord <String>(); } Name.ReadXML(subEle, master); } if (ele.TryPathTo("Model", false, out subEle)) { if (Model == null) { Model = new Model(); } Model.ReadXML(subEle, master); } if (ele.TryPathTo("ActorEffects", false, out subEle)) { if (ActorEffects == null) { ActorEffects = new List <RecordReference>(); } foreach (XElement e in subEle.Elements()) { RecordReference tempSPLO = new RecordReference(); tempSPLO.ReadXML(e, master); ActorEffects.Add(tempSPLO); } } if (ele.TryPathTo("Unarmed/AttackEffect", false, out subEle)) { if (UnarmedAttackEffect == null) { UnarmedAttackEffect = new RecordReference(); } UnarmedAttackEffect.ReadXML(subEle, master); } if (ele.TryPathTo("Unarmed/AttackAnimation", false, out subEle)) { if (UnarmedAttackAnimation == null) { UnarmedAttackAnimation = new SimpleSubrecord <UInt16>(); } UnarmedAttackAnimation.ReadXML(subEle, master); } if (ele.TryPathTo("Models", false, out subEle)) { if (Models == null) { Models = new SubNullStringList(); } Models.ReadXML(subEle, master); } if (ele.TryPathTo("TextureHashes", false, out subEle)) { if (TextureHashes == null) { TextureHashes = new SimpleSubrecord <Byte[]>(); } TextureHashes.ReadXML(subEle, master); } if (ele.TryPathTo("BaseStats", false, out subEle)) { if (BaseStats == null) { BaseStats = new CreatureBaseStats(); } BaseStats.ReadXML(subEle, master); } if (ele.TryPathTo("Factions", false, out subEle)) { if (Factions == null) { Factions = new List <FactionMembership>(); } foreach (XElement e in subEle.Elements()) { FactionMembership tempSNAM = new FactionMembership(); tempSNAM.ReadXML(e, master); Factions.Add(tempSNAM); } } if (ele.TryPathTo("DeathItem", false, out subEle)) { if (DeathItem == null) { DeathItem = new RecordReference(); } DeathItem.ReadXML(subEle, master); } if (ele.TryPathTo("VoiceType", false, out subEle)) { if (VoiceType == null) { VoiceType = new RecordReference(); } VoiceType.ReadXML(subEle, master); } if (ele.TryPathTo("Template", false, out subEle)) { if (Template == null) { Template = new RecordReference(); } Template.ReadXML(subEle, master); } if (ele.TryPathTo("Destructable", false, out subEle)) { if (Destructable == null) { Destructable = new Destructable(); } Destructable.ReadXML(subEle, master); } if (ele.TryPathTo("Script", false, out subEle)) { if (Script == null) { Script = new RecordReference(); } Script.ReadXML(subEle, master); } if (ele.TryPathTo("Contents", false, out subEle)) { if (Contents == null) { Contents = new List <InventoryItem>(); } foreach (XElement e in subEle.Elements()) { InventoryItem tempCNTO = new InventoryItem(); tempCNTO.ReadXML(e, master); Contents.Add(tempCNTO); } } if (ele.TryPathTo("AIData", false, out subEle)) { if (AIData == null) { AIData = new AIData(); } AIData.ReadXML(subEle, master); } if (ele.TryPathTo("Packages", false, out subEle)) { if (Packages == null) { Packages = new List <RecordReference>(); } foreach (XElement e in subEle.Elements()) { RecordReference tempPKID = new RecordReference(); tempPKID.ReadXML(e, master); Packages.Add(tempPKID); } } if (ele.TryPathTo("Animations", false, out subEle)) { if (Animations == null) { Animations = new SubNullStringList(); } Animations.ReadXML(subEle, master); } if (ele.TryPathTo("Data", false, out subEle)) { if (Data == null) { Data = new CreatureData(); } Data.ReadXML(subEle, master); } if (ele.TryPathTo("AttackReach", false, out subEle)) { if (AttackReach == null) { AttackReach = new SimpleSubrecord <Byte>(); } AttackReach.ReadXML(subEle, master); } if (ele.TryPathTo("CombatStyle", false, out subEle)) { if (CombatStyle == null) { CombatStyle = new RecordReference(); } CombatStyle.ReadXML(subEle, master); } if (ele.TryPathTo("BodyPartData", false, out subEle)) { if (BodyPartData == null) { BodyPartData = new RecordReference(); } BodyPartData.ReadXML(subEle, master); } if (ele.TryPathTo("TurningSpeed", false, out subEle)) { if (TurningSpeed == null) { TurningSpeed = new SimpleSubrecord <Single>(); } TurningSpeed.ReadXML(subEle, master); } if (ele.TryPathTo("BaseScale", false, out subEle)) { if (BaseScale == null) { BaseScale = new SimpleSubrecord <Single>(); } BaseScale.ReadXML(subEle, master); } if (ele.TryPathTo("FootWeight", false, out subEle)) { if (FootWeight == null) { FootWeight = new SimpleSubrecord <Single>(); } FootWeight.ReadXML(subEle, master); } if (ele.TryPathTo("ImpactMaterialType", false, out subEle)) { if (ImpactMaterialType == null) { ImpactMaterialType = new SimpleSubrecord <MaterialTypeUInt>(); } ImpactMaterialType.ReadXML(subEle, master); } if (ele.TryPathTo("SoundLevel", false, out subEle)) { if (SoundLevel == null) { SoundLevel = new SimpleSubrecord <SoundLevel>(); } SoundLevel.ReadXML(subEle, master); } if (ele.TryPathTo("SoundTemplate", false, out subEle)) { if (SoundTemplate == null) { SoundTemplate = new RecordReference(); } SoundTemplate.ReadXML(subEle, master); } if (ele.TryPathTo("SoundData", false, out subEle)) { if (SoundData == null) { SoundData = new List <CreatureSoundData>(); } foreach (XElement e in subEle.Elements()) { CreatureSoundData tempCSDT = new CreatureSoundData(); tempCSDT.ReadXML(e, master); SoundData.Add(tempCSDT); } } if (ele.TryPathTo("ImpactDataset", false, out subEle)) { if (ImpactDataset == null) { ImpactDataset = new RecordReference(); } ImpactDataset.ReadXML(subEle, master); } if (ele.TryPathTo("MeleeWeaponList", false, out subEle)) { if (MeleeWeaponList == null) { MeleeWeaponList = new RecordReference(); } MeleeWeaponList.ReadXML(subEle, master); } }
public virtual IQueryable <TEntity> Set <TEntity>() where TEntity : class { if (typeof(TEntity) == typeof(City)) { return((IQueryable <TEntity>)Cities.AsQueryable()); } if (typeof(TEntity) == typeof(CogTag)) { return((IQueryable <TEntity>)Tags.AsQueryable()); } if (typeof(TEntity) == typeof(Faction)) { return((IQueryable <TEntity>)Factions.AsQueryable()); } if (typeof(TEntity) == typeof(LocustHorde)) { return((IQueryable <TEntity>)Factions.OfType <LocustHorde>().AsQueryable()); } if (typeof(TEntity) == typeof(Gear)) { return((IQueryable <TEntity>)Gears.AsQueryable()); } if (typeof(TEntity) == typeof(Officer)) { return((IQueryable <TEntity>)Gears.OfType <Officer>().AsQueryable()); } if (typeof(TEntity) == typeof(Mission)) { return((IQueryable <TEntity>)Missions.AsQueryable()); } if (typeof(TEntity) == typeof(Squad)) { return((IQueryable <TEntity>)Squads.AsQueryable()); } if (typeof(TEntity) == typeof(SquadMission)) { return((IQueryable <TEntity>)SquadMissions.AsQueryable()); } if (typeof(TEntity) == typeof(Weapon)) { return((IQueryable <TEntity>)Weapons.AsQueryable()); } if (typeof(TEntity) == typeof(LocustLeader)) { return((IQueryable <TEntity>)LocustLeaders.AsQueryable()); } if (typeof(TEntity) == typeof(LocustHighCommand)) { return((IQueryable <TEntity>)LocustHighCommands.AsQueryable()); } throw new InvalidOperationException("Invalid entity type: " + typeof(TEntity)); }
// Start is called before the first frame update void Start() { Utility.gameObject = this.gameObject; Factions.DefaultInitialization(); // Destroy(this); }
public void SetReputation(Factions factionTarget, float amountOfChange) { matrixOfDiplomacy[(int)factionTarget] += amountOfChange; }
public GamePhase() { CurrentPhase = Phase.WaitingForSelect; Turn = Factions.Red; }
public void DeclareWar(Factions faction) { factionsAtWar[(int)faction] = true; }
public override bool FireEvent(Event E) { if (E.ID == "AIBored") { if (ParentObject.GetPart <Inventory>() != null) { if (XRLCore.Core.Game.TimeTicks - lastPlayed > 100) { lastPlayed = XRLCore.Core.Game.TimeTicks; foreach (GameObject GO in ParentObject.GetPart <Inventory>().GetObjects()) { if (GO.GetPart <acegiak_Musical>() != null) { GO.FireEvent(XRL.World.Event.New("InvCommandPlayTune", "Owner", ParentObject, "Object", GO)); } } } } } if (E.ID == "ShowConversationChoices" && !ParentObject.IsPlayer()) { if (XRLCore.Core.Game.Player.Body.GetPart <acegiak_SongBook>() != null && XRLCore.Core.Game.Player.Body.HasSkill("acegiak_Customs_Music")) { //IPart.AddPlayerMessage("My tags are:"+String.Join(", ",FactionTags(ParentObject.pBrain.GetPrimaryFaction()).ToArray())); if (this.Songs.Count > 0 && !this.learnedFrom) { if (E.GetParameter <ConversationNode>("CurrentNode") != null && E.GetParameter <ConversationNode>("CurrentNode") is WaterRitualNode) { WaterRitualNode wrnode = E.GetParameter <ConversationNode>("CurrentNode") as WaterRitualNode; List <ConversationChoice> Choices = E.GetParameter <List <ConversationChoice> >("Choices") as List <ConversationChoice>; if (Choices.Where(b => b.ID == "LearnSong").Count() <= 0) { bool canlearn = XRLCore.Core.Game.PlayerReputation.get(ParentObject.pBrain.GetPrimaryFaction()) > 50; ConversationChoice conversationChoice = new ConversationChoice(); conversationChoice.Text = (canlearn?"&G":"&K") + "Teach me to play &W" + this.Songs[0].Name + (canlearn?"&g":"&K") + " [" + (canlearn?"&C":"&r") + "-50" + (canlearn?"&g":"&K") + " reputation]"; conversationChoice.GotoID = "End"; conversationChoice.ParentNode = wrnode; conversationChoice.ID = "LearnSong"; conversationChoice.onAction = delegate() { if (!canlearn) { Popup.Show("You do not have enough reputation."); return(false); } XRLCore.Core.Game.Player.Body.GetPart <acegiak_SongBook>().Songs.Add(this.Songs[0]); this.learnedFrom = true; Popup.Show("You learned to play " + this.Songs[0].Name); JournalAPI.AddAccomplishment("You learned to play " + this.Songs[0].Name); JournalAPI.AddObservation(FactionInfo.getFormattedName(ParentObject.pBrain.GetPrimaryFaction()) + " play a song called \"" + this.Songs[0].Name + "\"", this.Songs[0].Name, "Songs", null, null, true); XRLCore.Core.Game.PlayerReputation.modify(Factions.get(ParentObject.pBrain.GetPrimaryFaction()).Name, -50, false); return(true); }; Choices.Add(conversationChoice); Choices.Sort(new ConversationChoice.Sorter()); // wrnode.Choices.Add(conversationChoice); // wrnode.SortEndChoicesToEnd(); E.SetParameter("CurrentNode", wrnode); } } } } } return(base.FireEvent(E)); }
public static void Build() { /** * We need to build each object to go into the Monster List. First we use the StreamReader * to open the Monsters text file that stores all the information that is need to create * the monsters. This file is formated to be in a certain order. Then we use the while loop * to assign the value to the variables one line at a time until we reach the end of the * text file. After we have assigned values to the variables we then pass the variables * to create the monster object that is then stored in the Monster List. */ #region Build Monster using (StreamReader reader = File.OpenText(@"../../../Engine/Docs/Monsters.txt")) { while (!reader.EndOfStream) { //string line = reader.ReadLine(); //string[] properties = GetNextLine(reader); int id = int.Parse(GetNextLine(reader)[1]); string name = GetNextLine(reader)[1]; int xp = int.Parse(GetNextLine(reader)[1]); int armor = int.Parse(GetNextLine(reader)[1]); int gold = int.Parse(GetNextLine(reader)[1]); string damage = GetNextLine(reader)[1]; int baseAttack = int.Parse(GetNextLine(reader)[1]); int currentHitpoints = int.Parse(GetNextLine(reader)[1]); int maxHitpoints = int.Parse(GetNextLine(reader)[1]); string image = GetNextLine(reader)[1]; bool isDead = bool.Parse(GetNextLine(reader)[1]); bool canBeattacked = bool.Parse(GetNextLine(reader)[1]); Factions faction = (Factions)Enum.Parse(typeof(Factions), GetNextLine(reader)[1], true); World.Monsters.Add(new Monster(id, name, xp, gold, armor, damage, baseAttack, currentHitpoints, maxHitpoints, image, isDead, canBeattacked, faction)); } } #endregion /** * We need to build each object to go into the NPC List. First we use the StreamReader * to open the NPC text file that stores all the information that is need to create * the monsters. This file is formated to be in a certain order. Then we use the while loop * to assign the value to the variables one line at a time until we reach the end of the * text file. After we have assigned values to the variables we then pass the variables * to create the NPC object that is then stored in the Monster List. */ #region Build NPC using (StreamReader reader = File.OpenText(@"../../../Engine/Docs/NPCs.txt")) { while (!reader.EndOfStream) { int id = int.Parse(reader.ReadLine()); string npcName = reader.ReadLine(); string npcClass = reader.ReadLine(); string npcRace = reader.ReadLine(); int gold = int.Parse(reader.ReadLine()); int currentHitpoints = int.Parse(reader.ReadLine()); int maxHitpoints = int.Parse(reader.ReadLine()); bool isDead = bool.Parse(reader.ReadLine()); bool canBeattacked = bool.Parse(reader.ReadLine()); Factions faction = (Factions)Enum.Parse(typeof(Factions), reader.ReadLine(), true); World.NPCs.Add(new NPC(id, npcName, npcClass, npcRace, gold, currentHitpoints, maxHitpoints, isDead, canBeattacked, faction)); } } #endregion /** * We need to build each object to go into the Weapon List. First we use the StreamReader * to open the Monsters text file that stores all the information that is need to create * the weaponss. This file is formated to be in a certain order. Then we use the while loop * to assign the value to the variables one line at a time until we reach the end of the * text file. After we have assigned values to the variables we then pass the variables * to create the weapon object that is then stored in the Weapon List. */ #region Build Weapon using (StreamReader reader = File.OpenText(@"../../../Engine/Docs/Weapon.txt")) { while (!reader.EndOfStream) { int id = int.Parse(reader.ReadLine()); string name = reader.ReadLine(); string namePluarl = reader.ReadLine(); string desc = reader.ReadLine(); int cost = int.Parse(reader.ReadLine()); string damage = reader.ReadLine(); string type = reader.ReadLine(); bool equiptable = bool.Parse(reader.ReadLine()); int wearLocation = int.Parse(reader.ReadLine()); World.Weapons.Add(new Weapon(id, name, namePluarl, desc, cost, damage, type, equiptable, wearLocation)); } } #endregion /** * We need to build each object to go into the Room List. First we use the StreamReader * to open the Monsters text file that stores all the information that is need to create * the rooms. This file is formated to be in a certain order. Then we use the while loop * to assign the value to the variables one line at a time until we reach the end of the * text file. After we have assigned values to the variables we then pass the variables * to create the room object that is then stored in the Rooms List. */ #region Build Room using (StreamReader reader = File.OpenText(@"../../../Engine/Docs/Room.txt")) { while (!reader.EndOfStream) { int id = int.Parse(reader.ReadLine()); string name = reader.ReadLine(); string descript = reader.ReadLine(); int exit1 = int.Parse(reader.ReadLine()); int exit2 = int.Parse(reader.ReadLine()); int exit3 = int.Parse(reader.ReadLine()); int exit4 = int.Parse(reader.ReadLine()); int idMonster = int.Parse(reader.ReadLine()); int idRmLoot = int.Parse(reader.ReadLine()); int idRoomNPC = int.Parse(reader.ReadLine()); World.Location.Add(new Room(id, name, descript, exit1, exit2, exit3, exit4, idMonster, idRmLoot, idRoomNPC)); } } #endregion /** * We need to build each object to go into the Items List. First we use the StreamReader * to open the Items text file that stores all the information that is need to create * the monsters. This file is formated to be in a certain order. Then we use the while loop * to assign the value to the variables one line at a time until we reach the end of the * text file. After we have assigned values to the variables we then pass the variables * to create the monster object that is then stored in the Monster List. */ #region Build Item using (StreamReader reader = File.OpenText(@"../../../Engine/Docs/Items.txt")) { while (!reader.EndOfStream) { int id = int.Parse(reader.ReadLine()); String name = reader.ReadLine(); String namePluarl = reader.ReadLine(); String desc = reader.ReadLine(); int cost = int.Parse(reader.ReadLine()); bool equiptable = bool.Parse(reader.ReadLine()); World.Items.Add(new Item(id, name, namePluarl, desc, cost, equiptable)); } } #endregion }
public int JoinFaction(params Faction[] factions) { Factions.UnionWith(factions); return(Factions.Count); }
public static List<Tile> FindTilesNotNextToEnemy(TacticsMovement origin, List<Tile> tiles, Factions opposingFaction) { List<Tile> filteredTiles = new List<Tile>(); List<Unit> opponents = new List<Unit>(); switch (opposingFaction) { case Factions.players: opponents = Initiative.players; break; case Factions.enemies: opponents = Initiative.enemies; break; default: break; } foreach (Tile t in tiles) { bool found = false; foreach (Unit opponent in opponents) { TacticsMovement opponentTactics = opponent.GetComponent<TacticsMovement>(); //The next line shouldn't be needed as tiles should be allocated when a unit moves into them. opponentTactics.GetCurrentTile(); //opponentTactics.currentTile.FindNeighbours(opponentTactics.jumpHeight, null); opponentTactics.currentTile.CheckNeighbours(opponentTactics.jumpHeight, null); foreach (Tile orthagonalTile in opponentTactics.currentTile.adjacencyList) { if (t == orthagonalTile) found = true; } foreach (Tile diagonalTile in opponentTactics.currentTile.diagonalAdjacencyList) { if (t == diagonalTile) found = true; } } if (!found) filteredTiles.Add(t); } return filteredTiles; }
public static Entity createPlayer(int skillLevel) { Entity e = ecs_instance.create(); GameMap gameMap = ComponentMapper.get <GameMap> (ecs_instance.tag_manager.get_entity_by_tag("MAP")); Vector2 pos = MapFactory.findSafeLocation(gameMap); //ECSInstance.entity_manager.add_component(e, new Position(new Vector2(576f, 360f),new Vector2(12.5f))); ecs_instance.add_component(e, new Position(pos, new Vector2(16))); //ECSInstance.entity_manager.add_component(e, new Position(new Vector2(0, 0), new Vector2(12.5f))); ecs_instance.add_component(e, new Velocity(4f)); ecs_instance.add_component(e, new Controllable()); //ECSInstance.entity_manager.add_component(e, new Sprite("characters\\lor_lar_sheet", "characters\\normals\\lor_lar_sheet_normals",32,32,0,0));; ecs_instance.add_component(e, AnimationFactory.createPlayerAnimation()); ecs_instance.add_component(e, new CameraFocus(75)); ecs_instance.add_component(e, new MapCollidable()); ecs_instance.add_component(e, new Heading()); ecs_instance.add_component(e, createLight(true, 8, new Vector3(new Vector2(576f, 360f), 10), 0.5f, new Vector4(1, 1, .6f, 1))); ecs_instance.add_component(e, new Transform()); Information info = new Information(); info.GeneralGroup = "HUMAN"; info.VariationGroup = "NONE"; info.UniqueGroup = "NONE"; info.Name = "PLAYER"; ecs_instance.add_component(e, info); //create life Life life = new Life(); life.IsAlive = true; life.DeathLongevity = 1000; ecs_instance.add_component(e, life); //create interactions Interactable interact = new Interactable(); interact.SupportedInteractions.PROJECTILE_COLLIDABLE = true; interact.SupportedInteractions.ATTACKABLE = true; interact.SupportedInteractions.MAY_RECEIVE_VICTORY = true; interact.SupportedInteractions.MAY_ADVANCE = true; interact.SupportedInteractions.CAUSES_ADVANCEMENT = false; interact.SupportedInteractions.AWARDS_VICTORY = false; ecs_instance.add_component(e, interact); //create test equipment ItemFactory iFactory = new ItemFactory(ecs_instance); ecs_instance.add_component(e, iFactory.createTestEquipment()); //setup experiences Knowledges knowledges = new Knowledges(); knowledges.GeneralKnowledge.Add("HUMAN", new Knowledge { Name = "", Value = skillLevel, KnowledgeType = KnowledgeType.General }); knowledges.GeneralKnowledge.Add("BAT", new Knowledge { Name = "", Value = skillLevel, KnowledgeType = KnowledgeType.General }); knowledges.VariationKnowledge.Add("NONE", new Knowledge { Name = "", Value = 0f, KnowledgeType = KnowledgeType.General }); knowledges.UniqueKnowledge.Add("NONE", new Knowledge { Name = "", Value = 0f, KnowledgeType = KnowledgeType.General }); ecs_instance.add_component(e, knowledges); //setup attributes Statistics statistics = new Statistics(); statistics.Focus = new Statistic { Name = "FOCUS", Value = skillLevel, StatType = StatType.FOCUS }; statistics.Endurance = new Statistic { Name = "ENDURANCE", Value = skillLevel, StatType = StatType.ENDURANCE }; statistics.Mind = new Statistic { Name = "MIND", Value = skillLevel, StatType = StatType.MIND }; statistics.Muscle = new Statistic { Name = "MUSCLE", Value = skillLevel, StatType = StatType.MUSCLE }; statistics.Perception = new Statistic { Name = "PERCEPTION", Value = skillLevel, StatType = StatType.PERCEPTION }; statistics.Personality = new Statistic { Name = "PERSONALITY", Value = skillLevel, StatType = StatType.PERSONALITY }; statistics.Quickness = new Statistic { Name = "QUICKNESS", Value = skillLevel, StatType = StatType.QUICKNESS }; ecs_instance.add_component(e, statistics); //create health Health health = new Health(statistics.Endurance.Value * 5); // new Health(5000);// health.RecoveryAmmount = statistics.Endurance.Value / 5; health.RecoveryRate = 1000; ecs_instance.add_component(e, health); //setup skills Skills skills = new Skills(); skills.Ranged = new Skill { Name = "RANGED", Value = skillLevel, SkillType = SkillType.Offensive }; skills.Avoidance = new Skill { Name = "AVOIDANCE", Value = skillLevel, SkillType = SkillType.Defensive }; skills.Melee = new Skill { Name = "MELEE", Value = skillLevel, SkillType = SkillType.Offensive }; ecs_instance.add_component(e, skills); Factions factions = new Factions(); factions.OwnerFaction = new Faction { Name = "PLAYER", Value = 100, FactionType = FactionType.Player }; factions.KnownFactions.Add("WILDERNESS", new Faction { Name = "WILDERNESS", Value = -10, FactionType = FactionType.Wilderness }); factions.KnownFactions.Add("ALLY", new Faction { Name = "ALLY", Value = 100, FactionType = FactionType.Ally }); ecs_instance.add_component(e, factions); GameSession.PlayerState = new PlayerState(); GameSession.PlayerState.Statistics = statistics; GameSession.PlayerState.Factions = factions; GameSession.PlayerState.Health = health; GameSession.PlayerState.Information = info; GameSession.PlayerState.Interactable = interact; GameSession.PlayerState.Knowledges = knowledges; GameSession.PlayerState.Life = life; GameSession.PlayerState.Skills = skills; ecs_instance.tag_manager.tag_entity("PLAYER", e); ecs_instance.resolve(e); return(e); }
/// <summary>Creates an attacking ship.</summary> /// <param name="startPosition">The start position.</param> /// <param name="targetPosition">The target position.</param> /// <param name="faction">The faction.</param> public void CreateAttackingShip(ref FarPosition startPosition, ref FarPosition targetPosition, Factions faction) { var ship = EntityFactory.CreateAIShip(Manager, "L1_AI_Ship", faction, startPosition, _random); var ai = ((ArtificialIntelligence)Manager.GetComponent(ship, ArtificialIntelligence.TypeId)); ai.AttackMove(ref targetPosition); }
public static float GetReaction( Factions from, Factions to ) { return reactions[ (int)from, (int)to ]; }
public Faction GetFaction(Factions faction) { return(_mapData.GetFaction(faction)); }
public static string RankMatrix(Factions faction, int rank) { switch (faction) { case Factions.QUANTAR: return quantarRankMatrix(rank); case Factions.SOLRAIN: return solrainRankMatrix(rank); case Factions.OCTAVIUS: return octavianRankMatrix(rank); default: throw new ArgumentOutOfRangeException("faction", "Not a valid faction!"); } }
public override void ReadData(ESPReader reader, long dataEnd) { while (reader.BaseStream.Position < dataEnd) { string subTag = reader.PeekTag(); switch (subTag) { case "EDID": if (EditorID == null) { EditorID = new SimpleSubrecord <String>(); } EditorID.ReadBinary(reader); break; case "OBND": if (ObjectBounds == null) { ObjectBounds = new ObjectBounds(); } ObjectBounds.ReadBinary(reader); break; case "FULL": if (Name == null) { Name = new SimpleSubrecord <String>(); } Name.ReadBinary(reader); break; case "MODL": if (Model == null) { Model = new Model(); } Model.ReadBinary(reader); break; case "SPLO": if (ActorEffects == null) { ActorEffects = new List <RecordReference>(); } RecordReference tempSPLO = new RecordReference(); tempSPLO.ReadBinary(reader); ActorEffects.Add(tempSPLO); break; case "EITM": if (UnarmedAttackEffect == null) { UnarmedAttackEffect = new RecordReference(); } UnarmedAttackEffect.ReadBinary(reader); break; case "EAMT": if (UnarmedAttackAnimation == null) { UnarmedAttackAnimation = new SimpleSubrecord <UInt16>(); } UnarmedAttackAnimation.ReadBinary(reader); break; case "NIFZ": if (Models == null) { Models = new SubNullStringList(); } Models.ReadBinary(reader); break; case "NIFT": if (TextureHashes == null) { TextureHashes = new SimpleSubrecord <Byte[]>(); } TextureHashes.ReadBinary(reader); break; case "ACBS": if (BaseStats == null) { BaseStats = new CreatureBaseStats(); } BaseStats.ReadBinary(reader); break; case "SNAM": if (Factions == null) { Factions = new List <FactionMembership>(); } FactionMembership tempSNAM = new FactionMembership(); tempSNAM.ReadBinary(reader); Factions.Add(tempSNAM); break; case "INAM": if (DeathItem == null) { DeathItem = new RecordReference(); } DeathItem.ReadBinary(reader); break; case "VTCK": if (VoiceType == null) { VoiceType = new RecordReference(); } VoiceType.ReadBinary(reader); break; case "TPLT": if (Template == null) { Template = new RecordReference(); } Template.ReadBinary(reader); break; case "DEST": if (Destructable == null) { Destructable = new Destructable(); } Destructable.ReadBinary(reader); break; case "SCRI": if (Script == null) { Script = new RecordReference(); } Script.ReadBinary(reader); break; case "CNTO": if (Contents == null) { Contents = new List <InventoryItem>(); } InventoryItem tempCNTO = new InventoryItem(); tempCNTO.ReadBinary(reader); Contents.Add(tempCNTO); break; case "AIDT": if (AIData == null) { AIData = new AIData(); } AIData.ReadBinary(reader); break; case "PKID": if (Packages == null) { Packages = new List <RecordReference>(); } RecordReference tempPKID = new RecordReference(); tempPKID.ReadBinary(reader); Packages.Add(tempPKID); break; case "KFFZ": if (Animations == null) { Animations = new SubNullStringList(); } Animations.ReadBinary(reader); break; case "DATA": if (Data == null) { Data = new CreatureData(); } Data.ReadBinary(reader); break; case "RNAM": if (AttackReach == null) { AttackReach = new SimpleSubrecord <Byte>(); } AttackReach.ReadBinary(reader); break; case "ZNAM": if (CombatStyle == null) { CombatStyle = new RecordReference(); } CombatStyle.ReadBinary(reader); break; case "PNAM": if (BodyPartData == null) { BodyPartData = new RecordReference(); } BodyPartData.ReadBinary(reader); break; case "TNAM": if (TurningSpeed == null) { TurningSpeed = new SimpleSubrecord <Single>(); } TurningSpeed.ReadBinary(reader); break; case "BNAM": if (BaseScale == null) { BaseScale = new SimpleSubrecord <Single>(); } BaseScale.ReadBinary(reader); break; case "WNAM": if (FootWeight == null) { FootWeight = new SimpleSubrecord <Single>(); } FootWeight.ReadBinary(reader); break; case "NAM4": if (ImpactMaterialType == null) { ImpactMaterialType = new SimpleSubrecord <MaterialTypeUInt>(); } ImpactMaterialType.ReadBinary(reader); break; case "NAM5": if (SoundLevel == null) { SoundLevel = new SimpleSubrecord <SoundLevel>(); } SoundLevel.ReadBinary(reader); break; case "CSCR": if (SoundTemplate == null) { SoundTemplate = new RecordReference(); } SoundTemplate.ReadBinary(reader); break; case "CSDT": if (SoundData == null) { SoundData = new List <CreatureSoundData>(); } CreatureSoundData tempCSDT = new CreatureSoundData(); tempCSDT.ReadBinary(reader); SoundData.Add(tempCSDT); break; case "CNAM": if (ImpactDataset == null) { ImpactDataset = new RecordReference(); } ImpactDataset.ReadBinary(reader); break; case "LNAM": if (MeleeWeaponList == null) { MeleeWeaponList = new RecordReference(); } MeleeWeaponList.ReadBinary(reader); break; default: throw new Exception(); } } }
void Start() { Time.timeScale = 1f; gameState = GameState.Playing; playerFaction = spawnedPlayer.GetComponent<Targetable>().faction; fxPlayer = GetComponent<FXPlayer>(); gameUI = GetComponent<GameUI>(); if(isTimed) InvokeRepeating("roundTimeCountdown", 1, 1); //spawnCoins(50, new Vector3(-1, 4, 8)); IntersceneData.instance.ApplyEquipment(spawnedPlayer); }
public override void WriteData(ESPWriter writer) { if (EditorID != null) { EditorID.WriteBinary(writer); } if (ObjectBounds != null) { ObjectBounds.WriteBinary(writer); } if (Name != null) { Name.WriteBinary(writer); } if (Model != null) { Model.WriteBinary(writer); } if (ActorEffects != null) { ActorEffects.Sort(); foreach (var item in ActorEffects) { item.WriteBinary(writer); } } if (UnarmedAttackEffect != null) { UnarmedAttackEffect.WriteBinary(writer); } if (UnarmedAttackAnimation != null) { UnarmedAttackAnimation.WriteBinary(writer); } if (Models != null) { Models.WriteBinary(writer); } if (TextureHashes != null) { TextureHashes.WriteBinary(writer); } if (BaseStats != null) { BaseStats.WriteBinary(writer); } if (Factions != null) { Factions.Sort(); foreach (var item in Factions) { item.WriteBinary(writer); } } if (DeathItem != null) { DeathItem.WriteBinary(writer); } if (VoiceType != null) { VoiceType.WriteBinary(writer); } if (Template != null) { Template.WriteBinary(writer); } if (Destructable != null) { Destructable.WriteBinary(writer); } if (Script != null) { Script.WriteBinary(writer); } if (Contents != null) { Contents.Sort(); foreach (var item in Contents) { item.WriteBinary(writer); } } if (AIData != null) { AIData.WriteBinary(writer); } if (Packages != null) { foreach (var item in Packages) { item.WriteBinary(writer); } } if (Animations != null) { Animations.WriteBinary(writer); } if (Data != null) { Data.WriteBinary(writer); } if (AttackReach != null) { AttackReach.WriteBinary(writer); } if (CombatStyle != null) { CombatStyle.WriteBinary(writer); } if (BodyPartData != null) { BodyPartData.WriteBinary(writer); } if (TurningSpeed != null) { TurningSpeed.WriteBinary(writer); } if (BaseScale != null) { BaseScale.WriteBinary(writer); } if (FootWeight != null) { FootWeight.WriteBinary(writer); } if (ImpactMaterialType != null) { ImpactMaterialType.WriteBinary(writer); } if (SoundLevel != null) { SoundLevel.WriteBinary(writer); } if (SoundTemplate != null) { SoundTemplate.WriteBinary(writer); } if (SoundData != null) { foreach (var item in SoundData) { item.WriteBinary(writer); } } if (ImpactDataset != null) { ImpactDataset.WriteBinary(writer); } if (MeleeWeaponList != null) { MeleeWeaponList.WriteBinary(writer); } }
public static bool IsInnocentAttackingFactioner( Mobile m, Factions.Faction f ) { if ( f == null ) return false; if ( Find( m ) == null ) { List<AggressorInfo> list = m.Aggressed; for ( int i = 0; i < list.Count; ++i ) { AggressorInfo info = list[i]; if ( Find( info.Defender ) == f ) return true; } } return false; }
private void LoadLevelInfo(StreamReader stream) { m_levelID = uint.Parse(SaveSlot.Extract(stream.ReadLine())); m_faction = FactionHelper.StringToFactions(SaveSlot.Extract(stream.ReadLine())); }