예제 #1
0
		IEnumerator LoadRoutine()
		{
			while(!AssetLoader.Ready)
			{
				yield return null;
			}


			AssetDefinition bulletDef = AssetLoader.GetAssetDefinitionWithName("BDArmory/AssetBundles/bdabulletshader", "BDArmory/Bullet");
			AssetDefinition unlitBlackDef = AssetLoader.GetAssetDefinitionWithName("BDArmory/AssetBundles/bdaunlitblack", "BDArmory/Unlit Black");
			AssetDefinition grayscaleDef = AssetLoader.GetAssetDefinitionWithName("BDArmory/AssetBundles/bdagrayscaleshader", "BDArmory/Grayscale Effect");
			AssetDefinition[] assetDefs = new AssetDefinition[]{ bulletDef, unlitBlackDef, grayscaleDef };
			AssetLoader.LoadAssets(AssetLoaded, assetDefs);
		}
예제 #2
0
        public bool EditBoolean(String name, bool defaultValue = false)
        {
            try
            {
                AssetDefinition assetDef = m_editAsset.Content;
                if (assetDef.Fields.ContainsKey(name))
                {
                    return(assetDef.AsBool(name));
                }
            }
            catch { }

            return(defaultValue);
        }
예제 #3
0
        public T EditEnum <T>(String name, T defaultValue = default(T))
        {
            try
            {
                AssetDefinition assetDef = m_editAsset.Content;
                if (assetDef.Fields.ContainsKey(name))
                {
                    return((T)Enum.Parse(typeof(T), assetDef.Fields[name] as String, true));
                }
            }
            catch { }

            return(defaultValue);
        }
예제 #4
0
        public float EditSingle(String name, float defaultValue = 0)
        {
            try
            {
                AssetDefinition assetDef = m_editAsset.Content;
                if (assetDef.Fields.ContainsKey(name))
                {
                    return(assetDef.AsFloat(name));
                }
            }
            catch { }

            return(defaultValue);
        }
예제 #5
0
        public int EditInt(String name, int defaultValue = 0)
        {
            try
            {
                AssetDefinition assetDef = m_editAsset.Content;
                if (assetDef.Fields.ContainsKey(name))
                {
                    return(assetDef.AsInt(name));
                }
            }
            catch { }

            return(defaultValue);
        }
예제 #6
0
        public T Edit <T>(String name, T defaultValue = default(T))
        {
            try
            {
                AssetDefinition assetDef = m_editAsset.Content;
                if (assetDef.Fields.ContainsKey(name))
                {
                    return((T)assetDef.Fields[name]);
                }
            }
            catch { }

            return(defaultValue);
        }
예제 #7
0
        public void UpdateAssetDefinition(AssetDefinition eAssetDefinition)
        {
            query  = "UPDATE AssetDefinition SET AssetName = @AssetName,CategoryId = @CategoryId,BrandName = @BrandName,";
            query += "DepreciationMethod = @DepreciationMethod WHERE AssetDefinitionId= @AssetDefinitionId";

            data.SetSqlStatement(query, CommandType.Text);

            data.Parameter("@AssetDefinitionId", SqlDbType.BigInt, eAssetDefinition.AssetDefinitionId);
            data.Parameter("@AssetName", SqlDbType.NVarChar, 100, eAssetDefinition.AssetName);
            data.Parameter("@CategoryId", SqlDbType.Int, eAssetDefinition.CategoryId);
            data.Parameter("@BrandName", SqlDbType.NVarChar, 50, eAssetDefinition.BrandName);
            data.Parameter("@DepreciationMethod", SqlDbType.Char, 1, eAssetDefinition.DepreciationMethod);

            data.ExecuteScalar();
        }
예제 #8
0
        public Vector2 EditVector2(String name, Vector2 defaultValue)
        {
            try
            {
                AssetDefinition assetDef = m_editAsset.Content;
                if (assetDef.Fields.ContainsKey(name) && assetDef.Fields[name] is AssetDefinition)
                {
                    AssetDefinition vecAssetDef = assetDef.Fields[name] as AssetDefinition;
                    return(new Vector2(vecAssetDef.AsFloat("X"), vecAssetDef.AsFloat("Y")));
                }
            }
            catch { }

            return(defaultValue);
        }
예제 #9
0
        IEnumerator LoadRoutine()
        {
            while (!AssetLoader.Ready)
            {
                yield return(null);
            }


            AssetDefinition bulletDef     = AssetLoader.GetAssetDefinitionWithName("BDArmory/AssetBundles/bdabulletshader", "BDArmory/Bullet");
            AssetDefinition unlitBlackDef = AssetLoader.GetAssetDefinitionWithName("BDArmory/AssetBundles/bdaunlitblack", "BDArmory/Unlit Black");
            AssetDefinition grayscaleDef  = AssetLoader.GetAssetDefinitionWithName("BDArmory/AssetBundles/bdagrayscaleshader", "BDArmory/Grayscale Effect");

            AssetDefinition[] assetDefs = new AssetDefinition[] { bulletDef, unlitBlackDef, grayscaleDef };
            AssetLoader.LoadAssets(AssetLoaded, assetDefs);
        }
