public static ICreature CreateCreature(Creatures creatureType, Vector2 worldIndex, World world) { if (creatureType == Creatures.GiantBat) { return(CreateGiantBat(worldIndex, world)); } else if (creatureType == Creatures.SkeletonWarrior) { return(CreateSkeletonWarrior(worldIndex, world)); } else if (creatureType == Creatures.Octopus) { return(CreateOctopus(worldIndex, world)); } else if (creatureType == Creatures.Golem) { return(CreateGolem(worldIndex, world)); } else if (creatureType == Creatures.ManEatingPlant) { return(CreateManEatingPlant(worldIndex, world)); } else if (creatureType == Creatures.WalkingDragon) { return(CreateWalkingDragon(worldIndex, world)); } else if (creatureType == Creatures.FireSpirit) { return(CreateFireSpirit(worldIndex, world)); } else { throw new NotImplementedException("Unknown creature type."); } }
private void Creature_Click(object sender, EventArgs e) { //Getting a reference to the selected creature using the TAG property of the picturebox. if (sender is PictureBox) { PictureBox selectedCreature = (PictureBox)sender; //Get the name of the creature from the TAG property string nameOfTheCreature = selectedCreature.Tag.ToString(); //using LINQ to find the selected creature from the Creatures list SelectedCreature = Creatures.First(creture => creture.Name == nameOfTheCreature); //You can also do a for each loop to find the selected creature //foreach (var creature in Creatures) //{ // if (creature.Name == nameOfTheCreature) // { // SelectedCreature = creature; // } //} //Showing all instructions and elements on the creen CreatureInstructions.Visible = FeedButton.Visible = CommunicateButton.Visible = SelectedCreatureDetails.Visible = ResetButton.Visible = true; //Turning off all border styling on creature elements Crush.BorderStyle = Phat.BorderStyle = SwimShady.BorderStyle = WaterDragon.BorderStyle = BorderStyle.None; //Adding border style to the selected creature selectedCreature.BorderStyle = BorderStyle.FixedSingle; //Height = 500; } }
public void ApplyDamage(int damage) { int currentHP = hp; if (damage > currentHP) { hp = Creatures.Get(creatureId).hp; count--; if (count == 0) { dead = true; return; } damage -= currentHP; while (damage >= Creatures.Get(creatureId).hp) { damage -= Creatures.Get(creatureId).hp; count--; if (count == 0) { dead = true; return; } } } hp -= damage; SetCounter(count); SetHP(hp); }
public override string ToString() { StringBuilder sb = new StringBuilder(); StringBuilder sbCreatures = new StringBuilder(); for (int y = 0; y < BoundingRect.Height; y++) { for (int x = 0; x < BoundingRect.Width; x++) { Point p = new Point(x, y); if (Walls.Contains(p)) { sb.Append("#"); } else if (Creatures.ContainsKey(p)) { sb.Append(Creatures[p].Symbol); sbCreatures.Append($"{Creatures[p].Symbol}({Creatures[p].HitPoints}),"); } else { sb.Append("."); } } sb.Append("\t"); sb.Append(sbCreatures); sbCreatures.Clear(); sb.Append("\n"); } //foreach (var kvp in Creatures) sb.Append($"{kvp.Key} ({kvp.Value.Symbol}): HP {kvp.Value.HitPoints}\n"); return(sb.ToString()); }
/// <summary> /// Updates the world /// </summary> /// <param name="fractionElapsed">A fraction of the simulation time</param> public void Update(double fractionElapsed) { //All the fields grow Parallel.ForEach <Field[]>(Fields, column => { foreach (var field in column) { field.GrowCalories(fractionElapsed); } }); //Creatures update, if they split newborns are added and if they die, they are removed creaturesToDie.Clear(); creaturesToBirth.Clear(); Parallel.ForEach <Creature.Creature>(Creatures, creature => { var newBorn = creature.Update(fractionElapsed); if (creature.ShouldDie()) { lock (creaturesToDie) { creaturesToDie.Add(creature); } } else if (newBorn != null) { lock (creaturesToBirth) { creaturesToBirth.Add(newBorn); } } }); foreach (var deadCreature in creaturesToDie) { Creatures.Remove(deadCreature); if (deadCreature == SelectedCreature) { SelectedCreature = null; } } foreach (var newBorn in creaturesToBirth) { Creatures.AddFirst(newBorn); } //New creatures replace the dead ones if (Creatures.Count < MinCreatures) { for (int i = 0; i < MinCreatures - Creatures.Count; i++) { AddCreature(new Creature.Creature(this)); } } //Old creatures over the max die for (int i = 0; i < Creatures.Count - maxCreatures; i++) { if (Creatures.Last.Value == SelectedCreature) { SelectedCreature = null; } Creatures.RemoveLast(); } }
public static void Run() { // AoS : Array Of Structures Creature[] creatures = new Creature[100]; foreach (Creature creature in creatures) { /* * * here is a performance problem * if we ignore .net wrapper around Creature object * the representation in ram will be [Age X Y Age X Y ......] * so processor pointer need to jump know steps to locate the location of values * but this will be more efficient if we store values like * [Age Age Age ...], [X X X ...], [Y Y Y ...] * so we need to separate it in different arrays * and this what we will do in Creatures Class * */ creature.Y++; } // SoA : Structure Of Arrays var hpCreatures = new Creatures(100); foreach (Creatures.CreatureProxy creature in hpCreatures) { creature.X++; } }
public Creatures.AttackResult Attack(Creatures attacker, Creatures target, int BonusAcc = 0) { int delta = attacker.GetResultStat(Stats.Accuracy) - target.GetResultStat(Stats.Dodge) + BonusAcc; int ranNum = Random.Range(0, 101); double deltad = delta / (1 + 0.1 * DgnInfo.DgnLvl); if (deltad > 40) { deltad = 40; } ranNum += (int)deltad; if ((ranNum >= 25) && (ranNum <= 50)) { return(Creatures.AttackResult.Glance); } else { if ((ranNum > 50) && (ranNum <= 100)) { return(Creatures.AttackResult.Hit); } else { if (ranNum > 100) { return(Creatures.AttackResult.Crit); } else { return(Creatures.AttackResult.Miss); } } } }
public void SpawnCreatureCorpse(Vector3 spawnPosition, string causeOfDeath, float timeSinceDeath) { Location location = null; if (worlditem.Is <Location>(out location)) { gCorpsePosition.Position = location.LocationGroup.tr.InverseTransformPoint(spawnPosition); Creature deadCreature = null; if (Creatures.SpawnCreature(this, location.LocationGroup, gCorpsePosition.Position, out deadCreature)) { deadCreature.State.IsDead = true; } /*Debug.Log("Spawning creature at position " + spawnPosition.ToString()); * WorldItem corpse = null; * if (WorldItems.CloneWorldItem ("Corpses", "Bone Pile 1", gCorpsePosition, true, location.LocationGroup, out corpse)) { * CreatureTemplate t = null; * Creatures.GetTemplate (State.NameOfCreature, out t); * corpse.Initialize (); * FillStackContainer fsc = corpse.Get <FillStackContainer> (); * fsc.State.WICategoryName = t.Props.InventoryFillCategory; * if (corpse.Is (WIActiveState.Active)) { * fsc.TryToFillContainer (true); * } * }*/ } }
public void CreaturesAdd(Creature _creature, Point _inBlockCoords) { if (Creatures.Any(_pair => _pair.Value == _inBlockCoords)) { throw new ApplicationException(); } //var busy = new List<Point>(); //while (Creatures.Any(_pair => _pair.Value == _inBlockCoords)) //{ // busy.Add(_inBlockCoords); // var lt = _creature[0, 0].InBlockCoords; // foreach (var point in new Point(Constants.MAP_BLOCK_SIZE / 2, Constants.MAP_BLOCK_SIZE / 2).GetSpiral(Constants.MAP_BLOCK_SIZE / 2 - 1)) // { // if (_creature[point - lt].GetIsPassableBy(_creature) > 0 && !busy.Contains(point)) // { // _inBlockCoords = point; // break; // } // } //} Creatures.Add(_creature, _inBlockCoords); //if (_creature.GeoInfo != null) //{ // _creature.GeoInfo.WorldCoords = WorldCoords + _inBlockCoords; //} }
private void OpenDiplomacyConversation(WorldManager World) { World.Paused = true; var name = ""; if (Creatures.Count > 0) { name = Creatures.First().Stats.FullName; } else { name = TextGenerator.ToTitleCase(TextGenerator.GenerateRandom(Datastructures.SelectRandom(OwnerFaction.Race.NameTemplates).ToArray())); } // Prepare conversation memory for an envoy conversation. var cMem = World.ConversationMemory; cMem.SetValue("$world", new Yarn.Value(World)); cMem.SetValue("$envoy", new Yarn.Value(this)); cMem.SetValue("$envoy_demands_tribute", new Yarn.Value(this.TributeDemanded != 0)); cMem.SetValue("$envoy_tribute_demanded", new Yarn.Value((float)this.TributeDemanded.Value)); cMem.SetValue("$envoy_name", new Yarn.Value(name)); cMem.SetValue("$envoy_faction", new Yarn.Value(OwnerFaction.ParentFaction.Name)); cMem.SetValue("$player_faction", new Yarn.Value(this.OtherFaction)); cMem.SetValue("$offensive_trades", new Yarn.Value(0)); cMem.SetValue("$trades", new Yarn.Value(0)); var politics = World.Overworld.GetPolitics(OtherFaction.ParentFaction, OwnerFaction.ParentFaction); cMem.SetValue("$faction_was_at_war", new Yarn.Value(politics.IsAtWar)); cMem.SetValue("$envoy_relationship", new Yarn.Value(politics.GetCurrentRelationship().ToString())); GameStateManager.PushState(new YarnState(OwnerFaction.World, OwnerFaction.Race.DiplomacyConversation, "Start", cMem)); }
void Update() { if (test) { CastleDB DB = new CastleDB(CastleDBAsset, CastleDBImagesAsset); Creatures creature = DB.Creatures["Dragon"]; Debug.Log("[string] name: " + creature.Name); Debug.Log("[bool] attacks player: " + creature.attacksPlayer); Debug.Log("[int] base damage: " + creature.BaseDamage); Debug.Log("[float] damage modifier: " + creature.DamageModifier); Debug.Log("[enum] death sound: " + creature.DeathSound); Debug.Log("[flag enum] spawn areas: " + creature.SpawnAreas); foreach (var item in creature.DropsList) { Debug.Log($"{creature.Name} drops item {item.item} at rate {item.DropChance}"); foreach (var effect in item.PossibleEffectsList) { Debug.Log($"item has effect {effect.effect} with chase {effect.EffectChance}"); } } textureToRender = creature.DropsList[0].item.image; test = false; } }
public void SetupButton(Creatures aTurnHolder, Skills aSkill, bool aSkillSize) { m_ButtonTurnHolder = aTurnHolder; m_ButtonSkill = aSkill; m_SkillType = aSkill.GetSkillType(); SetElementalIcon(aSkill.GetElementalType()); m_Text_NameOfSkill.text = aSkill.m_SkillName; if (aSkill.m_SkillName == "") { m_Text_NameOfSkill.text = "Name Is Empty"; } int SkillSize = aSkillSize ? m_ButtonSkill.m_MultiTargetCost : m_ButtonSkill.m_SingleTargetCost; if (m_ButtonTurnHolder.m_CurrentMana <= SkillSize) { m_Text_NameOfSkill.color = m_Color_HalfTransparentWhite; } else if (m_ButtonTurnHolder.m_CurrentMana >= SkillSize) { m_Text_NameOfSkill.color = m_Color_White; } m_CostToUseText.text = SkillSize.ToString(); }
public virtual void ButtonDown(Block listener, Block button) { if (button.IsA(Block.Type.REDBUTTON)) { Game g = Game.Instance; GameLevel gl = g.Level; BlockContainer bc = gl.GetBlockContainer(listener); // Take the first creature and clone it Block b = bc.Upper; if (b.Creature || b.IsBlock()) { BlockContainer moveTo = gl.GetBlockContainer(b, b.Facing); if (moveTo.CanMoveTo(b)) { try { Block clone = g.BlockFactory.Get(b.getType(), b.Facing); Point p = b.Point; // Move.updatePoint(p, b.getFacing()); if (clone.Creature && !(clone.IsA(Block.Type.TEETH) || clone.IsA(Block.Type.BLOB) || clone.IsA(Block.Type.FIREBALL))) { g.AddBlockDelay(clone, p, 3); } else { gl.AddBlock(p.X, p.Y, clone, 2); gl.MoveBlock(clone, clone.Facing, true, false); if (clone.Creature) { Creatures.AddCreature(clone); } } } catch (BlockContainerFullException) { // Ignore for now. TODO: Fix } } } try { b.Clone(); if (b.Creature) { Creatures.Boss = b; } } catch (Exception) { // System.out.println("Couldn't clone " + b); // Ignore } } }
public void RemoveDeadFromList(Creatures aDeadCreature) { if (aDeadCreature.charactertype == Creatures.Charactertype.Ally) { for (int i = m_TurnOrderAlly.Count - 1; i >= 0; i--) { if (m_TurnOrderAlly[i] == aDeadCreature) { m_TurnOrderAlly.RemoveAt(i); } } } if (aDeadCreature.charactertype == Creatures.Charactertype.Enemy) { for (int i = m_TurnOrderEnemy.Count - 1; i >= 0; i--) { if (m_TurnOrderEnemy[i] == aDeadCreature) { m_TurnOrderEnemy.RemoveAt(i); } } if (m_TurnOrderEnemy.Count == 0) { EndCombat(); } } }
void Update() { if (test) { #if SAMPLECDBFILE_CDBIMPORT var DB = new SampleCDBFile(CastleDBAsset); Creatures creature = DB.Creatures.Dragon; Debug.Log("[string] name: " + creature.Name); Debug.Log("[bool] attacks player: " + creature.attacksPlayer); Debug.Log("[int] base damage: " + creature.BaseDamage); Debug.Log("[float] damage modifier: " + creature.DamageModifier); Debug.Log("[enum] death sound: " + creature.DeathSound); Debug.Log("[flag enum] spawn areas: " + creature.Spawn_Areas); Debug.Log("[color] color: <color=#" + ColorUtility.ToHtmlStringRGBA(creature.Color) + ">" + creature.Color.ToString() + "</color>"); Debug.Log("[img] image : " + creature.Icon.name); dragonTex = creature.Icon; GetComponent <MeshRenderer>().material.SetTexture("_MainTex", creature.Icon); foreach (var item in creature.DropsList) { Debug.Log($"{creature.Name} drops item {item.item} at rate {item.DropChance}"); foreach (var effect in item.PossibleEffectsList) { Debug.Log($"item has effect {effect.effect} with chase {effect.EffectChance}"); } } #endif } test = false; }
public override void OnStartup() { CheckTemplate(); //create body for creature CreatureBody body = null; if (!Creatures.GetBody(Template.Props.BodyName, out body)) { Debug.Log("Couldn't get body in creature " + State.TemplateName); return; } else { GameObject newBody = GameObject.Instantiate(body.gameObject, worlditem.tr.position, Quaternion.identity) as GameObject; Body = newBody.GetComponent <CreatureBody> (); } //set the body's eye colors Body.HostileEyeColor = Color.red; Body.TimidEyeColor = Color.green; Body.AggressiveEyeColor = Color.yellow; Body.ScaredEyeColor = Color.white; //don't set the body's parent or name //let the body stay in the world to keep the heirarchy clean //Body.transform.parent = worlditem.Group.transform; //Body.name = worlditem.FileName + "-Body"; //if we're dead, we need to set the body to ragdoll right away }
public async Task ReloadData() { Creatures.Clear(); dataLoaded = false; pcsAdded = false; await LoadData(); }
public void BuildGraph() { AdjacencyList = new Dictionary <Point, List <Point> >(); for (int y = 0; y < BoundingRect.Height; y++) { for (int x = 0; x < BoundingRect.Width; x++) { Point p = new Point(x, y); if (Walls.Contains(p) || Creatures.ContainsKey(p)) { continue; } AdjacencyList.Add(p, new List <Point>()); List <Point> adjacentList = Fifteen.AdjacentPoints(p); foreach (Point ap in adjacentList) { if (Walls.Contains(ap) || Creatures.ContainsKey(ap)) { continue; } AdjacencyList[p].Add(ap); } } } }
protected void swap(ref Creatures xp, ref Creatures yp) { Creatures temp = xp; xp = yp; yp = temp; }
public void ReserveToParty(int CurrentPartyPosition, int CurrentReservePosition) { Creatures TransferBuffer = m_CurrentParty[CurrentPartyPosition]; m_CurrentParty[CurrentPartyPosition] = m_ReservePartymembers[CurrentReservePosition]; m_ReservePartymembers[CurrentReservePosition] = TransferBuffer; }
static void Main(string[] args) { Console.Clear(); CustomEvents.Game.OnGameLoad += load => { //Start caching objects Creatures.Load(); Structures.Load(); //Check for updates Helpers.Updater(); //Initialize AutoLeveler new AutoLevel(LevelSequences.GetSequence().Select(num => num - 1).ToArray()); AutoLevel.Enable(); //Load Champion Plugin new PluginLoader(); }; Game.OnUpdate += tick => { EasyPositioning.Update(); Behaviors.Tree.Root.Tick(); }; }
void Start() { combatOver = false; Creatures.PrepareCreatures(); if (PersistentData.state != PersistentData.State.EnteringCombat) { PregenerateArmies(); PersistentData.state = PersistentData.State.EnteringCombat; } armies = new List <CombatMonsterGroup>(); GenerateMap(); PrepareArmies(); pathfinder = new Pathfinder(); mainCamera = Camera.main.gameObject.GetComponent <CameraController>(); mainCamera.SetConstraint( -mapWidth / 2 * tilePrefab.transform.localScale.x - 4, mapWidth / 2 * tilePrefab.transform.localScale.x + 4, 5, 5, -mapHeight / 2 * tilePrefab.transform.localScale.z - 3, mapHeight / 2 * tilePrefab.transform.localScale.z - 3 ); highlightedTiles = new List <Tile>(); NextTurn(); #if UNITY_EDITOR DynamicGI.UpdateEnvironment(); #endif }
public ArkTribe() { // Relations _creatures = new Lazy <ArkTamedCreature[]>(() => { ArkTamedCreature[] creatures = null; return(_gameData?._tribeTamedCreatures.TryGetValue(Id, out creatures) == true ? creatures : new ArkTamedCreature[] { }); }); _structures = new Lazy <ArkStructure[]>(() => { ArkStructure[] structures = null; return(_gameData?._tribeStructures.TryGetValue(Id, out structures) == true ? structures : new ArkStructure[] { }); }); _items = new Lazy <ArkItem[]>(() => Structures.SelectMany(x => x.Inventory) .Concat(Creatures.SelectMany(x => x.Inventory)).Where(ArkItem.Filter_RealItems).ToArray()); _creatureTypes = new Lazy <Dictionary <string, ArkTamedCreature[]> >(() => Creatures.GroupBy(x => x.ClassName).ToDictionary(x => x.Key, x => x.ToArray())); _structureTypes = new Lazy <Dictionary <string, ArkStructure[]> >(() => Structures.GroupBy(x => x.ClassName).ToDictionary(x => x.Key, x => x.ToArray())); _itemTypes = new Lazy <Dictionary <string, ArkItemTypeGroup> >(() => Items.GroupBy(x => x.ClassName).ToDictionary(x => x.Key, x => new ArkItemTypeGroup(x.ToArray()))); _members = new Lazy <ArkPlayer[]>(() => { ArkPlayer[] members = null; return(_gameData?._tribePlayers.TryGetValue(Id, out members) == true ? members : new ArkPlayer[] { }); }); _lastActiveTime = new Lazy <DateTime>(() => Members.Length > 0 ? Members.Max(y => y.LastActiveTime) : SavedAt); }
public void EnemyMovement() { FindAllPaths(); m_NodeInWalkableRange = GetAvailableEnemysInRange(m_Grid.m_GridPathList, Node_ObjectIsOn, m_EnemyRange); List <Creatures> m_AllysInRange = new List <Creatures>(); foreach (FloorNode node in m_NodeInWalkableRange) { if (CheckIfAllyIsOnNode(node)) { m_AllysInRange.Add(node.m_CreatureOnGridPoint); } } if (m_AllysInRange.Count > 0) { Creatures CharacterInRange = m_Behaviour.AllyToAttack(m_AllysInRange); FloorNode NodeNeightboringAlly = Grid.instance.CheckNeighborsForLowestNumber(CharacterInRange.m_CreatureAi.m_Position); if (NodeNeightboringAlly != null) { SetGoalPosition(NodeNeightboringAlly.m_PositionInGrid); return; } else { Debug.Log(gameObject.name + " Failed to be able to get to node "); return; } } }
public override List <Creatures> GetAvailableTargets(RoomType room, Creatures user) { List <Creatures> availableTargets = new List <Creatures>(); if (user is Monsters) { foreach (Hero m in room.Heroes) { if (m.Alive) { availableTargets.Add(m); } } } else { foreach (Monsters m in room.Mobs) { if (m.Alive) { availableTargets.Add(m); } } } return(availableTargets); }
public void SetCreature(Creatures aCreature) { m_Creatures = aCreature; m_NameTag.text = aCreature.name; MaxTerritoryValue = aCreature.m_CreatureAi.m_NodeInDomainRange.Count; TerritoryValue = aCreature.m_CreatureAi.m_NodeInDomainRange.Count; m_TerritoryText.text = TerritoryValue.ToString(); }
private void AssignFittness() { for (int i = 0; i < numberOfCreatures; i++) { Creatures c = creatures[i].GetComponent <Creatures>(); cnetworks[i].SetFitness((c.distanceCovered / c.timeAlive) + c.distanceCovered); } }
public void AddCreature(Creature creature) { if (Creatures == null) { Creatures = new List <Creature>(); } Creatures.Add(creature); }
/// <summary> /// отменяет активацию способности и сопутствующий ему блок интерфейса SelectionLock /// </summary> public void DisactivateAbility() { TurnOnSelectCircles(false); SelectedAbility = null; SelectedTarget = null; SelectFrame.SetActive(false); SelectionLock = false; }
private async void SaveCreatures() { foreach (var creature in Creatures.ToList()) // create a copy of the list, so it is not modified while looping { creature.EncounterId = Id; await creature.Save(); } }
protected override void OnCollision(Creatures.Minion m) { List<Minion> minions = WorldMap.Instance.GetMinions(); foreach (Minion minion in minions) { float dist = 0; Vector2 minionPosition = new Vector2(minion.Position.X + 0.5f, minion.Position.Y + 0.5f); Vector2 towerPosition = new Vector2(Position.X + 1, Position.Y + 1); Vector2.Distance(ref minionPosition, ref towerPosition, out dist); if (dist <= _range) { minion.AddMinionBuff(new FireBuff(minion)); } } base.OnCollision(m); }
protected override void OnCollision(Creatures.Minion m) { List<Minion> minions = WorldMap.Instance.GetMinions(); foreach (Minion minion in minions) { float dist = 0; Vector2 minionPosition = new Vector2(minion.Position.X + 0.5f, minion.Position.Y + 0.5f); Vector2 towerPosition = new Vector2(Position.X + 1, Position.Y + 1); Vector2.Distance(ref minionPosition, ref towerPosition, out dist); if (dist <= _range) { float damage = _explosionDamage * (1 - (dist / _range)); DamageRules.DamageMinion(damage, Buildings.DamageType.Explosion, minion); } } base.OnCollision(m); }
public static ICreature CreateCreature(Creatures creatureType, Vector2 worldIndex, World world) { if (creatureType == Creatures.GiantBat) return CreateGiantBat(worldIndex, world); else if (creatureType == Creatures.SkeletonWarrior) return CreateSkeletonWarrior(worldIndex, world); else if (creatureType == Creatures.Octopus) return CreateOctopus(worldIndex, world); else if (creatureType == Creatures.Golem) return CreateGolem(worldIndex, world); else if (creatureType == Creatures.ManEatingPlant) return CreateManEatingPlant(worldIndex, world); else if (creatureType == Creatures.WalkingDragon) return CreateWalkingDragon(worldIndex, world); else if (creatureType == Creatures.FireSpirit) return CreateFireSpirit(worldIndex, world); else { throw new NotImplementedException("Unknown creature type."); } }
public override Behavior.Selector ActivateBehavior(Creatures.Dwarf d) { d.SetActionPasture(PastureSim); return new WorkPasture(); }