Esempio n. 1
0
        public TriangleEntity(Guid id,CustomType.Polygon polygon)
            : base(id)
        {
            _Polygon = polygon;

            var points = new Queue<CustomType.Vector2>(_Polygon.Points);
            var firstPoint = points.Dequeue();
            float top = firstPoint.Y;
            float down = firstPoint.Y ;
            float left = firstPoint.X;
            float right = firstPoint.X;
            while (points.Count > 0)
            {
                var point = points.Dequeue();
                if (point.X > right)
                {
                    right = point.X;
                }
                if (point.X < left)
                {
                    left = point.X;
                }
                if (point.Y < top)
                {
                    top = point.Y;
                }
                if (point.Y > down)
                {
                    down = point.Y;
                }

            }
            _QuadTreeObjectAbility = new PhysicalAbility(new Regulus.CustomType.Rect(left , top , right - left , down - top ) , this);
            _Polygon.BuildEdges();
        }
Esempio n. 2
0
        protected override void _SetAbility(Entity.AbilitySet abilitys)
        {
            _MoverAbility = new ActorMoverAbility(_Property.Direction, _Property.Position.X, _Property.Position.Y);
            _MoverAbility.ActionEvent += _OnAction;
            _MoverAbility.PositionEvent += _OnPosition;

            abilitys.AttechAbility<IMoverAbility>(_MoverAbility);

            _QuadTreeObjectAbility = new PhysicalAbility(new Regulus.Types.Rect(_Property.Position.X - _BodyWidth / 2, _Property.Position.Y - _BodyHeight / 2, _BodyWidth, _BodyHeight), this);
            abilitys.AttechAbility<PhysicalAbility>(_QuadTreeObjectAbility);
        }
Esempio n. 3
0
        public StaticEntity(Regulus.Utility.OBB obb, Guid id)
            : base(id)
        {
            _Obb = obb;

            var a = (float)((_Obb.getRotation() - 180) * Math.PI / 180);
            var s = (float)Math.Sin(a);
            var c = (float)Math.Cos(a);

            s = s < 0 ? -s : s;
            c = c < 0 ? -c : c;

            var w = _Obb.getHeight() * s + _Obb.getWidth() * c;
            var h = _Obb.getHeight() * c + _Obb.getWidth() * s;
            var x = _Obb.getX() - w / 2;
            var y = _Obb.getY() - h / 2;

            _QuadTreeObjectAbility = new PhysicalAbility(new Regulus.Types.Rect(x,y,w,h) , this);
        }
Esempio n. 4
0
 private void _UpdateMovers(IMoverAbility moverAbility, IObserveAbility observeAbility, PhysicalAbility physical)
 {
     var w = physical.Bounds.Width;
     var h = physical.Bounds.Height;
     var x = observeAbility.Position.X - w / 2;
     var y = observeAbility.Position.Y - h / 2;
     var brounds = new Regulus.CustomType.Rect(x, y, w, h);
     var inbrounds = _ObseverdInfomations.Query(brounds);
     var obbs = from qtoa in inbrounds let ma = qtoa.Move where ma != null && moverAbility != ma select ma.Polygon;
     moverAbility.Update(_Time.Ticks, obbs);
 }
Esempio n. 5
0
        /// <summary>
        /// 設定功能
        /// </summary>
        /// <param name="abilitys">現有功能Dict</param>
        protected override void _SetAbility(Entity.AbilitySet abilitys)
        {
            _MoverAbility = new ActorMoverAbility2(_Property.Direction, _Property.Position.X, _Property.Position.Y);
            _MoverAbility.ActionEvent += _OnAction;
            _MoverAbility.PositionEvent += _OnPosition;

            abilitys.AttechAbility<IMoverAbility>(_MoverAbility);

            _QuadTreeObjectAbility = new PhysicalAbility(new Regulus.CustomType.Rect(_Property.Position.X - _BodyWidth / 2, _Property.Position.Y - _BodyHeight / 2, _BodyWidth, _BodyHeight), this);
            abilitys.AttechAbility<PhysicalAbility>(_QuadTreeObjectAbility);
            abilitys.AttechAbility<IBehaviorAbility>(_Behavior);
            abilitys.AttechAbility<IBehaviorCommandAbility>(_Behavior);

            abilitys.AttechAbility<IActorPropertyAbility>(_PropertyAbility);
            abilitys.AttechAbility<IActorUpdateAbility>(_PropertyAbility);
            abilitys.AttechAbility<ISkillCaptureAbility>(_PropertyAbility);
        }