예제 #10
0
        public ActionResult EditAssetDefinition(AssetDefinition eAssetDefinition)
        {
            if (eAssetDefinition.isLoad == false)
            {
                DataTable dtCategory = CategoriesBI.GetCategories();
                ViewData["CategoryName"] = General.DataTableToSelectList(dtCategory, "CategoryId", "CategoryName", "0", TopEmptyItem: new SelectListItem {
                    Value = "0", Text = ""
                });

                DataTable dtDepreciationMethods = General.GetDepreciationMethods();
                ViewData["DepreciationMethods"] = General.DataTableToSelectList(dtDepreciationMethods, "Value", "Text", "0", TopEmptyItem: new SelectListItem {
                    Value = "0", Text = ""
                });

                eAssetDefinition.AssetDefinitionId = Convert.ToInt32(Request.Params["AssetDefinitionId"]);
                AssetDefinitionBI.LoadAssetDefinition(ref eAssetDefinition);
                return(PartialView(eAssetDefinition));
            }
            else
            {
                string message = "";
                if (ModelState.IsValid)
                {
                    try
                    {
                        FASM_Enums.InfoMessages Results = AssetDefinitionBI.SaveAssetDefinition(ref eAssetDefinition);

                        switch (Results)
                        {
                        case FASM_Enums.InfoMessages.Success:
                            message = FASM_Msg.Updated;
                            break;

                        case FASM_Enums.InfoMessages.AlreadyExist:
                            message = "Sorry! the Asset Name already exist";
                            break;
                        }
                        return(Json(new { msg = message, JsonRequestBehavior.AllowGet }));
                    }
                    catch (Exception ex)
                    {
                        ViewBag.CatchedMsg = ex.Message;
                    }
                }
            }

            return(View(eAssetDefinition));
        }
        public async Task <CreateAssetDefinitionResponse> Handle(
            CreateAssetDefinitionRequest aCreateAssetDefinitionRequest,
            CancellationToken aCancellationToken)
        {
            AssetDefinition assetDefintion = Mapper.Map <AssetDefinitionDto, AssetDefinition>(aCreateAssetDefinitionRequest.AssetDefinitionDto);

            HercPwaDbContext.AssetDefinitions.Add(assetDefintion);
            await HercPwaDbContext.SaveChangesAsync(aCancellationToken);

            var createAssetDefinitionResponse = new CreateAssetDefinitionResponse(aCreateAssetDefinitionRequest.Guid)
            {
                AssetDefinition = Mapper.Map <AssetDefinition, AssetDefinitionDto>(assetDefintion)
            };

            return(createAssetDefinitionResponse);
        }
예제 #12
0
 public FASM_Enums.InfoMessages SaveAssetDefinition(ref AssetDefinition eAssetDefinition)
 {
     //Check if already exists
     if (AssetDefinitionDAL.DoesAssetDefinitionExists(eAssetDefinition.AssetDefinitionId, eAssetDefinition.AssetName) > 0)
     {
         return(FASM_Enums.InfoMessages.AlreadyExist);
     }
     if (eAssetDefinition.AssetDefinitionId == 0)
     {
         AssetDefinitionDAL.InsertAssetDefinition(ref eAssetDefinition);
     }
     else
     {
         AssetDefinitionDAL.UpdateAssetDefinition(eAssetDefinition);
     }
     return(FASM_Enums.InfoMessages.Success);
 }
예제 #13
0
        public void InsertAssetDefinition(ref AssetDefinition eAssetDefinition)
        {
            query  = "INSERT INTO AssetDefinition(AssetName,CategoryId,BrandName,DepreciationMethod)";
            query += " VALUES(@AssetName,@CategoryId,@BrandName,@DepreciationMethod); SELECT @AssetDefinitionId = SCOPE_IDENTITY()";

            data.SetSqlStatement(query, CommandType.Text);

            data.Parameter("@AssetDefinitionId", SqlDbType.BigInt, eAssetDefinition.AssetDefinitionId, ParameterDirection.Output);
            data.Parameter("@AssetName", SqlDbType.NVarChar, 100, eAssetDefinition.AssetName);
            data.Parameter("@CategoryId", SqlDbType.Int, eAssetDefinition.CategoryId);
            data.Parameter("@BrandName", SqlDbType.NVarChar, 50, eAssetDefinition.BrandName);
            data.Parameter("@DepreciationMethod", SqlDbType.Char, 1, eAssetDefinition.DepreciationMethod);

            data.ExecuteScalar();

            eAssetDefinition.AssetDefinitionId = Int64.Parse(data.GetParamValue("@AssetDefinitionId").ToString());
        }
