public void Register(GameComponent item) { _newRegisteredElement = true; _gameComponents.Add(item); if (item is RenderableGameComponent) _renderer.Register(item as RenderableGameComponent); }
public void AddToInventory(GameComponent item) { if (!Full) { inventory.Add(item); } }
public Health(ComponentManager manager, string name, GameComponent parent, float maxHealth, float minHealth, float currentHp) : base(name, parent) { InitializeResistance(); MaxHealth = maxHealth; MinHealth = minHealth; Hp = currentHp; }
public void AddItem(String layerName, GameComponent item) { ItemLayer layer = GetLayer(layerName); // TODO [Null模式实现] 优化请求层不存在情况处理 if(layer == null) { layer = new ItemLayer(); layer.Name = layerName; CurScene.Layers.Add(layer); } layer.Add(item); }
public bool Has(GameComponent item) { if(!(item is IEquippable)) { Debug.LogError("Inventory on " + gameObject.name + " was passed a non-equippable object: " + item.name); return false; } if (inventory.Contains(item)) { return true; } return false; }
public void DeleteItem(GameComponent item) { foreach (ItemLayer itemMgr in Layers) { foreach (GameComponent i in itemMgr.ItemList) { int itemId = itemMgr.ItemList.IndexOf(item); if (itemId == -1) { Console.WriteLine("错误:要删除的Item不存在于列表中!"); return; } itemMgr.ItemList[itemId].Unload(); itemMgr.ItemList.RemoveAt(itemId); return; } } Console.WriteLine("警告:场景管理器中不存在对指定Item的引用!"); }
public override bool CanBeAppliedTo(GameComponent Entity, WorldManager World) { return((World.UserInterface.Tools["DeconstructObjects"] as DeconstructObjectTool).CanDestroy(Entity)); }
public static MaybeNull <CombinationTable.Combination> FindPossibleCombination(Rail.JunctionPiece Piece, GameComponent Entity) { if (Entity is RailEntity) { var baseJunction = (Entity as RailEntity).GetPiece(); if (Library.GetRailPiece(baseJunction.RailPiece).HasValue(out var basePiece)) { var relativeOrientation = Rail.OrientationHelper.Relative(baseJunction.Orientation, Piece.Orientation); if (basePiece.Name == Piece.RailPiece && relativeOrientation == PieceOrientation.North) { return new CombinationTable.Combination { Result = basePiece.Name, ResultRelativeOrientation = PieceOrientation.North } } ; var matchingCombination = Library.FindRailCombination(basePiece.Name, Piece.RailPiece, relativeOrientation); return(matchingCombination); } } return(null); }
public override void Execute(GameComponent go) { go.Dig(); base.Execute(go); }
public override bool CanBeAppliedTo(GameComponent Entity, WorldManager World) { if (Entity.GetComponent <CreatureAI>().HasValue(out var creature) && Entity.GetComponent <DwarfThoughts>().HasValue(out var thoughts)) { return(World.PlayerFaction.Minions.Contains(creature)); }
private void MoveToUpperLayer(GameComponent item, GameComponentCollection itemList) { int layer = itemList.IndexOf(item); int MaxLayer = itemList.Count - 1; if (layer == MaxLayer) { Console.WriteLine("信息:该Item已经处于顶层"); return; } // 寻找最近一个覆盖它的Item GameComponent curItem = itemList[layer]; Transform curTrans = curItem.Children.QueryComponent<Transform>(); if ( curTrans == null) return; Rectangle curRect = curTrans.GetOrthoBox(); GameComponent upperItem = null; int upLayer = -1; for (int i = layer + 1; i <= MaxLayer; i++) { GameComponent compItem = itemList[i]; Transform compTrans = compItem.Children.QueryComponent<Transform>(); if (compItem == null) continue; Rectangle compRect = compTrans.GetOrthoBox(); if (curRect.Intersects(compRect)) { upperItem = compItem; upLayer = i; break; } } if (upperItem == null) { Console.WriteLine("信息:该Item未被任Item覆盖"); return; } // 移动 MoveTo(layer, upLayer, itemList); //SetTypeList(itemList); }
public virtual void Remove(GameComponent item) { ItemList.Remove(item); }
public override bool CanBeAppliedTo(GameComponent Entity, WorldManager World) { return(Entity.Tags.Contains("Vegetation")); }
public static ScreenComponent ToScreenComponent(this GameComponent component, IScreen screen, DisplayLayer index) { return(new GameComponentWrapper(component, screen, index)); }
public static ScreenComponent ToScreenComponent(this GameComponent component, IScreen screen) { return(component.ToScreenComponent(screen, DisplayLayer.None)); }
public GameComponentWrapper(GameComponent component, IScreen screen, DisplayLayer index) : base(screen, index) { Wrapped = component; }
void FadableButton_MouseEnter(GameComponent sender, MouseEvent mouseEvent) { mouseOn = true; }
void FadableButton_MouseLeave(GameComponent sender, MouseEvent mouseEvent) { mouseOn = false; }
public void MoveToBottom(GameComponent item) { MoveToBottom(item, GetContainLayer(item).ItemList); }
private void OpenBattleJustHero(String scene, int upgradeLevel) { string civilianUpgradeLevelTag = Campaign.Current.Models.LocationModel.GetCivilianUpgradeLevelTag(upgradeLevel); GameComponent.OpenBattleJustHero(scene, civilianUpgradeLevelTag); }
private void MoveToLowerLayer(GameComponent item, GameComponentCollection itemList) { int layer = itemList.IndexOf(item); if (layer == 0) { Console.WriteLine("信息:该Item已经处于底层"); return; } // 寻找最近一个被覆盖的Item GameComponent curItem = itemList[layer]; Transform curTrans = curItem.Children.QueryComponent<Transform>(); if (curTrans == null) return; Rectangle curRect = curTrans.GetOrthoBox(); GameComponent lowerItem = null; int lowerLayer = -1; for (int i = layer - 1; i >= 0; i--) { GameComponent compItem = itemList[i]; Transform compTrans = item.Children.QueryComponent<Transform>(); if (compItem == null) continue; Rectangle compRect = compTrans.GetOrthoBox(); if (curRect.Intersects(compRect)) { lowerItem = compItem; lowerLayer = i; break; } } if (lowerItem == null) { Console.WriteLine("信息:该Item未覆盖任何其他Item"); return; } // 移动 MoveTo(layer, lowerLayer, itemList); //SetTypeList(itemList); }
public void AddComponent(GameComponent component) { this._components.Add(component); }
public virtual void notifyChildDetached(GameComponent component) { removeChild(component); } // 通知该组件有子组件断开了联系
public override void Apply(GameComponent Entity, WorldManager World) { var creature = Entity.GetComponent <CreatureAI>(); creature.Chat(); }
public virtual void Delete(GameComponent item) { deleteItems.Add(item); }
public GroupTestSystem(GameEntity testEntity, GameComponent testComponent) { _testEntity = testEntity; _testComponent = testComponent; }
public virtual void notifyComponentDestroied(GameComponent component) { removeComponentFromList(component); }
public override void Update() { base.Update(); if (Enabled) { if (SkippedAnimTicks++ > 12) { SkippedAnimTicks = 0; int NewDir = (int)Direction + 1; if (NewDir >= 4) { Direction = (Directions)(4 - NewDir); } else { Direction = (Directions)NewDir; } } GEntity[] Ranges = new GEntity[] { new GEntity(Owner, X, Y + H / 2 - SRange / 2, W, SRange / 2, Directions.Unknown), new GEntity(Owner, X + W / 2, Y, SRange / 2, H, Directions.Unknown), new GEntity(Owner, X, Y + H / 2, W, SRange / 2, Directions.Unknown), new GEntity(Owner, X + W / 2 - SRange / 2, Y, SRange / 2, H, Directions.Unknown) }; List <Player>[] InRangePlayers = new List <Player>[] { GameLevel.GetIntersectingPlayers(Ranges[0], IntersectionType.BY_DIFF_OWNER), GameLevel.GetIntersectingPlayers(Ranges[1], IntersectionType.BY_DIFF_OWNER), GameLevel.GetIntersectingPlayers(Ranges[2], IntersectionType.BY_DIFF_OWNER), GameLevel.GetIntersectingPlayers(Ranges[3], IntersectionType.BY_DIFF_OWNER) }; bool PlayersInRange = false; double MinDist = GameComponent.GetScreenWidth() * GameComponent.GetScreenHeight(); for (int i = 0; i < InRangePlayers.Length; ++i) { InRangePlayers[i].Sort( delegate(Player A, Player B) { return(GetTwoPointsDist(A.X, X, A.Y, Y).CompareTo(GetTwoPointsDist(B.X, X, B.Y, Y))); } ); if (InRangePlayers[i].Count > 0) { double Dist = GetTwoPointsDist(InRangePlayers[i][0].X, X, InRangePlayers[i][0].Y, Y); if (i == 2 || Dist < MinDist) { MinDist = Dist; Direction = (Directions)i; PlayersInRange = true; } } } bool TurretsInRange = false; if (!PlayersInRange) { List <GEntity>[] InRangeTurrets = new List <GEntity>[] { GameLevel.GetIntersectingEntities(Ranges[0], IntersectionType.BY_DIFF_OWNER), GameLevel.GetIntersectingEntities(Ranges[1], IntersectionType.BY_DIFF_OWNER), GameLevel.GetIntersectingEntities(Ranges[2], IntersectionType.BY_DIFF_OWNER), GameLevel.GetIntersectingEntities(Ranges[3], IntersectionType.BY_DIFF_OWNER) }; MinDist = GameComponent.GetScreenWidth() * GameComponent.GetScreenHeight(); List <GEntity> Turrets = new List <GEntity>(); for (int i = 0; i < InRangeTurrets.Length; ++i) { Turrets.Clear(); foreach (GEntity E in InRangeTurrets[i]) { if (E.Type == EntityType.TURRET && E.Owner != Owner) { Turrets.Add(E); } } Turrets.Sort( delegate(GEntity A, GEntity B) { return(GetTwoPointsDist(A.X, X, A.Y, Y).CompareTo(GetTwoPointsDist(B.X, X, B.Y, Y))); } ); if (Turrets.Count > 0) { double Dist = GetTwoPointsDist(Turrets[0].X, X, Turrets[0].Y, Y); if (Dist < MinDist) { MinDist = Dist; Direction = (Directions)i; TurretsInRange = true; } } } } if (PlayersInRange || TurretsInRange) { Shoot(); } } }
public void RemoveComponent(GameComponent cmp) { components.Remove(cmp); rootNode.RemoveChild(cmp.rootNode); }
public void RemoveFromInventory(GameComponent item) { inventory.Remove(item); }
public void Load() { if (Scene == null) throw new NotSupportedException(); _targetGameObject = Scene.GameObjects.FirstOrDefault(g => g.Id == TargetObjectId); _sourceGameObject = Scene.GameObjects.FirstOrDefault(g => g.Id == SourceObjectId); if (_targetGameObject != null) _targetGameComponent = _targetGameObject.Components.FirstOrDefault(c => c.Id == TargetComponentId); if (_sourceGameObject != null) { /* object triggers */ if (Type == TriggerType.MouseDown) { _mouseDownHandler = (a, b) => ExecuteTrigger(); _sourceGameObject.OnMouseDown += _mouseDownHandler; } else if (Type == TriggerType.AnimationPlay) { _animationSignalHandler = (a, b) => { if (b.SignalState == iGL.Engine.AnimationComponent.State.Playing) ExecuteTrigger(); }; _sourceGameObject.OnAnimationSignal += _animationSignalHandler; } else if (Type == TriggerType.AnimationStopped) { _animationSignalHandler = (a, b) => { if (b.SignalState == iGL.Engine.AnimationComponent.State.Stopped) ExecuteTrigger(); }; _sourceGameObject.OnAnimationSignal += _animationSignalHandler; } else if (Type == TriggerType.AnimationPaused) { _animationSignalHandler = (a, b) => { if (b.SignalState == iGL.Engine.AnimationComponent.State.Paused) ExecuteTrigger(); }; _sourceGameObject.OnAnimationSignal += _animationSignalHandler; } else if (Type == TriggerType.PlayerCollision) { _collisionEventHandler = (a, b) => { if (b.Object != null && b.Object == this.Scene.PlayerObject) { ExecuteTrigger(); } }; _sourceGameObject.OnObjectCollision += _collisionEventHandler; } } if (Type == TriggerType.SceneLoad) { _sceneLoadEventHandler = (a,b) => ExecuteTrigger(); Scene.OnLoaded += _sceneLoadEventHandler; } }
public FarmPlot(Vector2 plotLocation, bool plotTaken = false, GameComponent componentToPlot = null) { PlotObject = componentToPlot; PlotTaken = plotTaken; PlotLocation = plotLocation; }
public override void Apply(GameComponent Entity, WorldManager World) { Entity.GetRoot().Die(); }
public void AddChildComponent(GameComponent component) { childComponents.Add(component); }
public ItemLayer GetContainLayer(GameComponent item) { foreach (ItemLayer layer in Layers) if (layer.ItemList.Contains(item)) return layer; return null; }
public void AddItem(ItemLayer layer, GameComponent item) { layer.Add(item); }
public void MoveToUpperLayer(GameComponent item) { MoveToUpperLayer(item, GetContainLayer(item).ItemList); }
public virtual void notifyAddComponent(GameComponent component) { }
private void MoveToTop(GameComponent item, GameComponentCollection itemList) { int layer = itemList.IndexOf(item); int MaxLayer = itemList.Count - 1; if (layer > MaxLayer) { Console.WriteLine("错误:指定层级不存在于itemList当中!"); return; } GameComponent srcItem = itemList[layer]; for (int i = layer + 1; i <= itemList.Count - 1; i++) { itemList[i - 1] = itemList[i]; } itemList[MaxLayer] = srcItem; //SetTypeList(itemList); }
public void AddComponent(GameComponent component) { components.Add(component); component.Parent = this; }
public void RemoveChildComponent(GameComponent component) { childComponents.Remove(component); }
public virtual void notifyChildDestroied(GameComponent component) { removeChild(component); }
public override void notifyAddComponent(GameComponent component) { base.notifyAddComponent(component); }
public void AddGameComponent(GameComponent gameComponent) { gameComponents.Add(gameComponent); }
public void StartModify(GameComponent item) { Tweening = true; startTimeMs = GameService.Instance.TotalTimeInMs; }
public static string GetLabel(GameComponent __instance) => __instance.GetType().Name;
public override void notifyComponentChanged(GameComponent component) { base.notifyComponentChanged(component); }
public virtual void notifyComponentChanged(GameComponent component) { }
public virtual void Add(GameComponent item) { ItemList.Add(item); }