Пример #1
0
 public void Register(GameComponent item)
 {
     _newRegisteredElement = true;
     _gameComponents.Add(item);
     if (item is RenderableGameComponent)
         _renderer.Register(item as RenderableGameComponent);
 }
Пример #2
0
 public void AddToInventory(GameComponent item)
 {
     if (!Full)
     {
       inventory.Add(item);
     }
 }
Пример #3
0
        public Health(ComponentManager manager, string name, GameComponent parent, float maxHealth, float minHealth, float currentHp)
            : base(name, parent)
        {
            InitializeResistance();
            MaxHealth = maxHealth;
            MinHealth = minHealth;

            Hp = currentHp;
        }
Пример #4
0
 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);
 }
Пример #5
0
    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;
    }
Пример #6
0
        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的引用!");
        }
Пример #7
0
 public override bool CanBeAppliedTo(GameComponent Entity, WorldManager World)
 {
     return((World.UserInterface.Tools["DeconstructObjects"] as DeconstructObjectTool).CanDestroy(Entity));
 }
Пример #8
0
        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);
 }
Пример #10
0
 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));
     }
Пример #11
0
        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);
        }
Пример #12
0
 public virtual void Remove(GameComponent item)
 {
     ItemList.Remove(item);
 }
Пример #13
0
 public override bool CanBeAppliedTo(GameComponent Entity, WorldManager World)
 {
     return(Entity.Tags.Contains("Vegetation"));
 }
Пример #14
0
 public static ScreenComponent ToScreenComponent(this GameComponent component, IScreen screen, DisplayLayer index)
 {
     return(new GameComponentWrapper(component, screen, index));
 }
Пример #15
0
 public static ScreenComponent ToScreenComponent(this GameComponent component, IScreen screen)
 {
     return(component.ToScreenComponent(screen, DisplayLayer.None));
 }
Пример #16
0
 public GameComponentWrapper(GameComponent component, IScreen screen, DisplayLayer index)
     : base(screen, index)
 {
     Wrapped = component;
 }
Пример #17
0
 void FadableButton_MouseEnter(GameComponent sender, MouseEvent mouseEvent)
 {
     mouseOn = true;
 }
Пример #18
0
 void FadableButton_MouseLeave(GameComponent sender, MouseEvent mouseEvent)
 {
     mouseOn = false;
 }
Пример #19
0
 public void MoveToBottom(GameComponent item)
 {
     MoveToBottom(item, GetContainLayer(item).ItemList);
 }
Пример #20
0
        private void OpenBattleJustHero(String scene, int upgradeLevel)
        {
            string civilianUpgradeLevelTag = Campaign.Current.Models.LocationModel.GetCivilianUpgradeLevelTag(upgradeLevel);

            GameComponent.OpenBattleJustHero(scene, civilianUpgradeLevelTag);
        }
Пример #21
0
        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);
 }
Пример #23
0
 public virtual void notifyChildDetached(GameComponent component)
 {
     removeChild(component);
 }                                                                                                   // 通知该组件有子组件断开了联系
Пример #24
0
        public override void Apply(GameComponent Entity, WorldManager World)
        {
            var creature = Entity.GetComponent <CreatureAI>();

            creature.Chat();
        }
Пример #25
0
 public virtual void Delete(GameComponent item)
 {
     deleteItems.Add(item);
 }
Пример #26
0
 public GroupTestSystem(GameEntity testEntity, GameComponent testComponent)
 {
     _testEntity    = testEntity;
     _testComponent = testComponent;
 }
Пример #27
0
 public virtual void notifyComponentDestroied(GameComponent component)
 {
     removeComponentFromList(component);
 }
Пример #28
0
        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();
                }
            }
        }
Пример #29
0
 public void RemoveComponent(GameComponent cmp)
 {
     components.Remove(cmp);
     rootNode.RemoveChild(cmp.rootNode);
 }
Пример #30
0
 public void RemoveFromInventory(GameComponent item)
 {
     inventory.Remove(item);
 }
Пример #31
0
        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;
            }
        }
Пример #32
0
 public FarmPlot(Vector2 plotLocation, bool plotTaken = false, GameComponent componentToPlot = null)
 {
     PlotObject   = componentToPlot;
     PlotTaken    = plotTaken;
     PlotLocation = plotLocation;
 }
Пример #33
0
 public override void Apply(GameComponent Entity, WorldManager World)
 {
     Entity.GetRoot().Die();
 }
Пример #34
0
 public void AddChildComponent(GameComponent component)
 {
     childComponents.Add(component);
 }
Пример #35
0
 public ItemLayer GetContainLayer(GameComponent item)
 {
     foreach (ItemLayer layer in Layers)
         if (layer.ItemList.Contains(item))
             return layer;
     return null;
 }
Пример #36
0
 public void AddItem(ItemLayer layer, GameComponent item)
 {
     layer.Add(item);
 }
Пример #37
0
 public void MoveToUpperLayer(GameComponent item)
 {
     MoveToUpperLayer(item, GetContainLayer(item).ItemList);
 }
Пример #38
0
 public virtual void notifyAddComponent(GameComponent component)
 {
 }
Пример #39
0
        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);
        }
Пример #40
0
 public void AddComponent(GameComponent component)
 {
     components.Add(component);
     component.Parent = this;
 }
Пример #41
0
 public void RemoveChildComponent(GameComponent component)
 {
     childComponents.Remove(component);
 }
Пример #42
0
 public virtual void notifyChildDestroied(GameComponent component)
 {
     removeChild(component);
 }
Пример #43
0
 public override void notifyAddComponent(GameComponent component)
 {
     base.notifyAddComponent(component);
 }
Пример #44
0
 public void AddGameComponent(GameComponent gameComponent)
 {
     gameComponents.Add(gameComponent);
 }
Пример #45
0
 public void StartModify(GameComponent item)
 {
     Tweening = true;
     startTimeMs = GameService.Instance.TotalTimeInMs;
 }
Пример #46
0
 public static string GetLabel(GameComponent __instance) => __instance.GetType().Name;
Пример #47
0
 public override void notifyComponentChanged(GameComponent component)
 {
     base.notifyComponentChanged(component);
 }
Пример #48
0
 public virtual void notifyComponentChanged(GameComponent component)
 {
 }
Пример #49
0
 public void RemoveFromInventory(GameComponent item)
 {
     inventory.Remove(item);
 }
Пример #50
0
 public virtual void Add(GameComponent item)
 {
     ItemList.Add(item);
 }