예제 #14
0
        public static void EditSmoothingAlgorithm(AssetDefinition adef, PropertyDefinition pdef, bool allowExtrapolation)
        {
            if (adef is StateDefinition)
            {
                if (allowExtrapolation)
                {
                    WithLabel("Smoothing Algorithm", () =>
                    {
                        pdef.StateAssetSettings.SmoothingAlgorithm = (SmoothingAlgorithms)EditorGUILayout.EnumPopup(pdef.StateAssetSettings.SmoothingAlgorithm);
                    });
                }
                else
                {
                    WithLabel("Smoothing Algorithm", () =>
                    {
                        if (ToggleDropdown(SmoothingAlgorithms.Interpolation.ToString(), SmoothingAlgorithms.None.ToString(), pdef.StateAssetSettings.SmoothingAlgorithm != SmoothingAlgorithms.None))
                        {
                            pdef.StateAssetSettings.SmoothingAlgorithm = SmoothingAlgorithms.Interpolation;
                        }
                        else
                        {
                            pdef.StateAssetSettings.SmoothingAlgorithm = SmoothingAlgorithms.None;
                        }
                    });
                }

                if (pdef.StateAssetSettings.SmoothingAlgorithm == SmoothingAlgorithms.Extrapolation)
                {
                    if (pdef.PropertyType is PropertyTypeTransform)
                    {
                        PropertyTypeTransform transform = (PropertyTypeTransform)pdef.PropertyType;

                        WithLabel("Extrapolation Velocity", () =>
                        {
                            transform.ExtrapolationVelocityMode = (ExtrapolationVelocityModes)EditorGUILayout.EnumPopup(transform.ExtrapolationVelocityMode);
                        });
                    }

                    WithLabel("Extrapolation Settings", () =>
                    {
                        pdef.StateAssetSettings.ExtrapolationMaxFrames      = IntFieldOverlay(pdef.StateAssetSettings.ExtrapolationMaxFrames, "Max Frames");
                        pdef.StateAssetSettings.ExtrapolationErrorTolerance = FloatFieldOverlay(pdef.StateAssetSettings.ExtrapolationErrorTolerance, "Error Tolerance");
                    });
                }
            }
        }
    void NewAsset(AssetDefinition def)
    {
        def.Guid = Guid.NewGuid();
        def.Name = "New" + def.GetType().Name.Replace("Definition", "");

        if (HasGroupSelected)
        {
            def.Groups.Add(Project.ActiveGroup);
        }

        // add to parent
        ArrayUtility.Add(ref Project.RootFolder.Assets, def);

        // select it
        Select(def, true);

        // save project
        Save();
    }
        public async Task Should_get_AssetDefinition()
        {
            //Arrange
            // Build the AssetDefinition
            var assetDefinition = new AssetDefinition()
            {
                Name = AssetDefinitionName,
                Url  = AssetDefinitionUrl,
            };

            var metricDefinitions = new MetricDefinition[]
            {
                new MetricDefinition {
                    Name = "Assay", Default = "0.9999", UnitOfMeasure = "Fineness", Description = "A Bar of Gold", SampleValue = "0.9999", Regex = @"^0([.,])\d+"
                },
                new MetricDefinition {
                    Name = "Bar Serial #", Description = "The serial number of the bar of gold", SampleValue = "123456", UnitOfMeasure = "Identifier"
                }
            };

            assetDefinition.MetricDefinitions = metricDefinitions;

            await InsertAsync(assetDefinition);

            var getAssetDefinitionRequest = new GetAssetDefinitionRequest
            {
                AssetDefinitionId = assetDefinition.AssetDefinitionId
            };

            //Act
            GetAssetDefinitionResponse getAssetDefinitionResponse = await SendAsync(getAssetDefinitionRequest);

            //Assert
            getAssetDefinitionResponse.AssetDefinition.ShouldNotBeNull();
            AssetDefinitionDto assetDefinitionDto = getAssetDefinitionResponse.AssetDefinition;

            assetDefinitionDto.Name.ShouldBe(AssetDefinitionName);
            assetDefinitionDto.Url.ShouldBe(AssetDefinitionUrl);
            assetDefinitionDto.MetricDefinitions.Count.ShouldBe(2);
            assetDefinitionDto.MetricDefinitions[0].Description.ShouldBe(assetDefinition.MetricDefinitions[0].Description);
        }
    void Select(AssetDefinition asset, bool focusEditor)
    {
        if (asset == null)
        {
            selectedAssetGuid = null;
        }
        else
        {
            selectedAssetGuid = asset.Guid.ToString();
        }

        Repaints = 10;
        Selected = asset;
        BeginClearFocus();

        DEditorGUI.UseEvent();

        if (focusEditor)
        {
            AscensionEditorWindow.Open();
        }
    }
