コード例 #1
0
        // public IEnumerable<short> GetTilesFor(PhysicsComponent body)
        public IEnumerable <(int, int)> GetTilesFor(PhysicsComponent body)
        {
            var rect = body.GetRectangle();

            int left_index = rect.Left / TileSize - 1;
            int width      = rect.Width / TileSize + 2;
            int top_index  = rect.Top / TileSize - 1;
            int height     = rect.Height / TileSize + 2;

            for (int i = left_index; i <= left_index + width; i++)
            {
                for (int j = top_index; j <= top_index + height; j++)
                {
                    if (i >= 0 && j >= 0 && i < Grid.GetLength(0) && j < Grid.GetLength(1) && Grid[i, j] != 0)
                    {
                        // yield return (i, j)Grid[i, j];
                        yield return(i, j);
                    }
                }
            }
        }
コード例 #2
0
        public override bool ProcessCollision(Direction direction, PhysicsComponent obj)
        {
            if (done)
            {
                return(false);
            }
            base.ProcessCollision(direction, obj);

            if (direction != Omniplatformer.Direction.None && obj.GameObject != GameObject.Source && (obj.Solid || obj.Hittable) && obj.GameObject.Team != GameObject.Team)
            {
                var hittable = GetComponent <HitComponent>();
                hittable?.Hit(obj.GameObject);
                // TODO: might have to extract this
                // GameObject.onDestroy();
                CurrentMovement = Vector2.Zero;
                GameObject.onDestroy();
                done = true;
                return(true);
                // Hit(obj);
            }
            return(false);
        }
コード例 #3
0
        public override bool ProcessCollision(Direction direction, PhysicsComponent obj)
        {
            // TODO: make the component acquisition less costly
            var pos = GetComponent <PositionComponent>();

            if (obj.Solid)
            {
                if (direction == Direction.Down)
                {
                    IsOnGround = true;
                }
                else if (direction == Direction.Up)
                {
                    IsNextToCeiling = true;
                }
                else if (direction == Direction.Left)
                {
                    IsNextToLeftWall = true;
                }
                else if (direction == Direction.Right)
                {
                    IsNextToRightWall = true;
                }
            }
            else if (obj.Climbable)
            {
                IsNextToRope = true;
            }

            // TODO: refactor this
            if (obj.Hittable)
            {
                var hittable = GetComponent <HitComponent>();
                hittable?.Hit(obj.GameObject);
            }

            base.ProcessCollision(direction, obj);
            return(false);
        }
コード例 #4
0
 public void ProcessCollision(PhysicsComponent physicable)
 {
 }