Exemplo n.º 1
0
    protected virtual void Awake()
    {
        Debug.Log("Building awake");

        id = BuildID++;

        Init();

        Resource = ResourceManager.GetResoucreObject(resource_id);

        Inventory = new ResourceInvenotory(MaxInventorySlots, MaxInventorySize);

        Transform icon = transform.FindChild("Icon");
        if (icon) {
            icon.gameObject.GetComponent<SpriteRenderer>().sprite = Resource.Image;
        }

        AwailableWorks.Add(1);

        for (int i = 0; i < MaxLaborers; i++) {
            Laborers.Add(i);
        }

        for (int i = 0; i < SlotCount; i++) {
            ActiveWorks.Add(null);
        }

        for (int i = 0; i < ShopCount; i++) {
            ShopList.Add(new ResourceData());
        }

        _shopTime = ShopTime;
    }
      public ResourceExampleController(Scope _scope, Resource _resource)
      {
         // save injectables
         resource = _resource;
         
         var parms = new { userId="@id" };
        
         ResourceActionDefinition actions = new ResourceActionDefinition();
         actions.Add("fetch","GET",false);
        
         myres = resource.Create("/api/person/:userId",null,actions);

         all_is_ok = "OK!";            
      }
Exemplo n.º 3
0
 public void InheritanceContextTest()
 {
     // When MarkupObjects try to find their inheritance context,
     // it breaks data binding.
     var viewModel = new ResourceObject
     {
         Properties =
             {
                 new Property { PropertyName = "String1", Value = "Test" },
                 new Property { PropertyName = "String2", Value = null },
                 new Property { PropertyName = "String3", Value = null },
             }
     }.Value as IDynamicObject;
     Assert.Equal("Test", viewModel["String1"]);
     Assert.Equal(null, viewModel["String2"]);
     Assert.Equal(null, viewModel["String3"]);
     var resource = new ResourceObject
     {
         Properties =
             {
                 new Property { PropertyName = "Collection" },
                 new Property { PropertyName = "Item1" },
             }
     };
     var window = new Window { DataContext = viewModel };
     window.Resources.Add(resource, "sampleData");
     TestHelper.AttachAndExecute(window,
         TestHelper.Configure(new Set { PropertyName = "String2" },
             TestHelper.TargetBinder,
             value => BindingOperations.SetBinding(value, Set.ValueProperty, new Binding("String1"))),
         TestHelper.Configure(new Set { PropertyName = "String3" },
             TestHelper.TargetBinder,
             value => BindingOperations.SetBinding(value, Set.ValueProperty, new Binding("String2"))));
     Assert.Equal("Test", viewModel["String1"]);
     Assert.Equal("Test", viewModel["String2"]);
     Assert.Equal("Test", viewModel["String3"]);
 }
Exemplo n.º 4
0
 public void NotifyPropertyChangedTest()
 {
     // Copy String1 to String2 and then copy String2 to String3.  If property
     // change notification isn't working, the binding for String2 will still
     // have its default value.
     var viewModel = new ResourceObject
     {
         Properties =
             {
                 new Property { PropertyName = "String1", Value = "Test" },
                 new Property { PropertyName = "String2", Value = null },
                 new Property { PropertyName = "String3", Value = null },
             }
     }.Value as IDynamicObject;
     Assert.Equal("Test", viewModel["String1"]);
     Assert.Equal(null, viewModel["String2"]);
     Assert.Equal(null, viewModel["String3"]);
     TestHelper.AttachAndExecute(new Window { DataContext = viewModel },
         TestHelper.Configure(new Set { PropertyName = "String2" },
             TestHelper.TargetBinder,
             value => BindingOperations.SetBinding(value, Set.ValueProperty, new Binding("String1"))),
         TestHelper.Configure(new Set { PropertyName = "String3" },
             TestHelper.TargetBinder,
             value => BindingOperations.SetBinding(value, Set.ValueProperty, new Binding("String2"))));
     Assert.Equal("Test", viewModel["String1"]);
     Assert.Equal("Test", viewModel["String2"]);
     Assert.Equal("Test", viewModel["String3"]);
 }
