Ejemplo n.º 1
0
        public int TickDeltaTime = 20; //{get;set;}



        public Ship(ShipData shipData)
        {
            p = new ShipData(shipData, this);;
            if (p.Rotation == new MyQuaternion(0f, 0f, 0f, 0f))
            {
                p.Rotation = new MyQuaternion(0f, 0f, 0f, 1f);
            }


            //rotationToTarget = p.SO.rotation;
            moveCommand = MoveType.stop;
            //SendEvent(ShipEvenentsType.move);
            //host = _host;
            //newtargetToMove = null;
            weapons = new SO_weapon[shipData.Weapons.Length];
            for (int i = 0; i < shipData.Weapons.Length; i++)
            {
                weapons[i] = new SO_weapon(shipData.Weapons[i], this);
            }
            equipments = new SO_equipment[shipData.Equipments.Length];
            for (int i = 0; i < shipData.Equipments.Length; i++)
            {
                equipments[i] = new SO_equipment(shipData.Equipments[i], this);
            }
        }
Ejemplo n.º 2
0
        private void AddShip(ShipData ship)
        {
            if (!ships.ContainsKey(ship.Id))
            {
                Ship s = new Ship(ship);
                Console.WriteLine("added {0} id {1} position {2} , rotation {3}", s.p.Type, s.p.Id, s.p.Position, s.p.Rotation);

                ships.TryAdd(s.p.Id, s);
                onTick += s.Tick;
            }
            else
            {
                //TODO Log wrong ship adding
            }
        }
Ejemplo n.º 3
0
        public ShipData(ShipData value, Ship ship) : base(value)
        {
            ShipLink        = ship;
            SpeedMax        = value.SpeedMax;
            RotationSpeed   = value.RotationSpeed;
            AccelerationMax = value.AccelerationMax;
            SpeedNew        = value.SpeedNew;

            Hull_full      = value.Hull_full;
            Armor_full     = value.Armor_full;
            Shield_full    = value.Shield_full;
            Capasitor_full = value.Capasitor_full;

            Hull      = value.Hull;
            Armor     = value.Armor;
            Shield    = value.Shield;
            Capasitor = value.Capasitor;

            Hull_restore      = value.Hull_restore;
            Armor_restore     = value.Armor_restore;
            Shield_restore    = value.Shield_restore;
            Capasitor_restore = value.Capasitor_restore;


            AgrDistance    = value.AgrDistance;
            VisionDistance = value.VisionDistance;

            Destroyed = value.Destroyed;
            Hidden    = value.Hidden;
            Mob       = value.Mob;

            WarpDriveStartTime = value.WarpDriveStartTime;
            WarpSpeed          = value.WarpSpeed;

            Weapons = new SO_weaponData[value.Weapons.Length];
            for (int i = 0; i < value.Weapons.Length; i++)
            {
                Weapons[i] = new SO_weaponData(value.Weapons[i]);
            }

            Equipments = new SO_equipmentData[value.Equipments.Length];
            for (int i = 0; i < value.Equipments.Length; i++)
            {
                Equipments[i] = new SO_equipmentData(value.Equipments[i]);
            }
        }