예제 #18
0
        public ActionResult CreateAssetDefinition(AssetDefinition eAssetDefinition)
        {
            string message = "";

            if (ModelState.IsValid)
            {
                try
                {
                    DataTable dtCategory = CategoriesBI.GetCategories();
                    ViewData["CategoryName"] = General.DataTableToSelectList(dtCategory, "CategoryId", "CategoryName", "0", TopEmptyItem: new SelectListItem {
                        Value = "0", Text = ""
                    });

                    DataTable dtDepreciationMethods = General.GetDepreciationMethods();
                    ViewData["DepreciationMethods"] = General.DataTableToSelectList(dtDepreciationMethods, "Value", "Text", "0", TopEmptyItem: new SelectListItem {
                        Value = "0", Text = ""
                    });

                    FASM_Enums.InfoMessages SaveResult = AssetDefinitionBI.SaveAssetDefinition(ref eAssetDefinition);
                    switch (SaveResult)
                    {
                    case FASM_Enums.InfoMessages.Success:
                        message = FASM_Msg.SuccessfulSaved;
                        break;

                    case FASM_Enums.InfoMessages.AlreadyExist:
                        message = "Asset Name already exist";
                        break;
                    }
                    return(Json(new { msg = message, JsonRequestBehavior.AllowGet }));
                }
                catch (Exception ex)
                {
                    ViewBag.CatchedMsg = ex.Message;
                }
            }

            return(View(eAssetDefinition));
        }
예제 #19
0
        public ActionResult IndexAssetDefinition()
        {
            ViewBag.AllowAdd    = this.HasPermission(ControllerName.AssetManagement + "-CreateAssetDefinition");
            ViewBag.AllowEdit   = this.HasPermission(ControllerName.AssetManagement + "-EditAssetDefinition");
            ViewBag.AllowDelete = this.HasPermission(ControllerName.AssetManagement + "-DeleteAssetDefinition");

            DataTable dtCategory = CategoriesBI.GetCategories();

            ViewData["CategoryName"] = General.DataTableToSelectList(dtCategory, "CategoryId", "CategoryName", "0", TopEmptyItem: new SelectListItem {
                Value = "0", Text = ""
            });

            DataTable dtDepreciationMethods = General.GetDepreciationMethods();

            ViewData["DepreciationMethods"] = General.DataTableToSelectList(dtDepreciationMethods, "Value", "Text", "0", TopEmptyItem: new SelectListItem {
                Value = "0", Text = ""
            });

            AssetDefinition eAssetDefinition = new AssetDefinition();

            eAssetDefinition.dtAssetDefinition = AssetDefinitionBI.GetAssetDefinition();
            return(View(eAssetDefinition));
        }
        public TxTemplate MakeCreateTransaction(Asset assets, dynamic metadata, List <Output> outputs, List <string> issuers)
        {
            var assetsDefinition = new AssetDefinition {
                Data = assets.Assets.Data ?? null
            };


            var _inputs = new List <InputTemplate>();

            foreach (var issuer in issuers)
            {
                _inputs.Add(makeInputTemplate(new List <string> {
                    issuer
                }));
            }
            //var _inputs = makeInputTemplate( issuers);

            return(MakeTrasnsaction(Transaction.CREATE.ToString(),
                                    assetsDefinition,
                                    metadata,
                                    outputs,
                                    _inputs));
        }
예제 #21
0
        public void LoadAssetDefinition(ref AssetDefinition eAssetDefinition)
        {
            query  = "SELECT AssetDefinitionId,AssetName,CategoryId,BrandName,DepreciationMethod FROM AssetDefinition";
            query += " WHERE AssetDefinitionId=@AssetDefinitionId";

            data.SetSqlStatement(query, CommandType.Text);

            data.Parameter("@AssetDefinitionId", SqlDbType.BigInt, eAssetDefinition.AssetDefinitionId);

            DataTable dt = data.FillData();

            if (dt != null && dt.Rows.Count > 0)
            {
                DataRow dr = dt.Rows[0];
                eAssetDefinition = new AssetDefinition()
                {
                    AssetDefinitionId  = Int64.Parse(dr["AssetDefinitionId"].ToString()),
                    AssetName          = dr["AssetName"].ToString(),
                    CategoryId         = Int32.Parse(dr["CategoryId"].ToString()),
                    BrandName          = dr["BrandName"].ToString(),
                    DepreciationMethod = dr["DepreciationMethod"].ToString()
                };
            }
        }
예제 #22
0
    protected void OnGUI()
    {
        if (Event.current.keyCode == KeyCode.Return && Event.current.type == EventType.KeyDown)
        {
            const EventModifiers MODS = EventModifiers.Control;

            if ((Event.current.modifiers & MODS) == MODS)
            {
                Event.current.Use();

                // compile!
                if (RuntimeSettings.Instance.compileAsDll)
                {
                    AscensionDataAssemblyCompiler.Run();
                }
                else
                {
                    AscensionDataAssemblyCompiler.CodeEmit();
                }
            }
        }

        DEditorGUI.Tooltip = "";

        LoadProject();

        if (Event.current.type == EventType.Repaint)
        {
            Repaints = Mathf.Max(0, Repaints - 1);
        }

        if (Selected != null && Selected.Deleted)
        {
            Selected = null;
        }
    }
