コード例 #1
0
        public override string ToString()
        {
            var builder = new System.Text.StringBuilder();

            builder.AppendFormat("{0} {{", nameof(CarInfo)).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(CarId), CarId.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(IsConnected), IsConnected.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(CarModel), CarModel.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(CarSkin), CarSkin.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(DriverName), DriverName.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(DriverTeam), DriverTeam.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(DriverGuid), DriverGuid.ToString()).AppendLine();
            builder.AppendFormat("}}").AppendLine();
            return(builder.ToString());
        }
コード例 #2
0
    private void LoadSkin()
    {
        foreach (Transform b in CarPlaceHolder)
        {
            Destroy(b.gameObject);
        }
        CarSkin carSkin = _Loader.GetCarSkin(CarId, true);
        //carSkin.SetCountry(_Loader.contry);
        var original = carSkin.model;

        carModel  = (GameObject)Instantiate(original, CarPlaceHolder.position + original.transform.position.y * Vector3.up, Quaternion.identity);
        renderers = carModel.GetComponentsInChildren <Renderer>();
        if (carSkin.haveColor)
        {
            carSkin.SetColor(renderers);
        }
        Player.SetFlag(carModel, _Loader.Country);
        carModel.transform.parent = CarPlaceHolder;
    }
コード例 #3
0
ファイル: Driver.cs プロジェクト: Measter/ACServerPlugin
        public override string ToString()
        {
            var builder = new System.Text.StringBuilder();

            builder.AppendFormat("{0} {{", nameof(Driver)).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(CarId), CarId.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(CarModel), CarModel.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(CarSkin), CarSkin.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(Name), Name.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(Team), Team.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(GUID), GUID.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(IsConnected), IsConnected.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(Position), Position.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(VelocityVector), VelocityVector.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(Speed), Speed.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(SplinePosition), SplinePosition.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(Gear), Gear.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(EngineRPM), EngineRPM.ToString()).AppendLine();
            builder.AppendFormat("}}").AppendLine();
            return(builder.ToString());
        }
コード例 #4
0
    public void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
            Cancel();
   
        sPos = Mathf.Lerp(sPos, car, Time.deltaTime * 2);
        sPos = Mathf.MoveTowards(sPos, car, Time.deltaTime * .3f);
        carName.text = (CarId + 1) + "/" + _Loader.CarSkins.Count;
        if (Input.GetMouseButton(0))
        {
            var mouseDelta = getMouseDelta();
            //camRot.x -= mouseDelta.y * 3;
            camRot.y += mouseDelta.x * 3;            
        }
        else
            camRot.y += 10 * Time.deltaTime;
        camRot.x = Mathf.Clamp(camRot.x, 0, 45);
        cam.eulerAngles = camRot;

        GUITexture[] txts = new[] { leftButton, rightButton, selectButton, cancelButton, selectFlagButton };

        carSkin = _Loader.GetCarSkin(CarId, true);
        locked = false;
        if (!carSkin.medalsUnlocked && !_Loader.carsCheat)
        {
            locked = true;
            lockedTxt.text = string.Format(Tr("You need {0} medals to unlock this car, you have {1}"), carSkin.medalsNeeded, _Loader.medals);
        }
        else if (carSkin.friendsNeeded > _Integration.FbFriendsInGame && !_Loader.tankCheat)
        {
            locked = true;
            lockedTxt.text = string.Format(Tr("You need {0} invited friends on facebook to unlock this tank, you have {1}"), carSkin.friendsNeeded, _Integration.FbFriendsInGame);
        }
        lockedButton.enabled = locked;
        selectButton.texture = locked ? lockedIcon : selectIcon;
        lockedTxt.enabled = textbacground.enabled = locked;
        selectFlagButton.enabled = car == 0;
        var posx = Mod(sPos + .5f, 1) - .5f;
        foreach (GUITexture a in txts)
        {
            //a.enabled = animation.isPlaying;
            var hitTest = a.HitTest(Input.mousePosition) && (a != selectButton || !locked);
            a.color = hitTest ? new Color(1, 1, 1, 1) : new Color(.5f, .5f, .5f, 1);

            if (hitTest && Input.GetMouseButtonDown(0))
            {
                //var leftButtonDown = a == leftButton ;
                //var rightButtonDown = a == rightButton ;
                ////if(Math.Abs(old - posx) < .005f)
                //if (leftButtonDown || rightButtonDown)
                //{

                //    var i = leftButtonDown ? -1 : 1;
                //    while (true)
                //    {
                //        car += i;
                //        if (_Loader.GetCarSkin(CarId).friendsNeeded == 0 || _Integration.fbLoggedIn || _Loader.tankCheat)
                //            break;
                //    }
                //    break;
                //}
                //if (selectFlagButton.enabled && selectFlagButton == a)
                //{
                //    _Loader.Country++;
                //    _Loader.Country = (CountryCodes)((int)_Loader.Country % Enum.GetValues(typeof(CountryCodes)).Length);
                //    SetFlag(carModel, _Loader.Country);
                //}
                //if (input.GetKeyDown(KeyCode.Escape) || cancelButton == a)
                //{
                //    Cancel();
                //}
                //else if (!locked && selectButton == a)
                //{
                //    _Loader.carSkin = CarId;
                //    LoadLevel(Levels.menu);
                //}
            }
        }
        if (Math.Abs(old - posx) > .9f)
        {
            LoadSkin();
        }
        old = posx;

        CarPlaceHolder.parent.position = -Camera.main.transform.right * posx * Scale;
    }
