Exemplo n.º 1
0
        public ShuttleEntity(Guid id, Regulus.CustomType.Rect vision,string target )
            : base(id)
        {
            _Target = target;
            _Vision = vision;

            _Position = new CustomType.Vector2();
            _Position.X = (float)(_Vision.X + _Vision.Width /2);
            _Position.X = (float)(_Vision.Y + _Vision.Height / 2);
        }
Exemplo n.º 2
0
        public PortalEntity(Guid id, Regulus.CustomType.Rect vision,string target_map, CustomType.Vector2 target_position)
            : base(id)
        {
            _TargetPosition = new CustomType.Vector2();
            _TargetPosition.X = target_position.X;
            _TargetPosition.Y = target_position.Y;
            _TargetMap = target_map;
            _Vision = vision;

            _Position = new CustomType.Vector2();
            _Position.X = (float)(_Vision.X + _Vision.Width /2);
            _Position.X = (float)(_Vision.Y + _Vision.Height / 2);
        }
Exemplo n.º 3
0
        public void Update(long time)
        {
            System.DateTime begin      = new DateTime(_BeginTime);
            System.DateTime current    = new DateTime(time);
            var             seconds    = (current - begin).TotalSeconds;
            float           newDistPer = (float)(seconds / _TotalTime);

            if (newDistPer < 1.0)
            {
                var position = new CustomType.Vector2();
                position.X = _Start.X + _Vector.X * newDistPer;
                position.Y = _Start.Y + _Vector.Y * newDistPer;
                _DBActorInfomation.Property.Position = position;
            }
        }
Exemplo n.º 4
0
        public void Move(CustomType.Vector2 end, long time)
        {
            _Start     = Regulus.Utility.ValueHelper.DeepCopy(_DBActorInfomation.Property.Position);
            _End       = end;
            _BeginTime = time;

            float x = System.Math.Abs(_End.X - _Start.X);
            float y = System.Math.Abs(_End.Y - _Start.Y);

            _Distance = Math.Sqrt(x * x + y * y);

            _Vector.X  = x;
            _Vector.Y  = y;
            _TotalTime = _Distance / _DBActorInfomation.Property.Speed;
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            var db3 = new DBEntityInfomation();

            db3.Property.Speed = 1;
            var position = new CustomType.Vector2();

            position.X            = 4530;
            position.Y            = 5430;
            db3.Property.Position = position;


            var db4 = new DBEntityInfomation();

            position.X            = 100;
            position.Y            = 33220;
            db4.Property.Position = position;


            System.TimeSpan    time = new TimeSpan(0, 0, 0);
            PlayerMoverAbility pma  = new PlayerMoverAbility(db3);

            pma.Move(db4.Property.Position, time.Ticks);

            pma.Update(time.Add(new TimeSpan(0, 0, 50)).Ticks);

            pma.Update(time.Add(new TimeSpan(0, 0, 99)).Ticks);



            DBEntityInfomation db1 = new DBEntityInfomation();

            db1.Property.Position = position;
            DBEntityInfomation db2 = new DBEntityInfomation();

            db2.Property.Position = position;
            db2.Look.Name         = "dff";
            var ret = Regulus.Utility.ValueHelper.DeepEqual(db1, db2);

            Regulus.NoSQL.Database db = new Regulus.NoSQL.Database();
            db.Launch("mongodb://127.0.0.1:27017", "Keys");
            db.Shutdown();
        }