예제 #23
0
 private void openAsset()
 {
     if (checkNeedToSave("open an asset definition file"))
     {
         string dir = RepositoryClass.Instance.AssetDefinitionDirectory;
         if (dir != "" && Directory.Exists(dir))
         {
             openAssetDialog.InitialDirectory = dir;
         }
         if (openAssetDialog.ShowDialog() == DialogResult.OK)
         {
             List <string> log = new List <string>();
             assetDefinition = AssetDefinition.ReadXmlFile(openAssetDialog.FileName, log);
             if (log.Count > 0)
             {
                 string lines = "";
                 foreach (string s in log)
                 {
                     lines += s + "\n";
                 }
                 MessageBox.Show("Error(s) reading asset definition - - reading cancelled\n\n" + lines,
                                 "Errors Reading Asset Definition File",
                                 MessageBoxButtons.OK);
                 return;
             }
             ClearControls();
             CheckLogAndMaybeExit(log);
             savedProperties = assetDefinition.Properties;
             displayAssetDefinition();
             setAssetFileName(openAssetDialog.FileName);
             somethingChanged = false;
             cameFromFile     = true;
             setEnables();
         }
     }
 }
예제 #24
0
 public void LoadAssetDefinition(ref AssetDefinition eAssetDefinition)
 {
     AssetDefinitionDAL.LoadAssetDefinition(ref eAssetDefinition);
 }
예제 #25
0
        public static void LoadAssetDefinition(ref AssetDefinition eAssetDefinition)
        {
            AssetDefinitionBL AssetDefinitionBL = new AssetDefinitionBL();

            AssetDefinitionBL.LoadAssetDefinition(ref eAssetDefinition);
        }
