Inheritance: MonoBehaviour
示例#1
0
 void SerializeStuff()
 {
     for (int i = 0; i < toSerialize.Length; i++)
     {
         Debug.Log("Found Serializable");
         if (!toSerialize[i].GetComponent <CustomScript>())
         {
             toSerialize[i].AddComponent <CustomScript>();
         }
         toSerialize[i].GetComponent <CustomScript>().GetComponents();
         jsonString = "";
         CustomScript cs = toSerialize[i].GetComponent <CustomScript>();
         Serializable so = Serialize(cs.gameObject);
         so.name = cs.gameObject.name;
         for (int j = 0; j < toSerialize[i].transform.childCount; j++)
         {
             GameObject child = toSerialize[i].transform.GetChild(j).gameObject;
             if (!child.GetComponent <CustomScript>())
             {
                 child.AddComponent <CustomScript>();
             }
             child.GetComponent <CustomScript>().GetComponents();
             Serializable sObject = Serialize(toSerialize[i].transform.GetChild(j).gameObject);
             sObject.name = child.name;
             SerializableTransform st = (SerializableTransform)so.components[0];
             st.children.Add(sObject);
         }
         Debug.Log("Added Object");
         sObjects.Add(so);
     }
 }
        public void ScriptingTest1()
        {
            CustomScript custom = new CustomScript();

            custom.AddInstructions(OPCODE.OP_1, OPCODE.OP_2, OPCODE.ADD, OPCODE.OP_3, OPCODE.EQ_NUM);
            Interpreter.Initialize();

            Assert.AreEqual(EXECUTION_RESULT.SUCCESS, custom.Run());
        }