Exemplo n.º 5
0
 public void StandAloneTest()
 {
     // Use Set to copy String1 to String2 using the DataContext of a Window.
     // Note: This test does not use any external methods.
     var viewModel = new ResourceObject
     {
         Properties =
         {
             new Property { PropertyName = "String1", Value = "Test" },
             new Property { PropertyName = "String2", Value = null },
         }
     }.Value as IDynamicObject;
     var window = new Window { DataContext = viewModel };
     Assert.Equal("Test", viewModel["String1"]);
     Assert.Equal(null, viewModel["String2"]);
     var statement = new Set { PropertyName = "String2" };
     BindingOperations.SetBinding(statement, Set.ContextProperty, new Binding());
     BindingOperations.SetBinding(statement, Set.ValueProperty, new Binding("String1"));
     Attached.GetOperations(window).Add(new AttachedHandler { Actions = { statement } });
     Assert.Equal("Test", viewModel["String1"]);
     Assert.Equal("Test", viewModel["String2"]);
 }
Exemplo n.º 6
0
	public static void Create() {

		Sprite[] sprites = Resources.LoadAll<Sprite>("Icons");

		foreach (Sprite sp in sprites) {
			ResourceSprites.Add(sp.name, sp);
			//Debug.Log(sp.name);
		}

		ErrorSprite = GetResourceSprite("signs_stop");
		BlankSprite = GetResourceSprite("misc folder2");

		ResourceObject obj;

#region ITEMS
		obj = new ResourceObject(1);
			obj.Name = "Wheat";
			obj.Desciption = "Wheat";
			obj.BasePrice = 1;
			obj.Time = 5;
			obj.Amount = 3;
			obj.SpriteName = "food_corn";
		ResourcesList.Add(obj.ID, obj);

		obj = new ResourceObject(2);
			obj.Name = "Wheat flour";
			obj.Desciption = "Wheat flour";
			obj.BasePrice = 1;
			obj.Time = 5;
			obj.Amount = 3;
			obj.SpriteName = "flour_wheat";
			obj.Request.Add(1,5);
		ResourcesList.Add(obj.ID, obj);

		obj = new ResourceObject(3);
			obj.Name = "Wheat bread";
			obj.Desciption = "Wheat bread";
			obj.BasePrice = 1;
			obj.Time = 5;
			obj.Amount = 1;
			obj.SpriteName = "bread_5";
			obj.Request.Add(2, 5);
		ResourcesList.Add(obj.ID, obj);
#endregion

#region BUILDINGS
		obj = new ResourceObject(1000);
			obj.Type = ResourceTypes.BUILDING;
			obj.Name = "Farm";
			obj.Desciption = "Farm";
			obj.BasePrice = 1;
			obj.SpriteName = "BuildingIcons_74";
			obj.Available.Add(1, 0);
		ResourcesList.Add(obj.ID, obj);

		obj = new ResourceObject(1001);
			obj.Type = ResourceTypes.BUILDING;
			obj.Name = "Garage";
			obj.Desciption = "Garage";
			obj.BasePrice = 1;
			obj.SpriteName = "BuildingIcons_76";
		ResourcesList.Add(obj.ID, obj);

		obj = new ResourceObject(1002);
			obj.Type = ResourceTypes.BUILDING;
			obj.Name = "Mill";
			obj.Desciption = "Mill";
			obj.BasePrice = 1;
			obj.SpriteName = "mill";
			obj.Available.Add(2,0);
		ResourcesList.Add(obj.ID, obj);

		obj = new ResourceObject(1003);
			obj.Type = ResourceTypes.BUILDING;
			obj.Name = "Bakery";
			obj.Desciption = "Bakery";
			obj.BasePrice = 1;
			obj.SpriteName = "bakery";
			obj.Available.Add(3, 0);
		ResourcesList.Add(obj.ID, obj);
#endregion

#region CARS
		obj = new ResourceObject(2001);
			obj.Type = ResourceTypes.CAR;
			obj.Name = "Car";
			obj.Desciption = "Car";
			obj.BasePrice = 1;
			obj.SpriteName = "TruckOris_0";
		ResourcesList.Add(obj.ID, obj);
#endregion

#region OTHER
		obj = new ResourceObject(5001);
		obj.Type = ResourceTypes.OTHER;
		obj.Name = "Build road";
		obj.Desciption = "Click on map for bulding road";
		obj.BasePrice = 1;
		obj.SpriteName = "RoadIcon";
		ResourcesList.Add(obj.ID, obj);
#endregion

		Debug.Log("Resources created!");
	}