예제 #26
0
 public static void EditSmoothingAlgorithm(AssetDefinition adef, PropertyDefinition pdef)
 {
     EditSmoothingAlgorithm(adef, pdef, true);
 }
    void EditProperty(AssetDefinition def, PropertyDefinition p, bool first, bool last)
    {
        BeginBackground();

        GUILayout.BeginHorizontal(DEditorGUI.HeaderBackground, GUILayout.Height(DEditorGUI.HEADER_HEIGHT));

        if ((Event.current.modifiers & EventModifiers.Control) == EventModifiers.Control)
        {
            if (DEditorGUI.IconButton("minus-editor"))
            {
                if (EditorUtility.DisplayDialog("Delete Property", string.Format("Do you want to delete '{0}' (Property)?", p.Name), "Yes", "No"))
                {
                    p.Deleted = true;
                }
            }
        }
        else
        {
            if (DEditorGUI.Toggle("arrow-down", "arrow-right", p.Expanded && (p.PropertyType.HasSettings || p.PropertyType.MecanimApplicable)))
            {
                p.Expanded = !p.Expanded;
            }
        }

        if (def is StateDefinition || def is ObjectDefinition)
        {
            p.Name = DEditorGUI.TextFieldOverlay(p.Name, p.Priority.ToString(), GUILayout.Width(181));

            switch (p.ReplicationMode)
            {
            case ReplicationMode.Everyone:
                DEditorGUI.Toggle("controller-plus", true);
                break;

            case ReplicationMode.EveryoneExceptController:
                DEditorGUI.Toggle("controller", false);
                break;

            case ReplicationMode.OnlyOwnerAndController:
                DEditorGUI.Toggle("controller-only", true);
                break;

            case ReplicationMode.LocalForEachPlayer:
                DEditorGUI.Toggle("owner-only", true);
                break;
            }
        }
        else
        {
            p.Name = EditorGUILayout.TextField(p.Name, GUILayout.Width(200));
        }

        DEditorGUI.SetTooltip("Name. The name of this property, has to be a valid C# property name.");

        // edit property type
        DEditorGUI.PropertyTypePopup(def, p);
        DEditorGUI.SetTooltip("Type. The type of this property.");

        EditorGUI.BeginDisabledGroup(def.SortOrder != SortOrder.Manual);

        if (DEditorGUI.IconButton("arrow-down", !last))
        {
            p.Adjust += 1;
        }

        if (DEditorGUI.IconButton("arrow-up", !first))
        {
            p.Adjust -= 1;
        }

        EditorGUI.EndDisabledGroup();
        EditorGUILayout.EndHorizontal();

        if (p.Controller)
        {
            p.ReplicationMode = ReplicationMode.Everyone;
            p.Controller      = false;
            Save();
        }

        if (p.Expanded)
        {
            GUILayout.Space(2);

            //DEditorGUI.WithLabel("Comment", () => {
            //  p.Comment = EditorGUILayout.TextField(p.Comment);
            //});

            if (def is StateDefinition || def is ObjectDefinition)
            {
                DEditorGUI.WithLabel("Replication", () =>
                {
                    p.Priority        = DEditorGUI.EditPriority(p.Priority, p.PropertyType.HasPriority);
                    p.ReplicationMode = (ReplicationMode)EditorGUILayout.EnumPopup(p.ReplicationMode);
                });
            }

            if (def is CommandDefinition)
            {
                if (p.PropertyType.CanSmoothCorrections && ((CommandDefinition)def).Result.Contains(p))
                {
                    DEditorGUI.WithLabel("Smooth Corrections", () =>
                    {
                        p.CommandAssetSettings.SmoothCorrection = EditorGUILayout.Toggle(p.CommandAssetSettings.SmoothCorrection);
                    });
                }
            }

            if (p.PropertyType.MecanimApplicable && (def is StateDefinition))
            {
                DEditorGUI.WithLabel("Mecanim", () =>
                {
                    EditorGUILayout.BeginHorizontal();

                    if (p.PropertyType is PropertyTypeFloat)
                    {
                        p.StateAssetSettings.MecanimMode = (MecanimMode)EditorGUILayout.EnumPopup(p.StateAssetSettings.MecanimMode);
                        EditorGUI.BeginDisabledGroup(p.StateAssetSettings.MecanimMode == MecanimMode.Disabled);

                        p.StateAssetSettings.MecanimDirection = (MecanimDirection)EditorGUILayout.EnumPopup(p.StateAssetSettings.MecanimDirection);

                        switch (p.StateAssetSettings.MecanimMode)
                        {
                        case MecanimMode.Parameter:
                            if (p.StateAssetSettings.MecanimDirection == MecanimDirection.UsingAscensionProperties)
                            {
                                p.StateAssetSettings.MecanimDamping = DEditorGUI.FloatFieldOverlay(p.StateAssetSettings.MecanimDamping, "Damping Time");
                            }

                            break;

                        case MecanimMode.LayerWeight:
                            p.StateAssetSettings.MecanimLayer = DEditorGUI.IntFieldOverlay(p.StateAssetSettings.MecanimLayer, "Layer Index");
                            break;
                        }

                        EditorGUI.EndDisabledGroup();
                    }
                    else
                    {
                        p.StateAssetSettings.MecanimMode = (MecanimMode)(int)EditorGUILayout.Popup((int)p.StateAssetSettings.MecanimMode, new string[] { "Disabled", "Parameter" });

                        EditorGUI.BeginDisabledGroup(p.StateAssetSettings.MecanimMode == MecanimMode.Disabled);
                        p.StateAssetSettings.MecanimDirection = (MecanimDirection)EditorGUILayout.EnumPopup(p.StateAssetSettings.MecanimDirection);

                        if (p.PropertyType is PropertyTypeTrigger)
                        {
                            p.StateAssetSettings.MecanimLayer = DEditorGUI.IntFieldOverlay(p.StateAssetSettings.MecanimLayer, "Layer Index");
                        }
                        EditorGUI.EndDisabledGroup();
                    }

                    EditorGUILayout.EndHorizontal();
                });
            }

            if (p.PropertyType.HasSettings)
            {
                PropertyEditorRegistry.GetEditor(p.PropertyType.GetType()).Edit(def, p);
            }
        }
        else
        {
            GUILayout.Space(2);
        }

        EditorGUILayout.EndVertical();
    }
