//每帧都会调用对应的实体 public override void Execute(List <BasicEntity> entities) { foreach (BasicEntity e in entities) { AttackComponent attack = e.GetComponent <AttackComponent> (); VoxelBlocks map = GameObject.Find("Voxel Map").transform.GetComponent <VoxelBlocks> (); AbilityComponent ab = e.GetComponent <AbilityComponent> (); InputComponent input = e.GetComponent <InputComponent> (); StateComponent ap = e.GetComponent <StateComponent> (); int i = AiToInput.GetAbilityCount(e, M_LinkedType); //检测是否按下攻击键 if (i >= ab.m_temporaryAbility.Count || i != input.currentKey) { continue; } //若无攻击对象则获取周围可攻击对象 if (attack.enemy == null) { attack.enemy = GetEnemyAround(e); if (attack.enemy == null) { return; } } List <Vector3> el = new List <Vector3> (); foreach (var enemy in attack.enemy) { el.Add(enemy.GetComponent <BlockInfoComponent> ().m_logicPosition); } UISimple ui = GameObject.Find("UI").GetComponent <UISimple> (); ui.ShowUI(el, 2); //左键攻击 if (input.leftButtonDown) { BasicEntity enemy = map.GetBlockByLogicPos(input.currentPos).entity; //检测当前选中敌人是否处于攻击范围内 List <BasicEntity> list = GetEnemyAround(e); if (list != null && !list.Contains(enemy)) { attack.enemy = list; return; } //扣除敌人HP值 DeadComponent dead = enemy.GetComponent <DeadComponent> (); StateComponent state = e.GetComponent <StateComponent> (); dead.hp -= attack.STR; state.m_actionPoint -= 1; state.Invoke("AnimationEnd", 1); state.AnimationStart(); //播放攻击动画 //播放敌人受击动画 //减少AP } } }
void Start() { rb = GetComponent <Rigidbody2D>(); stateComponent = GetComponent <StateComponent>(); stateComponent.iniPosition = rb.position; GameObject theWorld = GameObject.Find("TheWorld"); worldComponent = theWorld.GetComponent <FreezeWorldComponent>(); nonObstacles.Add("Orb"); nonObstacles.Add("Key"); nonObstacles.Add("Door"); nonObstacles.Add("Enemy"); nonObstacles.Add("Upper"); nonObstacles.Add("Downer"); nonObstacles.Add("Hazard"); nonObstacles.Add("Platform"); nonObstacles.Add("DialogueTrigger"); nonObstacles.Add("GrabbableObject"); nonObstacles.Add("Player"); nonObstacles.Add("Button"); nonObstacles.Add("IceBall"); nonObstacles.Add("FireBall"); nonObstacles.Add("Trigger"); nonObstacles.Add("DefenseRange"); nonObstacles.Add("Barrier"); nonObstacles.Add("FireBallUpgrade"); jumpTimeCounter = jumpTime; }
private void LoadStateComponent(GameEntity entity, StateComponentInfo info) { var comp = new StateComponent(); entity.AddComponent(comp); comp.LoadInfo(info); }
public override void AddComponents() { base.AddComponents(); if (Interactable()) { AddComponent(new InteractableComponent(Interact) { CanInteract = CanInteract }); } AddComponent(new AudioEmitterComponent { DestroySounds = false }); var state = new StateComponent(); AddComponent(state); if (LockedByDefault) { state.Become <IdleState>(); locked = true; } else { state.Become <OpenState>(); locked = false; } AddTag(Tags.Lock); }
private static Entity CreateEntity(Guid team, HexCoords coords, int attackPower = 1) { var state = new StateComponent() { CanAct = true }; var stats = new StatsComponent() { Health = 10, AttackRange = 1, AttackSpeed = 100, AttackPower = attackPower, MovementSpeed = 100 }; return(new Entity( new TeamComponent() { Team = team }, new LocationComponent() { StartingCoords = coords }, state, new AttackComponent(new PubSub.Hub(), state, stats), new MovementComponent(new PubSub.Hub(), stats), new SpellComponent(), stats )); }
public static Entity ConstructEntityFromCharacterData(HexCoords position, StarEntity character, Guid playerId, Hub simulationHub) { var state = new StateComponent(); var stats = new StatsComponent() { Health = character.Health, AttackRange = character.AttackRange, Armor = character.Armor, MagicArmor = character.MagicResist, AttackSpeed = character.AttackSpeed, MovementSpeed = character.Movespeed, AttackPower = character.AttackDamage, Name = character.Name, StarLevel = character.StarLevel }; return(new Entity( new LocationComponent() { StartingCoords = position }, new TeamComponent() { Team = playerId }, stats, new SpellComponent(), new MovementComponent(simulationHub, stats), new AttackComponent(simulationHub, state, stats), state )); }
public override void _Ready() { CharacterSprite = this.GetChildNode <Sprite>(nameof(CharacterSprite)); AnimationPlayer = this.GetChildNode <AnimationPlayer>(); CollisionShape2D = this.GetChildNode <CollisionShape2D>(nameof(CollisionShape2D)); State = this.GetChildNode <StateComponent>(); Stats = this.GetChildNode <Stats>(); CharacterHitBox = this.GetChildNode <CharacterHitBox>(); CharacterHitBox.Disable(); CharacterHurtBox = this.GetChildNode <CharacterHurtBox>(); BlinkAnimationPlayer = this.GetChildNodeOrNull <AnimationPlayer>(nameof(BlinkAnimationPlayer)); CharacterHurtBox.Connect(nameof(CharacterHurtBox.DamageReceived), this, nameof(ReceiveDamage)); HpIndicator = this.GetChildNode <HpIndicator>(); HpIndicator.Visible = true; Stats.Connect(nameof(Stats.HpWasChanged), HpIndicator, nameof(HpIndicator.OnChangeHp)); Stats.Connect(nameof(Stats.MaxHpWasChanged), HpIndicator, nameof(HpIndicator.OnChangeMaxHP)); HpIndicator.UpdateHealthIndication(); InvincibilityComponent = this.GetChildNode <InvincibilityComponent>(); InvincibilityComponent.Connect(nameof(InvincibilityComponent.InvincibilityStarted), this, nameof(StartInvincibility)); InvincibilityComponent.Connect(nameof(InvincibilityComponent.InvincibilityEnded), this, nameof(EndInvincibility)); }
public static void OnBeginPlay() { Debug.Log(LogLevel.Display, "Hello, Unreal Engine!"); Debug.AddOnScreenMessage(-1, 3.0f, Color.LightGreen, MethodBase.GetCurrentMethod().DeclaringType + " system started!"); World.GetFirstPlayerController().SetViewTarget(World.GetActor <Camera>("MainCamera")); const int eighthEntities = maxEntities / 8; for (int i = 0; i < maxEntities; i++) { string entityName = "Entity" + (i > 0 ? i.ToString() : String.Empty); entities[i] = new Entity(entityName); entities[i].CreateMesh(1.0f, "StateComponent", true); entities[i].StateComponent.SetRelativeRotation(Quaternion.CreateFromYawPitchRoll(5.0f * i, 0.0f, 0.0f)); entities[i].StateComponent.CreateAndSetMaterialInstanceDynamic(0).SetVectorParameterValue("Color", new LinearColor((float)random.NextDouble(), (float)random.NextDouble(), (float)random.NextDouble())); if (i < eighthEntities) { entities[i].StateComponent.SetRelativeLocation(new Vector3(i == 0 ? -100.0f : -100.0f * (i + i + 1), 100.0f, 0.0f)); } else if (i < eighthEntities * 2) { entities[i].StateComponent.SetRelativeLocation(new Vector3(i == 0 ? 100.0f : 100.0f * (i + i + 1 - eighthEntities * 2), 100.0f, 0.0f)); } else if (i < eighthEntities * 3) { entities[i].StateComponent.SetRelativeLocation(new Vector3(i == 0 ? -100.0f : -100.0f * (i + i + 1 - eighthEntities * 4), -100.0f, 0.0f)); } else if (i < eighthEntities * 4) { entities[i].StateComponent.SetRelativeLocation(new Vector3(i == 0 ? 100.0f : 100.0f * (i + i + 1 - eighthEntities * 6), -100.0f, 0.0f)); } else if (i < eighthEntities * 5) { entities[i].StateComponent.SetRelativeLocation(new Vector3(i == 0 ? -100.0f : -100.0f * (i + i + 1 - eighthEntities * 8), 300.0f, 0.0f)); } else if (i < eighthEntities * 6) { entities[i].StateComponent.SetRelativeLocation(new Vector3(i == 0 ? 100.0f : 100.0f * (i + i + 1 - eighthEntities * 10), 300.0f, 0.0f)); } else if (i < eighthEntities * 7) { entities[i].StateComponent.SetRelativeLocation(new Vector3(i == 0 ? -100.0f : -100.0f * (i + i + 1 - eighthEntities * 12), -300.0f, 0.0f)); } else if (i < eighthEntities * 8) { entities[i].StateComponent.SetRelativeLocation(new Vector3(i == 0 ? 100.0f : 100.0f * (i + i + 1 - eighthEntities * 14), -300.0f, 0.0f)); } Entity entity = World.GetActor <Entity>(entityName); StateComponent component = entity.GetComponent <StateComponent>(); Assert.IsTrue(entity.Equals(entities[i])); Assert.IsTrue(component.Equals(entities[i].StateComponent)); } Debug.AddOnScreenMessage(-1, 3.0f, Color.LightGreen, "Actors are spawned! Number of actors in the world: " + World.ActorCount); }
protected override void Update(float dt) { Vector3 zero = Vector3.zero; for (EntityRenderNode entityRenderNode = this.nodeList.Head; entityRenderNode != null; entityRenderNode = entityRenderNode.Next) { Vector3 vector = zero; SmartEntity smartEntity = (SmartEntity)entityRenderNode.Entity; GameObjectViewComponent gameObjectViewComp = smartEntity.GameObjectViewComp; StateComponent stateComp = smartEntity.StateComp; EntityState rawState = stateComp.RawState; if (rawState == EntityState.Moving) { PathView pathView = smartEntity.PathingComp.PathView; if (pathView != null) { pathView.TimeOnPathSegment += dt; vector = this.entityRenderController.MoveGameObject(gameObjectViewComp, pathView, smartEntity.SizeComp.Width); } } if (rawState != EntityState.Dying) { this.entityRenderController.RotateGameObject(smartEntity, vector.x, vector.z, dt); } else if (smartEntity.TroopComp != null) { gameObjectViewComp.UpdateAllAttachments(); } if (smartEntity.TroopComp != null || smartEntity.DroidComp != null) { bool isAbilityModeActive = smartEntity.TroopComp != null && smartEntity.TroopComp.IsAbilityModeActive; this.entityRenderController.UpdateAnimationState(gameObjectViewComp, stateComp, isAbilityModeActive); } } }
public void Escape(BasicEnemy enemy) { BasicEntity entity = enemy.m_entity; VoxelBlocks map = GameObject.Find("Voxel Map").GetComponent <VoxelBlocks> (); List <BasicEntity> enemyList = entity.GetComponent <MonitorComponent> ().m_enemy; if (AiToInput.CallFriend(entity, enemyList)) { //呼叫成功 StateComponent state = entity.GetComponent <StateComponent> (); state.AnimationStart(); state.m_actionPoint -= 1; state.Invoke("AnimationEnd", 1); return; } Vector3 escapePos = FindPath.GetNearestFriend(entity.GetComponent <BlockInfoComponent> ().m_logicPosition); if (escapePos == Vector3.down) { //无路可走等死 return; } else { AiToInput.Move(entity, escapePos); } return; }
public static void OnBeginPlay() { Debug.AddOnScreenMessage(-1, 3.0f, Color.LightGreen, MethodBase.GetCurrentMethod().DeclaringType + " system started!"); World.GetFirstPlayerController().SetViewTarget(World.GetActor <Camera>("MainCamera")); for (int i = 0; i < maxEntities; i++) { string entityName = "Entity" + (i > 0 ? i.ToString() : String.Empty); entities[i] = new Entity(entityName); entities[i].CreateMesh(1.0f, "StateComponent", true); entities[i].StateComponent.SetRelativeRotation(Maths.CreateFromYawPitchRoll(5.0f * i, 0.0f, 0.0f)); entities[i].StateComponent.CreateAndSetMaterialInstanceDynamic(0).SetVectorParameterValue("Color", new LinearColor((float)random.NextDouble(), (float)random.NextDouble(), (float)random.NextDouble())); entities[i].StateComponent.SetRelativeLocation(new Vector3(0.0f, 0.0f, 120.0f * i)); entities[i].StateComponent.AddLocalOffset(new Vector3(0.0f, 0.0f, -420.0f)); Entity entity = World.GetActor <Entity>(entityName); StateComponent component = entity.GetComponent <StateComponent>(); Assert.IsTrue(entity.Equals(entities[i])); Assert.IsTrue(component.Equals(entities[i].StateComponent)); } Debug.AddOnScreenMessage(-1, 3.0f, Color.LightGreen, "Actors are spawned! Number of actors in the world: " + World.ActorCount); }
/// @param stateComponent /// The state component to modify /// @param state /// The state to safely set /// public static void SafeState(this StateComponent stateComponent, string state) { if (stateComponent != null) { stateComponent.SetState(state); } }
public void UpdateAnimationState(Animator anim, StateComponent stateComp) { if (stateComp.Dirty) { if (anim == null) { return; } if (!anim.gameObject.activeInHierarchy) { return; } while (stateComp.Dirty) { EntityState entityState = stateComp.DequeuePrevState(); if (entityState == EntityState.AttackingReset) { anim.Play("", 0, 0f); } } switch (stateComp.CurState) { case EntityState.Idle: anim.SetInteger("Motivation", 0); return; case EntityState.Moving: anim.SetInteger("Motivation", 1); return; case EntityState.Tracking: break; case EntityState.Turning: anim.SetInteger("Motivation", 1); return; case EntityState.WarmingUp: anim.SetInteger("Motivation", 4); return; case EntityState.Attacking: case EntityState.AttackingReset: anim.SetInteger("Motivation", 3); return; case EntityState.CoolingDown: anim.SetInteger("Motivation", 4); return; case EntityState.Dying: anim.SetInteger("Motivation", 2); break; default: return; } } }
void Bomb(BasicEntity entity, float mr, float ridus, int demage) { InputComponent input = entity.GetComponent <InputComponent>(); VoxelBlocks map = GameObject.Find("Voxel Map").GetComponent <VoxelBlocks>(); //获取鼠标位置与角色位置的距离 float r = (input.currentPos - entity.GetComponent <BlockInfoComponent>().m_logicPosition).magnitude; //若距离大于预设值则退出 if (r > mr) { return; } //获取炸弹投掷后可能影响的范围 List <Vector3> ar = FindPath.GetArea(input.currentPos, Mathf.FloorToInt(ridus)); //显示炸弹影响范围 List <DeadComponent> mc = new List <DeadComponent>(); UISimple ui = GameObject.Find("UI").GetComponent <UISimple>(); ui.ShowUI(ar, 3); //获取该范围内所有的敌人的生命脚本 foreach (var pos in ar) { BlockInfo block = map.GetBlockByLogicPos(pos); if (block != null && block.entity != null) { if (block.entity.GetComponent <BlockInfoComponent>().m_blockType == BlockType.Enemy) { mc.Add(block.entity.GetComponent <DeadComponent>()); } } } //显示可被影响的敌人 //若按下鼠标左键则扔出炸弹,影响周围敌人。 if (input.leftButtonDown) { Debug.Log(mc.Count); foreach (var m in mc) { if (m != null) { m.hp -= demage; } } ItemComponent itemComp = entity.GetComponent <ItemComponent>(); //移除炸弹 itemComp.item.Remove(ItemType.Bomb); entity.GetComponent <ItemComponent>().current = ItemType.Null; //使用一次消耗一点行动点 StateComponent state = entity.GetComponent <StateComponent>(); state.m_actionPoint -= 1; state.AnimationStart(); state.Invoke("AnimationEnd", 1); } }
void Start() { physicsComponent = GetComponent <PhysicsComponent>(); stateComponent = GetComponent <StateComponent>(); rb = GetComponent <Rigidbody2D>(); Physics2D.IgnoreLayerCollision(8, 9, false); Physics2D.IgnoreLayerCollision(8, 11, false); }
public CharacterState AddComponent(StateComponent newComponent) { newComponent.parent = this; components.Add(newComponent); newComponent.Init(); return(this); }
private void AddMandatoryComponents(int entityId) { var stateComponent = new StateComponent(); var tagComponent = new TagComponent(); ComponentManager.Instance.AddComponentToEntity(stateComponent, entityId); ComponentManager.Instance.AddComponentToEntity(tagComponent, entityId); }
public void TestStateComponentInitialisation() { StateComponent <TestStates> actual = new StateComponent <TestStates>(TestStates.s1); TestStates expected = TestStates.s1; Assert.AreEqual(expected, actual.Peek(), "Test that the initialising state is the one passed in the constructor"); }
public override void Execute(List <BasicEntity> entities) { foreach (BasicEntity e in entities) { AIComponent aiInfo = e.GetComponent <AIComponent>(); if (aiInfo == null) { continue; } if (aiInfo.m_enemyState == EnemyState.Action) { //Debug.Log (StateStaticComponent.m_currentEntity + " aciont is going"); AbilityManager abilityManager = new AbilityManager(); abilityManager.RemoveTemppraryComponent(e); aiInfo.m_enemyState = EnemyState.Select; } //只有在系统结束工作之后才会重新开始执行 if (aiInfo.m_enemyState == EnemyState.Wait) { StateComponent state = (StateComponent)e.GetSpecicalComponent(ComponentType.State); //增加输入组件 AbilityManager abilityManager = new AbilityManager(); //根据能力表新建新的组件 abilityManager.AddTemporaryComponent(e); if (state.m_actionPoint > 0) { //切换状态 aiInfo.m_enemyState = EnemyState.Select; aiInfo.m_enemy.Execute(); } else { if (aiInfo.m_coldTime < aiInfo.m_actionInterval) { aiInfo.m_coldTime += Time.deltaTime; } else { aiInfo.m_coldTime = 0; state.m_actionPoint = e.GetComponent <PropertyComponent>().AP; aiInfo.m_enemyState = EnemyState.Select; aiInfo.m_enemy.Execute(); } } } //if (turnNumber - StateStaticComponent.m_EturnNumber != 0) //{ // turnNumber++; // if (StateStaticComponent.m_EcurrentEntity == e) // { // AIComponent aiComponent = (AIComponent)e.GetSpecicalComponent(ComponentType.AI); // aiComponent.m_enemy.Execute(); // } //} } }
private StateComponent GetOrAdd(StateId id) { if (!this.parent.TryGetValue(id, out var component)) { component = new StateComponent(); this.parent.Add(id, component); } return(component as StateComponent); }
protected override void InitializePreLoadComponent() { var stateComponent = new StateComponent <StateHolder>(); SetComponent(stateComponent); stateComponent.AfterReadState += StateComponent_AfterReadState; _autoSave = new AutoSaveStateComponent(AutoSaveStateComponent.PerMinute); SetComponent(_autoSave); }
public override bool Verify(StateComponent statesComponent) { _button = _inputAction.activeControl as ButtonControl; if (_button != null) { return(_button.isPressed); } return(false); }
public override void Execute(List <BasicEntity> entities) { foreach (var entity in entities) { KnockComponent knock = entity.gameObject.GetComponent <KnockComponent>(); AbilityComponent ab = entity.GetComponent <AbilityComponent>(); InputComponent input = entity.GetComponent <InputComponent>(); StateComponent ap = entity.GetComponent <StateComponent>(); int i = AiToInput.GetAbilityCount(entity, M_LinkedType); if (i >= ab.m_temporaryAbility.Count || i != input.currentKey) { knock.m_area = null; continue; } //获取影响范围 if (knock.m_area == null) { knock.m_area = FindPath.GetArea(knock.GetComponent <BlockInfoComponent>().m_logicPosition, knock.m_ridus); } UISimple ui = GameObject.Find("UI").GetComponent <UISimple>(); ui.ShowUI(knock.m_area, 3); VoxelBlocks map = GameObject.Find("Voxel Map").GetComponent <VoxelBlocks>(); List <BasicEntity> enemy = new List <BasicEntity>(); //获取影响范围内的敌人 foreach (var pos in knock.m_area) { var e = map.GetBlockByLogicPos(pos).entity; if (e != null) { if (e.GetComponent <BlockInfoComponent>().m_blockType == BlockType.Enemy) { enemy.Add(e); } } } //UI显示范围与敌人 if (input.leftButtonDown) { foreach (var e in enemy) { Debug.Log(e.name); e.GetComponent <MonitorComponent>().m_voice.Add(entity.GetComponent <BlockInfoComponent>().m_logicPosition); } ui.ShowUI(null, 3); StateComponent state = entity.GetComponent <StateComponent>(); state.m_actionPoint -= 1; state.AnimationStart(); state.Invoke("AnimationEnd", 1); } } }
public void TestStateComponentPush() { StateComponent <TestStates> actual = new StateComponent <TestStates>(TestStates.s1); actual.Push(TestStates.s2); TestStates expected = TestStates.s2; Assert.AreEqual(expected, actual.Peek(), "Test that the peeked state after a push is the topmost state"); }
protected override void InitializePreLoadComponent() { var stateComponent = new StateComponent <StateHolder>(); SetComponent(stateComponent); stateComponent.AfterReadState += StateComponent_AfterReadState; stateComponent.SetDefaultState += StateComponent_SetDefaultState; SetComponent(new PeriodicSaveStateComponent(TimeSpan.FromMinutes(1))); }
public void TestStateSwitch() { StateComponent <TestStates> actual = new StateComponent <TestStates>(TestStates.s1); actual.Switch(TestStates.s3); TestStates expected = TestStates.s3; Assert.AreEqual(expected, actual.Peek(), "Test that the state has changed once the stateis asked to switch"); }
public void TestStateComponentPop() { StateComponent <TestStates> actual = new StateComponent <TestStates>(TestStates.s1); actual.Push(TestStates.s2); actual.Pop(); TestStates expected = TestStates.s1; Assert.AreEqual(expected, actual.Peek(), "Test that the peeked state is the same after a push and pop"); }
public Effect Load(IEffectPartInfo info) { var newstate = ((StateEffectPartInfo)info).Name; return(entity => { StateComponent state = entity.GetComponent <StateComponent>(); if (state != null) { state.ChangeState(newstate); } }); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { var stateComponent = new StateComponent(this); var gameState = new GameState(stateComponent.StateMachine); stateComponent.StateMachine.Add("game", gameState); // Start the game by entering the 'menu' state stateComponent.StateMachine.Change("game", true); Components.Add(stateComponent); base.Initialize(); }
void Start() { player = GameObject.Find("Player"); exitTrapdoor = GameObject.Find("ExitTrapdoor"); playerStateComponent = player.GetComponent <StateComponent>(); teleportPoints = new List <Transform>(); GameObject[] teleportSpawns = GameObject.FindGameObjectsWithTag("BossTeleport"); foreach (GameObject teleportSpawn in teleportSpawns) { teleportPoints.Add(teleportSpawn.transform); } worldState.Add("PlayerInDefenseRange", false); worldState.Add("PassedFireBallTimeLimit", false); worldState.Add("ZeroHealthPoints", false); currentTeleportPoint = teleportPoints[0].position; ActionNode dieNode = new ActionNode(); dieNode.actionMethod = Die; ActionNode attackNode = new ActionNode(); attackNode.actionMethod = Attack; ActionNode teleportNode = new ActionNode(); teleportNode.actionMethod = Teleport; ActionNode idleNode = new ActionNode(); idleNode.actionMethod = Idle; BinaryNode attackDecisionNode = new BinaryNode(); attackDecisionNode.yesNode = attackNode; attackDecisionNode.noNode = idleNode; attackDecisionNode.decision = "PassedFireBallTimeLimit"; BinaryNode teleportDecisionNode = new BinaryNode(); teleportDecisionNode.yesNode = teleportNode; teleportDecisionNode.noNode = attackDecisionNode; teleportDecisionNode.decision = "PlayerInDefenseRange"; BinaryNode dieDecisionNode = new BinaryNode(); dieDecisionNode.yesNode = dieNode; dieDecisionNode.noNode = teleportDecisionNode; dieDecisionNode.decision = "ZeroHealthPoints"; decisionTree = dieDecisionNode; }
private void LoadEntity(XElement xml) { GameEntity entity = new GameEntity(); string name = xml.RequireAttribute("name").Value; if (entities.ContainsKey(name)) throw new GameXmlException(xml, "You have defined two entities both named \"" + name + "\"."); entity.Name = name; entity.MaxAlive = xml.TryAttribute<int>("limit", 50); SpriteComponent spritecomp = null; PositionComponent poscomp = null; StateComponent statecomp = new StateComponent(); entity.AddComponent(statecomp); try { foreach (XElement xmlComp in xml.Elements()) { switch (xmlComp.Name.LocalName) { case "EditorData": break; case "Tilesheet": if (spritecomp == null) { spritecomp = new SpriteComponent(); entity.AddComponent(spritecomp); } if (poscomp == null) { poscomp = new PositionComponent(); entity.AddComponent(poscomp); } spritecomp.LoadTilesheet(xmlComp); break; case "Trigger": statecomp.LoadStateTrigger(xmlComp); break; case "Sprite": if (spritecomp == null) { spritecomp = new SpriteComponent(); entity.AddComponent(spritecomp); } if (poscomp == null) { poscomp = new PositionComponent(); entity.AddComponent(poscomp); } spritecomp.LoadXml(xmlComp); break; case "Position": if (poscomp == null) { poscomp = new PositionComponent(); entity.AddComponent(poscomp); } poscomp.LoadXml(xmlComp); break; case "Death": entity.OnDeath += EffectParser.LoadTriggerEffect(xmlComp); break; case "GravityFlip": entity.IsGravitySensitive = xmlComp.GetValue<bool>(); break; default: entity.GetOrCreateComponent(xmlComp.Name.LocalName).LoadXml(xmlComp); break; } } } catch (GameXmlException ex) { ex.Entity = name; throw; } entities.Add(name, entity); }