Ejemplo n.º 1
0
        public void Initialise(Vdf vdf)
        {
            if (Initialised)
            {
                return;
            }

            _vdf          = vdf;
            _cacheManager = CacheManager.Instance;

            // Initialise with common sprites using more convenient names.
            _sprites = new Dictionary <string, I76Sprite>
            {
                // Numbers
                { "1", GetSprite("znbe.map", "top", 0, 1, false) },
                { "2", GetSprite("znbe.map", "top", 0, 2, false) },
                { "3", GetSprite("znbe.map", "top", 0, 3, false) },
                { "4", GetSprite("znbe.map", "top", 0, 4, false) },
                { "5", GetSprite("znbe.map", "top", 0, 5, false) },
                { "6", GetSprite("znbe.map", "top", 0, 6, false) },
                { "7", GetSprite("znbe.map", "top", 0, 7, false) },
                { "8", GetSprite("znbe.map", "top", 0, 8, false) },
                { "9", GetSprite("znbe.map", "top", 0, 9, false) },
                { "0", GetSprite("znbe.map", "top", 0, 0, false) }
            };

            Initialised = true;
        }
Ejemplo n.º 2
0
        private void AccountsManager_Load(object sender, EventArgs e)
        {
            Vdf v = new Vdf(mainForm.SteamPath + "\\config\\loginusers.vdf");
            Dictionary <string, SteamUserInfo> data = v.get();
            int index = 0;

            foreach (SteamUserInfo user in data.Values)
            {
                listBox_account.Items.Insert(index, user.user);
                listBox_steamname.Items.Insert(index, user.name);
                index++;
            }
        }
Ejemplo n.º 3
0
        private void ConfigManager_Load(object sender, EventArgs e)
        {
            Vdf v = new Vdf(mainForm.SteamPath + "\\config\\loginusers.vdf");
            Dictionary <string, SteamUserInfo> data = v.get();
            int index = 0;

            foreach (SteamUserInfo user in data.Values)
            {
                string str = user.user + " > " + user.name;
                cache_data.Add(index, user.id64);
                comboBox_dst.Items.Insert(index, str);
                comboBox_src.Items.Insert(index, str);
                index++;
            }
        }
Ejemplo n.º 4
0
        public void Configure(Vdf vdf, Vcf vcf)
        {
            Vdf = vdf;
            Vcf = vcf;

            _vehicleHealthGroups = Vdf.PartsThirdPerson.Count;

            int systemCount = (int)SystemType.TotalSystems;

            _vehicleHitPoints      = new int[systemCount];
            _vehicleStartHitPoints = new int[systemCount];

            _vehicleStartHitPoints[(int)SystemType.Vehicle]    = VehicleStartHealth;
            _vehicleStartHitPoints[(int)SystemType.Suspension] = CoreStartHealth;
            _vehicleStartHitPoints[(int)SystemType.Brakes]     = CoreStartHealth;
            _vehicleStartHitPoints[(int)SystemType.Engine]     = CoreStartHealth;

            _vehicleStartHitPoints[(int)SystemType.FrontArmor] = (int)vcf.ArmorFront;
            _vehicleStartHitPoints[(int)SystemType.RightArmor] = (int)vcf.ArmorRight;
            _vehicleStartHitPoints[(int)SystemType.BackArmor]  = (int)vcf.ArmorRear;
            _vehicleStartHitPoints[(int)SystemType.LeftArmor]  = (int)vcf.ArmorLeft;

            _vehicleStartHitPoints[(int)SystemType.FrontChassis] = (int)vcf.ChassisFront;
            _vehicleStartHitPoints[(int)SystemType.RightChassis] = (int)vcf.ChassisRight;
            _vehicleStartHitPoints[(int)SystemType.BackChassis]  = (int)vcf.ChassisRear;
            _vehicleStartHitPoints[(int)SystemType.LeftChassis]  = (int)vcf.ChassisLeft;

            _vehicleStartHitPoints[(int)SystemType.TireFL] = TireStartHealth;
            _vehicleStartHitPoints[(int)SystemType.TireFR] = TireStartHealth;
            _vehicleStartHitPoints[(int)SystemType.TireBL] = TireStartHealth;
            _vehicleStartHitPoints[(int)SystemType.TireBR] = TireStartHealth;

            for (int i = 0; i < systemCount; ++i)
            {
                _vehicleHitPoints[i] = _vehicleStartHitPoints[i];
            }
        }