コード例 #5
0
    //protected IEnumerator TakeScreenshot()
    //{
    //    yield return new WaitForEndOfFrame();
    //    int width = Screen.width;
    //    int height = Screen.height;
    //    Texture2D tx = new Texture2D(width, height, TextureFormat.RGB24, false);
    //    tx.ReadPixels(new Rect(0, 0, width, height), 0, 0);
    //    tx.Apply();
    //    yield return new WaitForEndOfFrame();
    //    byte[] screenshotBytes = tx.EncodeToPNG();
    //    Destroy(tx);
    //    WWWForm form = new WWWForm();
    //    form.AddField("name", playerName);
    //    form.AddBinaryData("file", screenshotBytes);

    //    var w = new WWW(mainsite + "uploadScreenshot.php", form);
    //    _CustomWindow.ShowWindow(delegate { gui.Label("Uploading Screenshot"); });
    //    yield return w;
    //    _CustomWindow.ShowWindow(delegate { gui.Label("Copy screenshot url to clipboard"); gui.TextArea(w.text); });
    //}
#if old
    public void OnEditorGuiOld()
    {
        if (gui.Button("LoadScenes"))
        {
            LoadScenes();
        }
        if (gui.Button("InitCars"))
        {
            for (int i = 0; i < res.CarSkins.Count; i++)
            {
                int     a = Mathf.RoundToInt((float)i / (res.CarSkins.Count - 1) * 4f);
                CarSkin c = res.CarSkins[i];
                c.Speed    = a;
                c.Rotation = 4 - a;
                print(c.prefabName);
                print("speed:" + c.getSpeed());
                print("rotation:" + c.getRotation());
            }
            SetDirty(res);
        }

        if (levelEditor != null)
        {
            _Loader.AproveMap();
        }
        foreach (var a in resEditor.renderSettings)
        {
            if (GUILayout.Button(a.name))
            {
                a.Active();
            }
        }

        playerName = gui.TextField(playerName);

        carSkin = EditorGUILayout.IntField("Car Skin", carSkin);
        if (GUILayout.Button("Reset Settings"))
        {
            PlayerPrefsClear();
        }
        if (GUILayout.Button("Merge Dicts"))
        {
            var  splitString = SplitString(assetDictionaryMerge.text);
            var  dest        = SplitString(assetDictionaryMergeTo.text);
            bool merge       = false;
            for (int i = 0, j = 0; i < dest.Length; i++)
            {
                dest[i] = dest[i].Trim(';');
                if (dest[i] == "_merge_")
                {
                    merge = true;
                }
                else if (merge)
                {
                    print("merged " + splitString[j]);
                    dest[i] += ";" + splitString[j].Trim(';') + ";";
                    j++;
                }
            }
            WriteAllLines(UnityEditor.AssetDatabase.GetAssetPath(_Loader.assetDictionaryMergeTo), dest);
        }
    }
コード例 #6
0
        private static unsafe void E_CarSkins(byte *byteptr_t, uint length, Database.Underground2 db)
        {
            const uint size = 0x40;
            var        map  = new Dictionary <int, string>();

            foreach (var car in db.CarTypeInfos.Collections)
            {
                map[car.Index] = car.CollectionName;
            }

            for (uint loop = 0; loop < length / size; ++loop)
            {
                uint offset = loop * size;

                var Reader = new CarSkin();
                Reader.Read(byteptr_t + offset, out int id, out int index);
                var car = db.CarTypeInfos.FindCollection(map[id]);
                if (car == null)
                {
                    continue;
                }

                switch (index)
                {
                case 1:
                    car.CARSKIN01 = Reader;
                    break;

                case 2:
                    car.CARSKIN02 = Reader;
                    break;

                case 3:
                    car.CARSKIN03 = Reader;
                    break;

                case 4:
                    car.CARSKIN04 = Reader;
                    break;

                case 5:
                    car.CARSKIN05 = Reader;
                    break;

                case 6:
                    car.CARSKIN06 = Reader;
                    break;

                case 7:
                    car.CARSKIN07 = Reader;
                    break;

                case 8:
                    car.CARSKIN08 = Reader;
                    break;

                case 9:
                    car.CARSKIN09 = Reader;
                    break;

                case 10:
                    car.CARSKIN10 = Reader;
                    break;

                default:
                    break;
                }
            }
        }
