示例#1
0
        void GiveVehicle(vehicle_DBID num, PlayerInfos playerInfo)
        {
            {
                if (playerInfo.isDefined && playerInfo.connected)
                {
                    Vector3 vector3 = new Vector3(0f, 10f, 0f);
                    if (!playerInfo.connected)
                    {
                        vector3 = new Vector3(playerInfo.DB_pos.x, playerInfo.DB_pos.y + 10f, playerInfo.DB_pos.z);
                    }
                    else
                    {
                        float   transfo  = playerInfo.Transfo.position.x;
                        Vector3 transfo1 = playerInfo.Transfo.position;
                        Vector3 vector31 = playerInfo.Transfo.position;
                        vector3 = new Vector3(transfo, transfo1.y + 10f, vector31.z);
                    }
                    VEHICLE_BLUEPRINT item = Vehicles[num];

                    Transform transforms = uLink.Network.Instantiate <Transform>(item.Vehicle_prefab, vector3, Quaternion.identity, 0, new object[0]);
                    Vehicle   component  = transforms.GetComponent <Vehicle>();
                    if (component == null)
                    {
                        SHIP sHIP = transforms.GetComponent <SHIP>();
                        if (sHIP != null)
                        {
                            string str = DateTime.Now.ToString("yyyyMMddHHmmssf", CultureInfo.InvariantCulture);
                            sHIP.GetSet_DataBase_ID = str;
                            string empty = string.Empty;
                            if (sHIP.Linked_Turrets != null && (int)sHIP.Linked_Turrets.Length > 0)
                            {
                                for (int i = 0; i < (int)sHIP.Linked_Turrets.Length; i++)
                                {
                                    string str1 = string.Concat(str, i.ToString());
                                    nc.Add_Turret_To_DB(str1, sHIP.Linked_Turrets[i]);
                                    empty = (i != 0 ? string.Concat(empty, "_", str1) : str1);
                                }
                            }
                            sHIP.FinalizeProduction();
                            nc.Add_Vehicle_to_DB(str, sHIP.DBID, vector3, Quaternion.identity, sHIP.FUEL, sHIP.HEALTH, empty);
                            sHIP.Start_DB_Record();
                        }
                    }
                    else
                    {
                        string str2 = DateTime.Now.ToString("yyyyMMddHHmmssf", CultureInfo.InvariantCulture);
                        component.GetSet_DataBase_ID = str2;
                        string empty1 = string.Empty;
                        if (component.Linked_Turrets != null && (int)component.Linked_Turrets.Length > 0)
                        {
                            for (int j = 0; j < (int)component.Linked_Turrets.Length; j++)
                            {
                                string str3 = string.Concat(str2, j.ToString(CultureInfo.InvariantCulture));
                                nc.Add_Turret_To_DB(str3, component.Linked_Turrets[j]);
                                empty1 = (j != 0 ? string.Concat(empty1, "_", str3) : str3);
                            }
                        }
                        nc.Add_Vehicle_to_DB(str2, component.DBID, vector3, Quaternion.identity, component.FUEL, component.HEALTH, empty1);
                        component.Start_DB_Record();
                    }
                }
            }
        }