예제 #28
0
        public static FASM_Enums.InfoMessages SaveAssetDefinition(ref AssetDefinition eAssetDefinition)
        {
            AssetDefinitionBL AssetDefinitionBL = new AssetDefinitionBL();

            return(AssetDefinitionBL.SaveAssetDefinition(ref eAssetDefinition));
        }
    new void OnGUI()
    {
        base.OnGUI();

        GUILayout.BeginArea(new Rect(0, 0, position.width, position.height - 22));
        scroll = GUILayout.BeginScrollView(scroll, false, false);

        EditorGUILayout.BeginHorizontal();

        var addingGroup = addGroup != null && addGroupTo != null;

        if (addingGroup)
        {
            GUI.SetNextControlName("AscensionProjectWindow_AddGroup");
            addGroup = GUILayout.TextField(addGroup);
            GUI.FocusControl("AscensionProjectWindow_AddGroup");

            switch (Event.current.keyCode.ToString())
            {
            case "Return":
                addGroup = addGroup.Trim();

                if (addGroup.Length > 0)
                {
                    addGroupTo.Groups.Add(addGroup);
                }

                addGroup   = null;
                addGroupTo = null;
                break;

            case "Escape":
                addGroup   = null;
                addGroupTo = null;
                break;
            }
        }
        else
        {
            EditorGUI.BeginDisabledGroup(Project.Groups.Count() == 0);

            var list = new[] { "Everything" }.Concat(Project.Groups).ToArray();
            var listCounted = new[] { "Everything (" + Project.RootFolder.Assets.Length + ")" }.Concat(Project.Groups.Select(x => x + " (" + Project.RootFolder.Assets.Count(a => a.Groups.Contains(x)) + ")")).ToArray();

            var index    = Mathf.Max(0, Array.IndexOf(list, Project.ActiveGroup));
            var selected = EditorGUILayout.Popup(index, listCounted);

            if (Project.ActiveGroup != list[selected])
            {
                Project.ActiveGroup = list[selected];
                Save();
            }

            EditorGUI.EndDisabledGroup();
        }

        EditorGUILayout.EndHorizontal();

        if (HasProject)
        {
            Header("States", "states");
            DisplayAssetList(Project.States.Cast <AssetDefinition>());

            Header("Objects", "objects");
            DisplayAssetList(Project.Structs.Cast <AssetDefinition>());

            Header("Commands", "commands");
            DisplayAssetList(Project.Commands.Cast <AssetDefinition>());

            Header("Events", "events");
            DisplayAssetList(Project.Events.Cast <AssetDefinition>());

            if (DEditorGUI.IsRightClick)
            {
                GenericMenu menu = new GenericMenu();
                menu.AddItem(new GUIContent("New State"), false, () => NewAsset(new StateDefinition()));
                menu.AddItem(new GUIContent("New Object"), false, () => NewAsset(new ObjectDefinition()));
                menu.AddItem(new GUIContent("New Event"), false, () => NewAsset(new EventDefinition()));
                menu.AddItem(new GUIContent("New Command"), false, () => NewAsset(new CommandDefinition()));
                menu.ShowAsContext();
            }
        }

        if (GUI.changed)
        {
            Save();
        }

        ClearAllFocus();

        GUILayout.EndScrollView();
        GUILayout.EndArea();

        GUILayout.BeginArea(new Rect(4, position.height - 20, position.width - 8, 16));
        Footer();
        GUILayout.EndArea();
    }