コード例 #7
0
    public void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Cancel();
        }

        sPos         = Mathf.Lerp(sPos, car, Time.deltaTime * 2);
        sPos         = Mathf.MoveTowards(sPos, car, Time.deltaTime * .3f);
        carName.text = (CarId + 1) + "/" + _Loader.CarSkins.Count;
        if (Input.GetMouseButton(0))
        {
            var mouseDelta = getMouseDelta();
            //camRot.x -= mouseDelta.y * 3;
            camRot.y += mouseDelta.x * 3;
        }
        else
        {
            camRot.y += 10 * Time.deltaTime;
        }
        camRot.x        = Mathf.Clamp(camRot.x, 0, 45);
        cam.eulerAngles = camRot;

        GUITexture[] txts = new[] { leftButton, rightButton, selectButton, cancelButton, selectFlagButton };

        carSkin = _Loader.GetCarSkin(CarId, true);
        locked  = false;
        if (!carSkin.medalsUnlocked && !_Loader.carsCheat)
        {
            locked         = true;
            lockedTxt.text = string.Format(Tr("You need {0} medals to unlock this car, you have {1}"), carSkin.medalsNeeded, _Loader.medals);
        }
        else if (carSkin.friendsNeeded > _Integration.FbFriendsInGame && !_Loader.tankCheat)
        {
            locked         = true;
            lockedTxt.text = string.Format(Tr("You need {0} invited friends on facebook to unlock this tank, you have {1}"), carSkin.friendsNeeded, _Integration.FbFriendsInGame);
        }
        lockedButton.enabled     = locked;
        selectButton.texture     = locked ? lockedIcon : selectIcon;
        lockedTxt.enabled        = textbacground.enabled = locked;
        selectFlagButton.enabled = car == 0;
        var posx = Mod(sPos + .5f, 1) - .5f;

        foreach (GUITexture a in txts)
        {
            //a.enabled = animation.isPlaying;
            var hitTest = a.HitTest(Input.mousePosition) && (a != selectButton || !locked);
            a.color = hitTest ? new Color(1, 1, 1, 1) : new Color(.5f, .5f, .5f, 1);

            if (hitTest && Input.GetMouseButtonDown(0))
            {
                //var leftButtonDown = a == leftButton ;
                //var rightButtonDown = a == rightButton ;
                ////if(Math.Abs(old - posx) < .005f)
                //if (leftButtonDown || rightButtonDown)
                //{

                //    var i = leftButtonDown ? -1 : 1;
                //    while (true)
                //    {
                //        car += i;
                //        if (_Loader.GetCarSkin(CarId).friendsNeeded == 0 || _Integration.fbLoggedIn || _Loader.tankCheat)
                //            break;
                //    }
                //    break;
                //}
                //if (selectFlagButton.enabled && selectFlagButton == a)
                //{
                //    _Loader.Country++;
                //    _Loader.Country = (CountryCodes)((int)_Loader.Country % Enum.GetValues(typeof(CountryCodes)).Length);
                //    SetFlag(carModel, _Loader.Country);
                //}
                //if (input.GetKeyDown(KeyCode.Escape) || cancelButton == a)
                //{
                //    Cancel();
                //}
                //else if (!locked && selectButton == a)
                //{
                //    _Loader.carSkin = CarId;
                //    LoadLevel(Levels.menu);
                //}
            }
        }
        if (Math.Abs(old - posx) > .9f)
        {
            LoadSkin();
        }
        old = posx;

        CarPlaceHolder.parent.position = -Camera.main.transform.right * posx * Scale;
    }
コード例 #8
0
 public void LoadCarSkins()
 {
     res.CarSkins = new List<CarSkin>();
     var splitString = SplitString(setting.carSkinsTxt.text);
     for (int i = 0; i < splitString.Length; i++)
     {
         var a = splitString[i];
         var car = new CarSkin();
         car.prefabName = a;
         if (i == splitString.Length - 1)
             car.friendsNeeded = 3;
         else
             car.medalsNeeded = (int)((float)i / splitString.Length * (SceneCount * 2));
         res.CarSkins.Add(car);
     }
 }