コード例 #1
0
ファイル: Game.cs プロジェクト: ndech/PlaneSimulator
 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
ファイル: Health.cs プロジェクト: scorvi/dwarfcorp
        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
ファイル: DestroyCommand.cs プロジェクト: hhy5277/dwarfcorp
 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);
        }
コード例 #9
0
 public override void Execute(GameComponent go)
 {
     go.Dig();
     base.Execute(go);
 }
コード例 #10
0
ファイル: ChatCommand.cs プロジェクト: sodomon2/dwarfcorp
 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
ファイル: ChopCommand.cs プロジェクト: sodomon2/dwarfcorp
 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);
        }
コード例 #22
0
 public void AddComponent(GameComponent component)
 {
     this._components.Add(component);
 }
コード例 #23
0
ファイル: GameComponent.cs プロジェクト: Hengle/GameEditor
 public virtual void notifyChildDetached(GameComponent component)
 {
     removeChild(component);
 }                                                                                                   // 通知该组件有子组件断开了联系
コード例 #24
0
ファイル: ChatCommand.cs プロジェクト: hhy5277/dwarfcorp
        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
ファイル: Game.cs プロジェクト: ajmd17/apexengine-sharp
 public void RemoveComponent(GameComponent cmp)
 {
     components.Remove(cmp);
     rootNode.RemoveChild(cmp.rootNode);
 }
コード例 #30
0
 public void RemoveFromInventory(GameComponent item)
 {
     inventory.Remove(item);
 }
コード例 #31
0
ファイル: Trigger.cs プロジェクト: BaldMan82/iGL
        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
ファイル: DestroyCommand.cs プロジェクト: hhy5277/dwarfcorp
 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
ファイル: GameObject.cs プロジェクト: aerosolswe/WaterWorld
 public void AddComponent(GameComponent component)
 {
     components.Add(component);
     component.Parent = this;
 }
コード例 #41
0
 public void RemoveChildComponent(GameComponent component)
 {
     childComponents.Remove(component);
 }
コード例 #42
0
ファイル: GameComponent.cs プロジェクト: Hengle/GameEditor
 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
ファイル: Character.cs プロジェクト: isoundy000/Mahjong-3
 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);
 }