예제 #30
0
        public static async Task <bool> PutBlockchainInAKnownState(string[] privateKeys)
        {
            var settings = settingsProvider.GetSettings();

            try
            {
                var  clientPrivateKey         = new BitcoinSecret(privateKeys[0]);
                var  hubPrivateKey            = new BitcoinSecret(privateKeys[1]);
                var  clientSelfRevokeKey      = new BitcoinSecret(privateKeys[2]);
                var  hubSelfRevokKey          = new BitcoinSecret(privateKeys[3]);
                var  feeSourcePrivateKey      = new BitcoinSecret(new Key(), settings.Network);
                var  feeDestinationPrivateKey = new BitcoinSecret(new Key(), settings.Network);
                uint feeCount = 100;

                AssetDefinition usdAsset = null;
                foreach (var item in (settings as IBlockchainStateManagerSettings).Assets)
                {
                    if (item.Name == "TestExchangeUSD")
                    {
                        usdAsset = item;
                        break;
                    }
                }

                if (!await StartRequiredJobs(true))
                {
                    return(false);
                }

                var bitcoinRPCCLient = GetRPCClient(settings as IBlockchainStateManagerSettings);

                IEnumerable <string> blkIds = null;

                for (int i = 0; i < 201; i++)
                {
                    var blkCount = 1;

                    blkIds = await bitcoinRPCCLient.GenerateBlocksAsync(blkCount);

                    await blockchainExplorerHelper.WaitUntillBlockchainExplorerHasIndexed
                        (blockchainExplorerHelper.HasBlockIndexed, blkIds);
                }

                /*
                 * for (int i = 0; i < 11; i++)
                 * {
                 *  var blkCount = 20;
                 *  if (i == 10)
                 *  {
                 *      blkCount = 1;
                 *  }
                 *
                 *  blkIds = await bitcoinRPCCLient.GenerateBlocksAsync(blkCount);
                 *  await blockchainExplorerHelper.WaitUntillBlockchainExplorerHasIndexed
                 *      (blockchainExplorerHelper.HasBlockIndexed, blkIds);
                 * }
                 */
                await bitcoinRPCCLient.ImportPrivKeyAsync(new BitcoinSecret(usdAsset.PrivateKey));

                var txId = await bitcoinRPCCLient.SendToAddressAsync(new BitcoinSecret(usdAsset.PrivateKey).GetAddress(),
                                                                     new Money(100 * Constants.BTCToSathoshiMultiplicationFactor));

                await blockchainExplorerHelper.WaitUntillBlockchainExplorerHasIndexed
                    (blockchainExplorerHelper.HasTransactionIndexed, new string[] { txId.ToString() });

                txId = await bitcoinRPCCLient.SendToAddressAsync(feeSourcePrivateKey.GetAddress(),
                                                                 new Money((feeCount + 1) * Constants.BTCToSathoshiMultiplicationFactor));

                blkIds = await bitcoinRPCCLient.GenerateBlocksAsync(1);

                await blockchainExplorerHelper.WaitUntillBlockchainExplorerHasIndexed
                    (blockchainExplorerHelper.HasBlockIndexed, blkIds);

                await blockchainExplorerHelper.WaitUntillBlockchainExplorerHasIndexed
                    (blockchainExplorerHelper.HasTransactionIndexed, new string[] { txId.ToString() });

                await blockchainExplorerHelper.WaitUntillBlockchainExplorerHasIndexed
                    (blockchainExplorerHelper.HasBalanceIndexed, new string[] { txId.ToString() }, feeSourcePrivateKey.GetAddress().ToString());

                var error = await feeManager.GenerateFees(feeSourcePrivateKey, feeDestinationPrivateKey, (int)feeCount);

                if (error != null)
                {
                    return(false);
                }

                var signedResp = await GetOffchainSignedSetup(privateKeys);

                await transactionBroadcaster.BroadcastTransactionToBlockchain
                    (signedResp.FullySignedSetupTransaction);

                await blockchainExplorerHelper.WaitUntillBlockchainExplorerHasIndexed
                    (blockchainExplorerHelper.HasTransactionIndexed, new string[] { new Transaction(signedResp.FullySignedSetupTransaction).GetHash().ToString() });

                /*
                 * // Not used
                 * var unsignedCommitment = await offchainHelper.CreateUnsignedCommitmentTransactions(signedResp.FullySignedSetupTransaction, clientPrivateKey.PubKey,
                 *  hubPrivateKey.PubKey, 40, 65, ASSET, hubSelfRevokKey.PubKey, 10, true);
                 */

                var clientSignedCommitment = await Helper.SignTransactionWorker(new TransactionSignRequest
                {
                    TransactionToSign = signedResp.UnsignedClientCommitment0,
                    PrivateKey        = clientPrivateKey.ToString()
                }, SigHash.All | SigHash.AnyoneCanPay);

                var commitmentToLog = clientSignedCommitment;

                /*
                 * var commitmentSpendingResp = await offchainHelper.CreateCommitmentSpendingTransactionForTimeActivatePart(txSendingResult.ToHex(), hubPrivateKey.ToString(),
                 *  clientPrivateKey.PubKey, hubPrivateKey.PubKey, "TestExchangeUSD", hubSelfRevokKey.PubKey, 144, true);
                 */
                var commitmentSpendingResp = await offchainHelper.CreateCommitmentSpendingTransactionForMultisigPart(clientSignedCommitment, clientPrivateKey.PubKey, hubPrivateKey.PubKey,
                                                                                                                     ASSET, 75, hubSelfRevokKey.PubKey, 144, true, clientPrivateKey, hubSelfRevokKey);

                //  Fee is now directly paid from output for bitcoin
                //  txSendingResult = await AddEnoughFeesToTransaction
                //       (new Transaction(commitmentSpendingResp.TransactionHex));

                var hubSignedCommitment = await Helper.SignTransactionWorker(new TransactionSignRequest
                {
                    TransactionToSign = clientSignedCommitment,
                    PrivateKey        = hubPrivateKey.ToString()
                }, SigHash.All | SigHash.AnyoneCanPay);

                // var txSendingResult = await AddEnoughFeesToTransaction
                // (new Transaction(hubSignedCommitment));
                //var txSendingResult = new Transaction(hubSignedCommitment);
                //await transactionBroadcaster.BroadcastTransactionToBlockchain
                //    (txSendingResult.ToHex());
                //await blockchainExplorerHelper.WaitUntillBlockchainExplorerHasIndexed
                //    (blockchainExplorerHelper.HasTransactionIndexed, new string[] { txSendingResult.GetHash().ToString() });
                //await blockchainExplorerHelper.WaitUntillBlockchainExplorerHasIndexed
                //    (blockchainExplorerHelper.HasBalanceIndexedZeroConfirmation, new string[] { txSendingResult.GetHash().ToString() },
                //    clientPrivateKey.PubKey.WitHash.ScriptPubKey.GetScriptAddress(settings.Network).ToString());


                // bool v = await VerifyTransaction(txSendingResult);
                var punishmentToLog = commitmentSpendingResp.TransactionHex;

                using (StreamWriter writer = new StreamWriter("log.txt"))
                {
                    StringBuilder builder = new StringBuilder();
                    builder.AppendLine("HubUnsignedCommitment:");
                    builder.AppendLine(commitmentToLog);

                    builder.AppendLine("HubSignedCommitment");
                    builder.AppendLine(hubSignedCommitment);

                    builder.AppendLine("Punishment:");
                    builder.AppendLine(punishmentToLog);

                    await writer.WriteAsync(builder.ToString());
                }

                return(true);
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }
예제 #31
0
 public LoadingData(AssetDefinition assetDefinition, ContentManager contentLoader)
 {
     m_assetDefinition = assetDefinition;
     m_contentLoader   = contentLoader;
 }