Exemplo n.º 6
0
        void _UpdateMover(long time, System.Collections.Generic.IEnumerable<Utility.OBB> obbs)
        {
            if (_MoveSpeed > 0)
            {
                var dt = (float)new System.TimeSpan(time - _CurrentTime).TotalSeconds;
                if (dt > 0)
                {
                    Regulus.CustomType.Vector2 moveVector = new CustomType.Vector2();
                    moveVector.X = _UnitVector.X * dt * _MoveSpeed;
                    moveVector.Y = _UnitVector.Y * dt * _MoveSpeed;

                    _CurrentTime = time;

                    Utility.OBB testobb = new Utility.OBB(_Obb.getX() + moveVector.X, _Obb.getY() + moveVector.Y, _Obb.getWidth(), _Obb.getHeight());
                    testobb.setRotation(_Obb.getRotation());
                    foreach (var obb in obbs)
                    {
                        if (testobb.isCollision(obb) == false)
                        {
                            continue;
                        }

                        Utility.OBB safeobb = new Utility.OBB(_Obb.getX() , _Obb.getY() , _Obb.getWidth(), _Obb.getHeight());
                        safeobb.setRotation(_Obb.getRotation());
                        do
                        {
                            moveVector.X += 0 - _UnitVector.X * dt * _MoveSpeed;
                            moveVector.Y += 0 - _UnitVector.Y * dt * _MoveSpeed;
                            safeobb.setXY(_Obb.getX() + moveVector.X, _Obb.getY() + moveVector.Y );
                        }
                        while (safeobb.isCollision(obb));

                        if (PositionEvent != null)
                            PositionEvent(time, moveVector);

                        _Act(ActionStatue.GangnamStyle, 0, 0);
                        return;
                    }

                    if (PositionEvent != null)
                        PositionEvent(time, moveVector);
                }

            }
            else
            {
                _Update = _Empty;
            }
        }
Exemplo n.º 7
0
 public EntityPropertyInfomation()
 {
     MaxEnergy = 50;
     Energy = 50;
     Skills = new System.Collections.Generic.List<Skill>();
     Position = new CustomType.Vector2();
     Identity = IDENTITY.GUEST;
 }
Exemplo n.º 8
0
 public EntityInfomation()
 {
     Position = new CustomType.Vector2();
 }
Exemplo n.º 9
0
 public PortalEntity()
 {
     Vision = new CustomType.Rect();
     TargetPosition = new CustomType.Vector2();
 }
Exemplo n.º 10
0
 public EntityPropertyInfomation()
 {
     Position = new CustomType.Vector2();
     Map = "";
 }
Exemplo n.º 11
0
 public EntityInfomation()
 {
     Position = new CustomType.Vector2();
 }
Exemplo n.º 12
0
        private void _Act(Serializable.ActionCommand action_command)
        {
            // 角色面對世界的方向
            var moveDirection = 0.0f;
            if (action_command.Absolutely == false)
                moveDirection = (action_command.Direction + _Direction) % 360;
            else
                moveDirection = action_command.Direction % 360;

            if (action_command.Turn)
            {
                _Direction = moveDirection;
            }

            _CurrentAction = action_command.Command;
            _MoveSpeed = action_command.Speed;

            // 移動向量
            var t = (float)((moveDirection - 180) * Math.PI / 180);
            var unitVector = new CustomType.Vector2() { X = -(float)Math.Sin(t), Y = -(float)Math.Cos(t) };

            _UnitVector = unitVector;
            _Update = _First;

            if (_PrevTime < action_command.Time)
                _PrevTime = action_command.Time;
        }
Exemplo n.º 13
0
        void _UpdateMover(long time, System.Collections.Generic.IEnumerable<CustomType.Polygon> polygons)
        {
            if (_MoveSpeed > 0)
            {
                var dt = (float)new System.TimeSpan(time - _PrevTime).TotalSeconds;
                if (dt > 0)
                {
                    Regulus.CustomType.Vector2 moveVector = new CustomType.Vector2();
                    moveVector.X = _UnitVector.X * dt * _MoveSpeed;
                    moveVector.Y = _UnitVector.Y * dt * _MoveSpeed;

                    _PrevTime = time;

                    var result = _Collision(polygons, moveVector);

                    if (PositionEvent != null && result.Intersect )
                        PositionEvent(time, moveVector + result.MinimumTranslationVector2);
                    else if (PositionEvent != null && result.WillIntersect )
                    {
                        //PositionEvent(time, moveVector + result.MinimumTranslationVector2);
                    }
                    else if (PositionEvent != null)
                        PositionEvent(time, moveVector);

                    if (result.Intersect || result.WillIntersect)
                    {

                        Serializable.ActionCommand actionCommand = new Serializable.ActionCommand()
                        {
                            Absolutely = false,
                            Command = ActionStatue.Idle_1,
                            Direction = 0,
                            Speed = 0,
                            Time = time,
                            Turn = true
                        };
                        _Act(actionCommand);
                    }

                }

            }
            else
            {
                _Update = _Empty;
            }
        }