Ejemplo n.º 5
0
        private RaySusp[] CreateWheelPair(Dictionary <string, GameObject> partDict, string placement, int wheelIndex, GameObject car, Vdf vdf, Vtf vtf, Wdf wheelDef)
        {
            string  wheel1Name = placement + "Right";
            RaySusp wheel      = Object.Instantiate(placement == "Front" ? _steerWheelPrefab : _driveWheelPrefab, car.transform);

            wheel.gameObject.name = wheel1Name;
            wheel.WheelRadius     = wheelDef.Radius; // This is not correct - find out where the radius is really stored
            wheel.SpringLength    = wheelDef.Radius;

            ImportCarParts(partDict, wheel.transform.Find("Mesh").gameObject, vtf, wheelDef.Parts, _noColliderPrefab, false);
            wheel.transform.localPosition = vdf.WheelLoc[wheelIndex].Position;

            RaySusp wheel2 = Object.Instantiate(wheel, car.transform);

            wheel2.name = placement + "Left";
            wheel2.transform.localPosition           = vdf.WheelLoc[wheelIndex + 1].Position;
            wheel2.transform.Find("Mesh").localScale = new Vector3(-1, 1, 1);

            return(new[] { wheel, wheel2 });
        }
Ejemplo n.º 6
0
        public GameObject ImportVcf(string filename, bool importFirstPerson, out Vdf vdf)
        {
            Vcf vcf = VcfParser.ParseVcf(filename);

            vdf = VdfParser.ParseVdf(vcf.VdfFilename);
            Vtf vtf = VtfParser.ParseVtf(vcf.VtfFilename);

            Car carObject = Object.Instantiate(_carPrefab);

            carObject.Configure(vdf, vcf);
            carObject.gameObject.name = vdf.Name + " (" + vcf.VariantName + ")";

            foreach (VLoc vLoc in vdf.VLocs)
            {
                GameObject vlocGo = new GameObject("VLOC");
                vlocGo.transform.parent        = carObject.transform;
                vlocGo.transform.localRotation = Quaternion.LookRotation(vLoc.Forward, vLoc.Up);
                vlocGo.transform.localPosition = vLoc.Position;
            }

            GameObject chassis = new GameObject("Chassis");

            chassis.transform.parent = carObject.transform;

            GameObject thirdPerson = new GameObject("ThirdPerson");

            thirdPerson.transform.parent = chassis.transform;

            Transform[] weaponMountTransforms = new Transform[vdf.HLocs.Count];
            for (int i = 0; i < vdf.HLocs.Count; ++i)
            {
                HLoc      hloc       = vdf.HLocs[i];
                Transform mountPoint = new GameObject(hloc.Label).transform;
                mountPoint.parent        = thirdPerson.transform;
                mountPoint.localRotation = Quaternion.LookRotation(hloc.Forward, hloc.Up);
                mountPoint.localPosition = hloc.Position;
                weaponMountTransforms[i] = mountPoint;
            }

            Dictionary <string, GameObject> partDict = new Dictionary <string, GameObject>();

            for (int i = 0; i < vdf.PartsThirdPerson.Count; ++i)
            {
                GameObject healthObject = new GameObject("Health " + i);
                healthObject.transform.SetParent(thirdPerson.transform);
                ImportCarParts(partDict, healthObject, vtf, vdf.PartsThirdPerson[i], _noColliderPrefab, false, false, i);
                if (i != 0)
                {
                    healthObject.SetActive(false);
                }
            }

            MeshFilter[] meshFilters = thirdPerson.GetComponentsInChildren <MeshFilter>();
            Bounds       bounds      = new Bounds();

            bounds.SetMinMax(Vector3.one * float.MaxValue, Vector3.one * float.MinValue);
            foreach (MeshFilter meshFilter in meshFilters)
            {
                Vector3 min = Vector3.Min(bounds.min, meshFilter.transform.position + meshFilter.sharedMesh.bounds.min) - thirdPerson.transform.position;
                Vector3 max = Vector3.Max(bounds.max, meshFilter.transform.position + meshFilter.sharedMesh.bounds.max) - thirdPerson.transform.position;
                bounds.SetMinMax(min, max);
            }

            GameObject chassisCollider = new GameObject("ChassisColliders");

            chassisCollider.transform.parent = carObject.transform;
            ImportCarParts(partDict, chassisCollider, vtf, vdf.PartsThirdPerson[0], _carBodyPrefab, true);

            for (int i = 0; i < vcf.Weapons.Count; ++i)
            {
                VcfWeapon weapon     = vcf.Weapons[i];
                int       mountPoint = weapon.MountPoint;
                HLoc      hloc       = vdf.HLocs[mountPoint];
                weapon.RearFacing = hloc.FacingDirection == 2;

                SdfPart[] partsArray;
                switch (hloc.MeshType)
                {
                case HardpointMeshType.Top:
                    partsArray = weapon.Gdf.TopParts;
                    break;

                case HardpointMeshType.Side:
                    partsArray = weapon.Gdf.SideParts;
                    break;

                case HardpointMeshType.Inside:
                    partsArray = weapon.Gdf.InsideParts;
                    break;

                case HardpointMeshType.Turret:
                    partsArray = weapon.Gdf.TurretParts;
                    break;

                default:
                    partsArray = null;
                    break;
                }

                if (partsArray != null)
                {
                    Transform weaponTransform = new GameObject(weapon.Gdf.Name).transform;
                    weaponTransform.SetParent(weaponMountTransforms[i]);
                    weaponTransform.localPosition = Vector3.zero;
                    weaponTransform.localRotation = Quaternion.identity;
                    ImportCarParts(partDict, weaponTransform.gameObject, vtf, partsArray, _noColliderPrefab, false);
                    weapon.Transform = weaponTransform;

                    // Disable depth test for 'inside' weapons, otherwise they are obscured.
                    if (hloc.MeshType == HardpointMeshType.Inside)
                    {
                        MeshRenderer weaponRenderer = weaponTransform.GetComponentInChildren <MeshRenderer>();
                        if (weaponRenderer != null)
                        {
                            weaponRenderer.sharedMaterial.shader = Shader.Find("Custom/CutOutWithoutZ");
                        }
                    }
                }
                else
                {
                    weapon.Transform = chassis.transform;
                }
            }

            // Note: The following is probably how I76 does collision detection. Two large boxes that encapsulate the entire vehicle.
            // Right now this won't work with Open76's raycast suspension, so I'm leaving this off for now. Investigate in the future.
            //var innerBox = chassisCollider.AddComponent<BoxCollider>();
            //innerBox.center = vdf.BoundsInner.center;
            //innerBox.size = vdf.BoundsInner.size;

            //var outerBox = chassisCollider.AddComponent<BoxCollider>();
            //outerBox.center = vdf.BoundsOuter.center;
            //outerBox.size = vdf.BoundsOuter.size;

            RaySusp[] frontWheels = null;
            if (vcf.FrontWheelDef != null)
            {
                frontWheels = CreateWheelPair(partDict, "Front", 0, carObject.gameObject, vdf, vtf, vcf.FrontWheelDef);
                carObject.Movement.FrontWheels = frontWheels;
            }
            if (vcf.MidWheelDef != null)
            {
                CreateWheelPair(partDict, "Mid", 2, carObject.gameObject, vdf, vtf, vcf.MidWheelDef);
            }

            RaySusp[] rearWheels = null;
            if (vcf.BackWheelDef != null)
            {
                rearWheels = CreateWheelPair(partDict, "Back", 4, carObject.gameObject, vdf, vtf, vcf.BackWheelDef);
                carObject.Movement.RearWheels = rearWheels;
            }

            if (importFirstPerson)
            {
                GameObject firstPerson = new GameObject("FirstPerson");
                firstPerson.transform.parent = chassis.transform;
                ImportCarParts(partDict, firstPerson, vtf, vdf.PartsFirstPerson, _noColliderPrefab, false, true, 0, LayerMask.NameToLayer("FirstPerson"));

                carObject.InitPanels();
                firstPerson.SetActive(false);
            }

            carObject.Movement.Initialise(chassis.transform, frontWheels, rearWheels);

            return(carObject.gameObject);
        }
Ejemplo n.º 7
0
        private ArcadeWheel[] CreateWheelPair(string placement, int wheelIndex, GameObject car, Vdf vdf, Vtf vtf, SdfPart[] parts)
        {
            var wheel1Name = placement + "Right";
            var wheel      = Instantiate(placement == "Front" ? SteerWheelPrefab : DriveWheelPrefab, car.transform);

            wheel.gameObject.name = wheel1Name;
            ImportCarParts(wheel.transform.Find("Mesh").gameObject, vtf, parts, true);
            wheel.transform.localPosition = vdf.WheelLoc[wheelIndex].Position;

            var wheel2 = Instantiate(wheel, car.transform);

            wheel2.name = placement + "Left";
            wheel2.transform.localPosition           = vdf.WheelLoc[wheelIndex + 1].Position;
            wheel2.transform.Find("Mesh").localScale = new Vector3(-1, 1, 1);

            return(new[] { wheel, wheel2 });
        }