Пример #1
0
        public bool Check(long otherEntID, long otherID)
        {
            var ent         = EntityManager.GetEntiy <GameObject>(EntID);
            var hitBox      = ent.GetComponent <RectPosCom>(RectPosAlais);    // Safe
            var otherEnt    = EntityManager.GetEntiy <GameObject>(otherEntID);
            var otherCom    = otherEnt.GetComponent <ICollisionCom>(otherID); // Safe
            var otherHitBox = otherCom.HitBox;                                // Not Safe
            var collied     = hitBox.Rectangle.Intersects(otherHitBox);

            if (collied)             // Note Safe
            {
                foreach (var entry in GameEventComs)
                {
                    if (otherEnt.Tags.Any(i => Regex.IsMatch(entry.Key, i)))
                    {
                        foreach (var id in entry.Value)
                        {
                            if (ent.GetComponent <IGameEventCom>(id) is IColsionGameEventCom)
                            {
                                ent.GetComponent <IColsionGameEventCom>(id).ColliedWithTable[otherCom.EntID] = new ColInfo(otherEntID);
                            }

                            GameEvenetPostMaster.Add(ent.GetIdForAlais(id), otherCom.EntID);
                        }
                    }
                }
            }

            return(collied);
        }
Пример #2
0
        public void Step(double deltaTime)
        {
            var ent = EntityManager.GetEntiy <GameObject>(EntID);

            if (ToResolve.All(i => ent.GetComponent <IResolveBool>(i).Resolve()))
            {
                Events.ForEach(i => GameEvenetPostMaster.Add(ent.GetIdForAlais(i)));
            }
        }
Пример #3
0
        public void Action()
        {
            var ent = EntityManager.GetEntiy <GameObject>(EntID);

            EventAlias.ForEach(i =>
                               GameEvenetPostMaster.Add(EntityManager.GetEntiy <GameObject>(EntID).GetIdForAlais(i))
                               );

            SenceManger.OverlayFileMain(FileName, PassValues);
            _ran = true;
        }
Пример #4
0
        public void Update(double deltaTime)
        {
            var ent      = EntityManager.GetEntiy <GameObject>(EntID);
            var valueCom = ent.GetComponent <IValueCom <T> >(ValueAlias);

            foreach (var entry in Actions[valueCom.Value])
            {
                if (entry.Resolve(KeyboardInputManger))
                {
                    entry.GameEvents.ForEach(i => GameEvenetPostMaster.Add(ent.GetIdForAlais(i)));
                }
            }
        }
Пример #5
0
 public void Step(double deltaTime)
 {
     foreach (var hpTrigger in Evenets)
     {
         if (hpTrigger.Resolve(this))
         {
             foreach (var gameEventID in hpTrigger.GameEvents)
             {
                 GameEvenetPostMaster.Add(EntityManager.GetEntiy <GameObject>(EntID).GetIdForAlais(gameEventID));
             }
         }
     }
 }
Пример #6
0
        public void Update(double deltaTime)
        {
            if (_failedTrys > 10)
            {
                return;
            }

            _lastUpdate += deltaTime;

            var ent    = EntityManager.GetEntiy <GameObject>(EntID);
            var posCom = ent.GetComponent <IPostionComponet>(PostionAlias);
            var curPos = posCom.GetPostion();

            if (_lastUpdate > PathUpdateInterval)
            {
                _path = new Queue <Postion2D>(new AStarSerach().FindPath(Grid, curPos, Target, ObstaclePattern));

                if (!_path.Last().WithinRadius(Target, 3))
                {
                    _failedTrys++;
                }

                _subTarget  = curPos;
                _lastUpdate = 0;
            }

            if (curPos.WithinRadius(_subTarget, 3))
            {
                if (_path.Count > 0)
                {
                    _subTarget = _path.Dequeue();
                }
                else
                {
                    TriggeredAtTarget.ForEach(i => GameEvenetPostMaster.Add(ent.GetIdForAlais(i)));
                }
            }

            var target = _subTarget;

            //System.Diagnostics.Debug.WriteLine("CUR POS {0} TARGET {1}", curPos, target);
            if (!curPos.WithinRadius(target, 3))
            {
                var curInc = Utils.IncrmnetForPoint(curPos, target, deltaTime, Speed);

                curPos += curInc;
                posCom.SetPostion(curPos);
            }
        }
Пример #7
0
        public void Update(double deltaTime)
        {
            var ent        = EntityManager.GetEntiy <GameObject>(EntID);
            var posCom     = ent.GetComponent <IPostionComponet>(RectPosAlais);
            var position   = posCom.GetPostion();
            var oldPostion = new Postion2D(position.X, position.Y);

            var state = Keyboard.GetState();

            float curSpeed = Speed * (float)deltaTime;

            if (state.IsKeyDown(Keys.Right))
            {
                position.X += curSpeed;
            }
            if (state.IsKeyDown(Keys.Left))
            {
                position.X -= curSpeed;
            }
            if (state.IsKeyDown(Keys.Up))
            {
                position.Y -= curSpeed;
            }
            if (state.IsKeyDown(Keys.Down))
            {
                position.Y += curSpeed;
            }

            if (position.X != oldPostion.X || position.Y != oldPostion.Y)
            {
                posCom.SetPostion(position);
            }

            foreach (var entry in Actions)
            {
                if (entry.Resolve(KeyboardInputManger))
                {
                    entry.GameEvents.ForEach(i => GameEvenetPostMaster.Add(ent.GetIdForAlais(i)));
                }
            }
        }
Пример #8
0
        public bool Check(long otherEntID, long otherID)
        {
            var ent         = EntityManager.GetEntiy <GameObject>(EntID);
            var hitBox      = ent.GetComponent <RectPosCom>(RectPosAlais);    // Safe
            var otherEnt    = EntityManager.GetEntiy <GameObject>(otherEntID);
            var otherCom    = otherEnt.GetComponent <ICollisionCom>(otherID); // Safe
            var otherHitBox = otherCom.GetHitBox;                             // Not Safe
            var collied     = hitBox.Rectangle.Intersects(otherHitBox);

            if (collied)             // Note Safe
            {
                foreach (var gameEventAlais in GameEventComs)
                {
                    if (ent.GetComponent <IGameEventCom>(gameEventAlais) is IColsionGameEventCom)
                    {
                        ent.GetComponent <IColsionGameEventCom>(gameEventAlais).ColliedWith = new ColInfo(otherEntID);
                    }

                    GameEvenetPostMaster.Add(ent.GetIdForAlais(gameEventAlais), otherID);
                }
            }

            return(collied);
        }
Пример #9
0
        private void ExcuteEvents()
        {
            var ent = EntityManager.GetEntiy <GameObject>(EntID);

            GameEvents.ForEach(i => GameEvenetPostMaster.Add(ent.GetIdForAlais(i)));
        }