Exemplo n.º 7
0
	public ResourceWorker(int item_id) {
		Resource = ResourceManager.GetResoucreObject(item_id);
		if (Resource == null) return;
	}
Exemplo n.º 8
0
        private ResourceObject[] FindResourceObjectByName(ResourceObject[] ros, string Name)
        {
            var lros = from l in ros
                       where l.resourceObjectName.Equals(Name, StringComparison.CurrentCultureIgnoreCase)
                       select l;

            if (lros.Count() > 0)
            {
                return new List<ResourceObject>(lros).ToArray();
            }
            else
                return null;

        }
Exemplo n.º 9
0
            static public ResourceObject[] MapResources(string Path)
            {

                List<ResourceObject> listRO = new List<ResourceObject>();
                string[] files = System.IO.Directory.GetFiles(Path, "*.*", SearchOption.AllDirectories);
                foreach (var file in files)
                {
                    if (!file.Contains(".svn"))
                    {

                        ResourceObject ro = new ResourceObject();
                        ro.resourceObjectFileType = ExtensionToFileType(file);
                        ro.resourceObjectPath = file.Substring(Path.Length+1);
                        ro.resourceObjectSize = new System.IO.FileInfo(file).Length;
                        ro.resourceObjectName = System.IO.Path.GetFileNameWithoutExtension(file);
                        if (ro.resourceObjectFileType.Equals(ResourceObject.ResourceObjectFileTypes.AudioWAV) || ro.resourceObjectFileType.Equals(ResourceObject.ResourceObjectFileTypes.AudioOGG) || ro.resourceObjectFileType.Equals(ResourceObject.ResourceObjectFileTypes.AudioMP3))
                        {
                            AnalyzeAudioFile(file, ro);
                        }

                        if (ro.resourceObjectFileType.Equals(ResourceObject.ResourceObjectFileTypes.ImagePNG))
                            ro.ImageUsesAlphaChannel = UsesAlphaChannel(file);

                        if (ro.resourceObjectFileType.Equals(ResourceObject.ResourceObjectFileTypes.ImagePNG) || ro.resourceObjectFileType.Equals(ResourceObject.ResourceObjectFileTypes.ImageJPG))
                        {
                            Bitmap bmpTmp = new Bitmap(file);
                            ro.ImageSize = string.Format("{0}x{1}", bmpTmp.Width, bmpTmp.Height);
                        }
                        listRO.Add(ro);
                    }

                }

                return listRO.ToArray();

            }
Exemplo n.º 10
0
            private static void AnalyzeAudioFile(string FilePath, ResourceObject ro)
            {
                try
                {
                    System.Diagnostics.Process p = new System.Diagnostics.Process();
                    p.StartInfo.FileName = ffmpegPath;
                    p.StartInfo.Arguments = "-i \"" + FilePath + "\"";
                    p.StartInfo.UseShellExecute = false;
                    p.StartInfo.RedirectStandardError = true;
                    p.StartInfo.CreateNoWindow = true;
                    p.Start();
                    while (!p.StandardError.EndOfStream)
                    {
                        string sLine = p.StandardError.ReadLine().Trim();
                        if (sLine.StartsWith("Duration: "))
                        {
                            ro.AudioLength = sLine.Substring("Duration: ".Length, "00:00:00.00".Length);
                        }
                        if (sLine.StartsWith("Stream #0.0:"))
                        {
                            string[] sParams = sLine.Substring("Stream #0.0: Audio: ".Length).Split(',');
                            ro.AudioBit = sParams[3].Trim();
                            ro.AudioChannels = sParams[2].Trim();
                            ro.AudioSampleRate = sParams[1].Trim();
                            ro.AudioBitRate = sParams[4].Trim();
                            ro.AudioType = sParams[0].Trim();
                        }

                    }

                    p.WaitForExit();
                }
                catch (System.Exception ex)
                {

                }

            }
        protected override void ProcessRecord()
        {
            ResourceObject r = this.ApprovalObject.InternalObject;

            RmcWrapper.Client.Approve(r, this.Decision == ApprovalDecision.Approve, this.Reason);
        }