Ejemplo n.º 4
0
        public List <ShipData> GetAllShips()
        {
            List <ShipData> retListShip = new List <ShipData>();

            string qwery = @"SELECT 
                            server_objects.id,
                            server_objects.type,
                            server_objects.visibleName,
                            server_objects.position_x,
                            server_objects.position_y,
                            server_objects.position_z,
                            server_objects.rotation_x,
                            server_objects.rotation_y,
                            server_objects.rotation_z,
                            server_objects.rotation_w,
                            server_objects.speed,
                            server_objects.prefab_path,
                            SO_shipdata.SO_id,
                            SO_shipdata.max_speed,
                            SO_shipdata.rotation_speed,
                            SO_shipdata.acceleration_max,
                            SO_shipdata.newSpeed,
                            SO_shipdata.hull_full,
                            SO_shipdata.armor_full,
                            SO_shipdata.shield_full,
                            SO_shipdata.capasitor_full,
                            SO_shipdata.hull,
                            SO_shipdata.armor,
                            SO_shipdata.shield,
                            SO_shipdata.capasitor,
                            SO_shipdata.hull_restore,
                            SO_shipdata.armor_restore,
                            SO_shipdata.shield_restore,
                            SO_shipdata.capasitor_restore,
                            SO_shipdata.agr_distance,
                            SO_shipdata.vision_distance,
                            SO_shipdata.destroyed,
                            SO_shipdata.hidden,
                            SO_shipdata.mob,
                            SO_shipdata.warpDriveStartTime,
                            SO_shipdata.warpSpeed
                        FROM SO_shipdata INNER JOIN server_objects
                        ON SO_shipdata.SO_id=server_objects.id";

            GetReader(qwery);
            while (reader.Read())
            {
                ShipData retShipData = new ShipData();
                int      _type       = 0;

                if (!reader.IsDBNull(0))
                {
                    retShipData.Id = reader.GetInt32(0);
                }
                if (!reader.IsDBNull(1))
                {
                    _type = reader.GetInt32(1);
                }
                if (!reader.IsDBNull(2))
                {
                    retShipData.VisibleName = reader.GetString(2);
                }
                if (!reader.IsDBNull(3) && !reader.IsDBNull(4) && !reader.IsDBNull(5))
                {
                    retShipData.Position = new Vector3(reader.GetFloat(3), reader.GetFloat(4), reader.GetFloat(5));
                }
                if (!reader.IsDBNull(6) && !reader.IsDBNull(7) && !reader.IsDBNull(8) && !reader.IsDBNull(9))
                {
                    retShipData.Rotation = new Quaternion(reader.GetFloat(6), reader.GetFloat(7), reader.GetFloat(8), reader.GetFloat(9));
                }
                if (!reader.IsDBNull(10))
                {
                    retShipData.Speed = reader.GetFloat(10);
                }
                if (!reader.IsDBNull(11))
                {
                    retShipData.Prefab = reader.GetString(11);
                }

                //            if (!reader.IsDBNull(12)) { int _id = reader.GetInt32(12); };
                if (!reader.IsDBNull(13))
                {
                    retShipData.SpeedMax = reader.GetFloat(13);
                }
                if (!reader.IsDBNull(14))
                {
                    retShipData.RotationSpeed = reader.GetFloat(14);
                }
                if (!reader.IsDBNull(15))
                {
                    retShipData.AccelerationMax = reader.GetFloat(15);
                }
                if (!reader.IsDBNull(16))
                {
                    retShipData.SpeedNew = reader.GetFloat(16);
                }
                if (!reader.IsDBNull(17))
                {
                    retShipData.Hull_full = reader.GetFloat(17);
                }
                if (!reader.IsDBNull(18))
                {
                    retShipData.Armor_full = reader.GetFloat(18);
                }
                if (!reader.IsDBNull(19))
                {
                    retShipData.Shield_full = reader.GetFloat(19);
                }
                if (!reader.IsDBNull(20))
                {
                    retShipData.Capasitor_full = reader.GetFloat(20);
                }
                if (!reader.IsDBNull(21))
                {
                    retShipData.Hull = reader.GetFloat(21);
                }
                if (!reader.IsDBNull(22))
                {
                    retShipData.Armor = reader.GetFloat(22);
                }
                if (!reader.IsDBNull(23))
                {
                    retShipData.Shield = reader.GetFloat(23);
                }
                if (!reader.IsDBNull(24))
                {
                    retShipData.Capasitor = reader.GetFloat(24);
                }
                if (!reader.IsDBNull(25))
                {
                    retShipData.Hull_restore = reader.GetFloat(25);
                }
                if (!reader.IsDBNull(26))
                {
                    retShipData.Armor_restore = reader.GetFloat(26);
                }
                if (!reader.IsDBNull(27))
                {
                    retShipData.Shield_restore = reader.GetFloat(27);
                }
                if (!reader.IsDBNull(28))
                {
                    retShipData.Capasitor_restore = reader.GetFloat(28);
                }
                if (!reader.IsDBNull(29))
                {
                    retShipData.AgrDistance = reader.GetFloat(29);
                }
                if (!reader.IsDBNull(30))
                {
                    retShipData.VisionDistance = reader.GetFloat(30);
                }
                if (!reader.IsDBNull(31))
                {
                    retShipData.Destroyed = (reader.GetInt32(31) == 1);
                }
                if (!reader.IsDBNull(32))
                {
                    retShipData.Hidden = (reader.GetInt32(32) == 1);
                }
                if (!reader.IsDBNull(33))
                {
                    retShipData.Mob = (reader.GetInt32(33) == 1);
                }
                if (!reader.IsDBNull(34))
                {
                    retShipData.WarpDriveStartTime = reader.GetFloat(34);
                }
                if (!reader.IsDBNull(35))
                {
                    retShipData.WarpSpeed = reader.GetFloat(35);
                }

                switch (_type)
                {
                case 1:
                    retShipData.Type = TypeSO.ship;
                    break;

                case 2:
                    retShipData.Type = TypeSO.station;
                    break;

                case 3:
                    retShipData.Type = TypeSO.asteroid;
                    break;
                }
                retListShip.Add(retShipData);
            }
            for (int i = 0; i < retListShip.Count; i++)
            {
                retListShip[i].Weapons    = GetWeapons(retListShip[i].Id);
                retListShip[i].Equipments = GetEquip(retListShip[i].Id);
            }
            return(retListShip);
        }
Ejemplo n.º 5
0
 private void DeleteShip(ShipData ship)
 {
 }