示例#3
0
 //12/4/2014 NS added for VSPLUS-1229
 public bool UpdateScriptDetails(CustomScript CScript)
 {
     try
     {
         return(VSWebDAL.ConfiguratorDAL.AlertsDAL.Ins.UpdateScriptDetails(CScript));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#4
0
 //12/4/2014 NS added for VSPLUS-1229
 public CustomScript GetScriptByKey(CustomScript CScript)
 {
     try
     {
         return(VSWebDAL.ConfiguratorDAL.AlertsDAL.Ins.GetCustomScriptsByKey(CScript));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#5
0
        public void TestNULLDATA()
        {
            CustomScript script = new CustomScript();

            script.AddInstructions(OPCODE.OP_3, OPCODE.OP_4, OPCODE.ADD);
            script.AddData((short)7);
            script.AddInstructions(OPCODE.EQ_VERIFY_NUM);
            script.AddData(System.Text.Encoding.UTF8.GetBytes("Hello, world!"));

            //Execute script and get data
            script.RunAndGetStack(out byte[] stack);
            Assert.AreEqual("Hello, world!", System.Text.Encoding.UTF8.GetString(stack));
        }
示例#6
0
 private void Awake()
 {
     // The Singleton pattern.
     if (instance != null && instance != this)
     {
         // Enforce that there is only one GameManager.
         Destroy(gameObject);
     }
     else
     {
         instance = this;
         DontDestroyOnLoad(this.gameObject);
     }
 }
示例#7
0
 public void fillData(int Key)
 {
     try
     {
         CustomScript CScript = new CustomScript();
         CScript.ID = Key;
         CustomScript Returnobj = VSWebBL.ConfiguratorBL.AlertsBL.Ins.GetScriptByKey(CScript);
         ScriptNameTextBox.Text          = Returnobj.ScriptName;
         ScriptCommandTextBox.Text       = Returnobj.ScriptCommand;
         UploadLocationLabel.Text        = Returnobj.ScriptLocation;
         UploadLocationLabel.Visible     = true;
         UploadLocationDispLabel.Visible = true;
     }
     catch (Exception ex)
     {
         //6/27/2014 NS added for VSPLUS-634
         Log.Entry.Ins.WriteHistoryEntry(DateTime.Now.ToString() + " Exception - " + ex);
     }
 }
示例#8
0
        public void InsertScriptData()
        {
            bool         res     = false;
            CustomScript CScript = new CustomScript();

            if (Request.QueryString["ID"] != "" && Request.QueryString["ID"] != null)
            {
                CScript.ID = int.Parse(Request.QueryString["ID"]);
                flag       = "Update";
            }
            CScript.ScriptName     = ScriptNameTextBox.Text;
            CScript.ScriptCommand  = ScriptCommandTextBox.Text;
            CScript.ScriptLocation = UploadLocationLabel.Text;
            if (flag == "Insert")
            {
                res = VSWebBL.ConfiguratorBL.AlertsBL.Ins.InsertScriptDetails(CScript);
            }
            else
            {
                res = VSWebBL.ConfiguratorBL.AlertsBL.Ins.UpdateScriptDetails(CScript);
            }
        }
        /// <summary>
        /// Creates object responsible for processing package of specified type.
        /// </summary>
        /// <param name="packageType">Type of the package to processed.</param>
        /// <param name="xmlPackage">The XML package to process.</param>
        /// <returns>Created package processing object.</returns>
        public IExecutingScript CreateScript(string packageType, XDocument xmlPackage)
        {
            if (packageType == null)
            {
                throw new ArgumentNullException("packageType");
            }

            CommunicationPackageType packageTypeVal;

            try
            {
                packageTypeVal = (CommunicationPackageType)Enum.Parse(typeof(CommunicationPackageType), packageType);
            }
            catch (ArgumentException)
            {
                packageTypeVal = CommunicationPackageType.Unknown;
            }
            IExecutingScript script = null;

            switch (packageTypeVal)
            {
            case CommunicationPackageType.ComplaintDocumentSnapshot:
                script = new ComplaintDocumentSnapshot(this.UnitOfWork, this.ExecutionController);
                break;

            case CommunicationPackageType.Configuration:
                script = new ConfigurationScript(this.UnitOfWork, this.ExecutionController);
                break;

            case CommunicationPackageType.ContractorSnapshot:
                script = new ContractorScript(this.UnitOfWork, this.ExecutionController);
                break;

            case CommunicationPackageType.ContractorRelations:
                script = new ContractorRelationsScript(this.UnitOfWork, this.ExecutionController);
                break;

            case CommunicationPackageType.ContractorGroupMembership:
                script = new ContractorGroupMembershipScript(this.UnitOfWork, this.ExecutionController);
                break;

            case CommunicationPackageType.DictionaryPackage:
                script = new DictionarySnapshotScript(this.UnitOfWork, this.ExecutionController);
                break;

            case CommunicationPackageType.FileDescriptor:
                script = new FileDescriptorScript(this.UnitOfWork, this.ExecutionController);
                break;

            case CommunicationPackageType.FinancialReport:
                script = new FinancialReportScript(this.UnitOfWork, this.ExecutionController);
                break;

            case CommunicationPackageType.FinancialDocumentSnapshot:
                script = new FinancialDocumentScript(this.UnitOfWork, this.ExecutionController);
                break;

            case CommunicationPackageType.InventoryDocumentSnapshot:
                script = new InventoryDocumentScript(this.UnitOfWork, this.ExecutionController);
                break;

            case CommunicationPackageType.ItemSnapshot:
                script = new ItemSnapshotScript(this.UnitOfWork, this.ExecutionController);
                break;

            case CommunicationPackageType.ItemRelation:
                script = new ItemRelationScript(this.UnitOfWork, this.ExecutionController);
                break;

            case CommunicationPackageType.ItemUnitRelation:
                script = new ItemUnitRelationScript(this.UnitOfWork, this.ExecutionController);
                break;

            case CommunicationPackageType.ItemGroupMembership:
                script = new ItemGroupMembershipScript(this.UnitOfWork, this.ExecutionController);
                break;

            case CommunicationPackageType.CommercialDocumentSnapshot:
                script = new CommercialDocumentScript(this.UnitOfWork, this.ExecutionController);
                break;

            case CommunicationPackageType.CommercialDocumentSnapshotEx:
                script = new CommercialDocumentExScript(this.UnitOfWork, this.ExecutionController, this.IsHeadquarter);
                break;

            case CommunicationPackageType.Series:
                script = new SeriesScript(this.UnitOfWork, this.ExecutionController);
                break;

            case CommunicationPackageType.CommercialWarehouseValuation:
                script = new CommercialWarehouseValuation(this.UnitOfWork, this.ExecutionController);
                break;

            case CommunicationPackageType.CommercialWarehouseRelation:
                script = new CommercialWarehouseRelation(UnitOfWork, this.ExecutionController);
                break;

            case CommunicationPackageType.DocumentRelation:
                script = new DocumentRelationScript(this.UnitOfWork, this.ExecutionController);
                break;

            case CommunicationPackageType.IncomeOutcomeRelation:
                script = new IncomeOutcomeRelation(this.UnitOfWork, this.ExecutionController);
                break;

            case CommunicationPackageType.Payment:
                script = new PaymentScript(this.UnitOfWork, this.ExecutionController);
                break;

            case CommunicationPackageType.WarehouseDocumentValuation:
                script = new WarehouseDocumentValuation(this.UnitOfWork, this.ExecutionController, this.IsHeadquarter);
                break;

            //TODO !! aktualnie WZk dotykajaca mmki bedzie traktowana jak by nie miala nic wspolnego z mmka
            //     czyli nie zostanie przeslana do oddzialu docelowego
            case CommunicationPackageType.WarehouseDocumentSnapshot:
                if (xmlPackage.Root.Element("warehouseDocumentLine").Elements("entry").All(row => row.Element("isDistributed").Value.Equals("1")))
                {
                    DocumentType docType = DictionaryMapper.Instance.GetDocumentType(new Guid(xmlPackage.Root.Element("warehouseDocumentHeader")
                                                                                              .Element("entry").Element("documentTypeId").Value));
                    if (docType.DocumentCategory != Makolab.Fractus.Kernel.Enums.DocumentCategory.IncomeWarehouseCorrection && docType.DocumentCategory != Makolab.Fractus.Kernel.Enums.DocumentCategory.OutcomeWarehouseCorrection)
                    {
                        script = new ShiftDocumentSnapshot(this.UnitOfWork, this.ExecutionController, this.IsHeadquarter);
                    }
                    else
                    {
                        script = new WarehouseDocumentSnapshot(this.UnitOfWork, this.ExecutionController, this.IsHeadquarter);
                    }
                }
                else
                {
                    script = new WarehouseDocumentSnapshot(this.UnitOfWork, this.ExecutionController, this.IsHeadquarter);
                }
                break;

            case CommunicationPackageType.WarehouseStock:
                script = new WarehouseStockScript(this.UnitOfWork, this.ExecutionController);
                break;

            case CommunicationPackageType.UnrelateCommercialDocument:
                script = new UnrelateCommercialDocumentScript(this.UnitOfWork, this.ExecutionController);
                break;

            case CommunicationPackageType.UnrelateWarehouseDocumentForOutcome:
                script = new UnrelateWarehouseDocumentForOutcomeScript(this.UnitOfWork, this.ExecutionController);
                break;

            case CommunicationPackageType.UnrelateWarehouseDocumentForIncome:
                script = new UnrelateWarehouseDocumentForIncomeScript(this.UnitOfWork, this.ExecutionController);
                break;

            case CommunicationPackageType.ShiftDocumentStatus:
                script = new ShiftDocumentStatusScript(this.UnitOfWork, this.ExecutionController);
                break;

            case CommunicationPackageType.PriceRule:
                script = new PriceRuleScript(this.UnitOfWork, this.ExecutionController);
                break;

            case CommunicationPackageType.PriceRuleList:
                script = new PriceRuleListScript(this.UnitOfWork, this.ExecutionController);
                break;

            case CommunicationPackageType.Custom:
                script = new CustomScript(this.UnitOfWork, this.ExecutionController);
                break;

            case CommunicationPackageType.Unknown:
            case CommunicationPackageType.Other:
            default:
                script = new NullScript();
                break;
            }
            script.LocalTransactionId = this.LocalTransactionId;
            return(script);
        }
示例#10
0
 private void OnEnable()
 {
     yourscript = (CustomScript)target;
     showFloats = false;
 }
示例#11
0
    Serializable Serialize(GameObject sObject)
    {
        Serializable output = new Serializable();
        CustomScript cs     = sObject.GetComponent <CustomScript>();

        for (int j = 0; j < cs.componentList.Length; j++)
        {
            /*Adds the Transform object for serialization*/
            if (cs.componentList[j].GetType().Name.Contains("Transform"))
            {
                Debug.Log("Added Transform");
                SerializableTransform sTransform = new SerializableTransform();
                sTransform.name     = "Transform";
                sTransform.position = cs.gameObject.transform.position;
                sTransform.rotation = cs.gameObject.transform.eulerAngles;
                sTransform.scale    = cs.gameObject.transform.localScale;
                output.components.Add(sTransform);
            }
            else if (cs.componentList[j].GetType().Name.Contains("Renderable"))
            {
                SerializableMesh sRenderable = new SerializableMesh();
                sRenderable.name = "Renderable";
                Renderable r = cs.gameObject.GetComponent <Renderable>();
                if (sRenderable != null)
                {
                    sRenderable.mesh      = r.data.mesh;
                    sRenderable.material  = r.data.material;
                    sRenderable.albedo    = r.data.albedo;
                    sRenderable.metal     = r.data.metal;
                    sRenderable.roughness = r.data.roughness;
                    sRenderable.normal    = r.data.normal;
                    sRenderable.height    = r.data.height;
                    sRenderable.ao        = r.data.ao;
                    sRenderable.emissive  = r.data.emissive;
                }
                output.components.Add(sRenderable);
            }
            else if (cs.componentList[j].GetType().Name.Contains("MeshFilter"))                /*Adds the MeshFilter object for serialization*/
            {
                Debug.Log("MeshRenderer Serialization is deprecated. It will probably be removed in a future update");
                //Debug.Log("Added MeshFilter");
                //SerializableMesh sMesh = new SerializableMesh();
                //sMesh.name = "MeshFilter";
                //MeshFilter mf = cs.gameObject.GetComponent<MeshFilter>();
                //MeshRenderer mr = cs.gameObject.GetComponent < MeshRenderer>();
                //sMesh.mesh = mf.sharedMesh.name;
                //sMesh.material = mr.sharedMaterial.name;
                //sMesh.castShadows = mr.shadowCastingMode == UnityEngine.Rendering.ShadowCastingMode.On;
                //output.components.Add(sMesh);
            }
            else if (cs.componentList[j].GetType().Name.Contains("MeshRenderer"))                /*Adds the MeshRenderer object for serialization*/
            {
                Debug.Log("MeshRenderer Serialization is deprecated. It will probably be removed in a future update");
                //    Debug.Log("Added MeshRenderer");
                //    SerializableMeshRenderer sMeshRenderer = new SerializableMeshRenderer();
                //    sMeshRenderer.name = "MeshRenderer";
                //    MeshRenderer mr = cs.gameObject.GetComponent<MeshRenderer>();
                //    sMeshRenderer.material = mr.sharedMaterial.name;
                //    sMeshRenderer.castShadows = mr.shadowCastingMode == UnityEngine.Rendering.ShadowCastingMode.On;

                //    output.components.Add(sMeshRenderer);
            }
            else if (cs.componentList[j].GetType().Name.Contains("Rigidbody"))                /*Adds the Rigidbody object for serialization */
            {
                Debug.Log("Added Rigidbody");
                SerializableRigidbody sRigidbody = new SerializableRigidbody();
                sRigidbody.name = "Rigidbody";
                Rigidbody rb = cs.gameObject.GetComponent <Rigidbody>();
                sRigidbody.mass        = rb.mass;
                sRigidbody.drag        = rb.drag;
                sRigidbody.angularDrag = rb.angularDrag;
                sRigidbody.useGravity  = rb.useGravity;
                sRigidbody.isKinematic = rb.isKinematic;
                sRigidbody.freezeXPos  = rb.constraints == RigidbodyConstraints.FreezePositionX;
                sRigidbody.freezeYPos  = rb.constraints == RigidbodyConstraints.FreezePositionY;
                sRigidbody.freezeZPos  = rb.constraints == RigidbodyConstraints.FreezePositionZ;
                sRigidbody.freezeXRot  = rb.constraints == RigidbodyConstraints.FreezeRotationX;
                sRigidbody.freezeYRot  = rb.constraints == RigidbodyConstraints.FreezeRotationY;
                sRigidbody.freezeZRot  = rb.constraints == RigidbodyConstraints.FreezeRotationZ;

                output.components.Add(sRigidbody);
            }
            else if (cs.componentList[j].GetType().Name.Contains("Collider"))                /*Adds the Collider object for serialization*/
            {
                Debug.Log("Added Collider");

                if (cs.gameObject.GetComponent <BoxCollider>())
                {
                    SerializableBoxCollider sBCollider = new SerializableBoxCollider();
                    sBCollider.name = "BoxCollider";
                    BoxCollider bc = cs.gameObject.GetComponent <BoxCollider>();
                    sBCollider.isTrigger = bc.isTrigger;
                    sBCollider.center    = bc.center;
                    sBCollider.size      = bc.size;
                    output.components.Add(sBCollider);
                }
                else if (cs.gameObject.GetComponent <SphereCollider>())
                {
                    SerializableSphereCollider sSCollider = new SerializableSphereCollider();
                    sSCollider.name = "SphereCollider";
                    SphereCollider sc = cs.gameObject.GetComponent <SphereCollider>();
                    sSCollider.isTrigger = sc.isTrigger;
                    sSCollider.center    = sc.center;
                    sSCollider.radius    = sc.radius;
                    output.components.Add(sSCollider);
                }
            }
            else
            {
                SerializableComponent Script = new SerializableComponent();
                string fName = cs.componentList[j].GetType().ToString();
                if (cs.componentList[j].GetType().ToString().Contains("UnityEngine."))
                {
                    Debug.Log(fName.Length);
                    Script.name = fName.Substring(12);
                }
                else
                {
                    Script.name = fName;
                }
                output.components.Add(Script);
            }
        }
        return(output);
    }