コード例 #1
0
        private void DecompressIntoShip(JArray data, ShipData ship)
        {
            var movingFlags = new MovingFlags()
            {
                RotatingLeft  = ExtractValue <bool>(data, _shipContract.RotatingLeft),
                RotatingRight = ExtractValue <bool>(data, _shipContract.RotatingRight),
                Forward       = ExtractValue <bool>(data, _shipContract.Forward),
                Backward      = ExtractValue <bool>(data, _shipContract.Backward),
            };
            var name        = ExtractValue <string>(data, _shipContract.Name);
            var maxLife     = ExtractValue <double>(data, _shipContract.MaxLife);
            var level       = ExtractValue <int>(data, _shipContract.Level);
            var boosting    = ExtractValue <bool>(data, _shipContract.Boost);
            var abilityData = new AbilityData()
            {
                Boosting = boosting
            };

            DecompressIntoCollidable(data, ship);
            ship.Movement.Position = ship.Movement.Position + _initializationData.Configuration.ShipConfiguration.WIDTH * .5;
            ship.Movement.Moving   = movingFlags;
            ship.Name      = name;
            ship.MaxLife   = maxLife;
            ship.Level     = level;
            ship.Abilities = abilityData;
            ship.Width     = _initializationData.Configuration.ShipConfiguration.WIDTH;
            ship.Height    = _initializationData.Configuration.ShipConfiguration.HEIGHT;
        }
コード例 #2
0
ファイル: BaseObject.cs プロジェクト: rkhapov/simple3d
        public void MoveOnDirection(Scene scene, float elapsedTime, MovingFlags flags = MovingFlags.Standard)
        {
            var map         = scene.Map;
            var dx          = MathF.Cos(DirectionAngle) * MoveSpeed * elapsedTime;
            var dy          = MathF.Sin(DirectionAngle) * MoveSpeed * elapsedTime;
            var newPosition = Position + new Vector2(dx, 0);

            if (CanMove(scene, newPosition, map, flags.HasFlag(MovingFlags.IgnoreObjects)))
            {
                Position = newPosition;
            }

            newPosition = Position + new Vector2(0, dy);

            if (CanMove(scene, newPosition, map, flags.HasFlag(MovingFlags.IgnoreObjects)))
            {
                Position = newPosition;
            }
        }