• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Component类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Component的典型用法代码示例。如果您正苦于以下问题:C# Component类的具体用法?C# Component怎么用?C# Component使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Component类属于命名空间,在下文中一共展示了Component类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: AddHealth

 public static void AddHealth(Component entity, int health)
 {
     HealthHandler handler = entity.GetComponent<HealthHandler>();
     if (handler) {
         handler.AddHealth(health);
     }
 }
开发者ID:JimWest,项目名称:UnityTestProject,代码行数:7,代码来源:HealthUtility.cs


示例2: Main

    static void Main(string[] args)
    {
        Component motherBoard1 = new Component("AsusP8H67/H67/1155", "Game Station", (decimal)155.00);
        Component graphicCard1 = new Component("ATI Radeon HD7850", (decimal)229.00);
        Component ram1 = new Component("2x4GB DDR3 1600Mhz", (decimal)129.00);
        Computer pc1 = new Computer("Asus Game Machine", new List<Component> { motherBoard1, graphicCard1, ram1 });
        Console.WriteLine(pc1);
        Console.WriteLine();
        Console.WriteLine("----------------------------------------------------------------");
        Component motherBoard2 = new Component("ASUS P8H61-M LX2/SI/LGA1155", "Home Station", (decimal)98.00);
        Component graphicCard2 = new Component("ATI Radeon HD 7750", (decimal)138.00);
        Component ram2 = new Component("4 GB DDR3 1333 MHz", (decimal)65.00);
        Computer pc2 = new Computer("Home Machine", new List<Component> { motherBoard2, graphicCard2, ram2 });
        Console.WriteLine(pc2);
        Console.WriteLine();
        Console.WriteLine("----------------------------------------------------------------");
        Component motherBoard3 = new Component("ASROCK Z87 PRO4 BULK", "Game Station", (decimal)217.00);
        Component graphicCard3 = new Component("SAPPHIRE R9 270 2G GDDR5 OC", (decimal)358.00);
        Component ram3 = new Component("2x4GB DDR3 1600 MHz", (decimal)148.00);
        Computer pc3 = new Computer("Game Machine New", new List<Component> { motherBoard3, graphicCard3, ram3 });
        Console.WriteLine(pc3);
        Console.WriteLine();
        Console.WriteLine("----------------------------------------------------------------");
        Console.WriteLine("----------------------------------------------------------------");
        List<Computer> computers = new List<Computer>() { pc1, pc2, pc3 };
        computers.OrderByDescending(computer => computer.Price).ToList().ForEach(computer => Console.WriteLine(computer.ToString()));

    }
开发者ID:fetko1977,项目名称:OOP-Homeworks,代码行数:28,代码来源:PCCatalog.cs


示例3:

		void ICmpInitializable.OnShutdown(Component.ShutdownContext context)
		{
			if(context == ShutdownContext.Deactivate)
			{
				DualityApp.Sound.StopAll();
			}
		}
开发者ID:ChrisLakeZA,项目名称:duality,代码行数:7,代码来源:MusicManager.cs


示例4: Deserialize

 public void Deserialize(byte[] data, Component instance)
 {
     UnitySerializer.AddFinalAction(delegate
     {
         Animation animation = (Animation)instance;
         animation.Stop();
         Dictionary<string, AnimationState> dictionary = animation.Cast<AnimationState>().ToDictionary((AnimationState a) => a.name);
         List<SerializeAnimations.StoredState> list = UnitySerializer.Deserialize<List<SerializeAnimations.StoredState>>(data);
         foreach (SerializeAnimations.StoredState current in list)
         {
             if (current.asset != null && !dictionary.ContainsKey(current.name))
             {
                 animation.AddClip(SaveGameManager.Instance.GetAsset(current.asset) as AnimationClip, current.name);
             }
             if (current.name.Contains(" - Queued Clone"))
             {
                 AnimationState instance2 = animation.PlayQueued(current.name.Replace(" - Queued Clone", string.Empty));
                 UnitySerializer.DeserializeInto(current.data, instance2);
             }
             else
             {
                 UnitySerializer.DeserializeInto(current.data, animation[current.name]);
             }
         }
     });
 }
开发者ID:GameDiffs,项目名称:TheForest,代码行数:26,代码来源:SerializeAnimations.cs


示例5: SaveComponent

        public int SaveComponent(IComponentDb componentDb, int? transactionNumber = null)
        {
            Component record;
            var recordOld = new Component();
            if (componentDb.ComponentId == 0)
            {
                record = new Component();
                Context.AddToComponents(record);
            }
            else
            {
                record = Context.Components.Where(r => r.ComponentId == componentDb.ComponentId).First();
                ReflectionHelper.CopyAllProperties(record, recordOld);
            }

            record.Name = componentDb.Name;
            record.IsReadOnlyAccess = componentDb.IsReadOnlyAccess;

            Context.SaveChanges();
            if (componentDb.ComponentId == 0)
            {
                componentDb.ComponentId = record.ComponentId;
                LogUnlinkedToDb(UserId, "Components", record.ComponentId, "I", XmlHelper.GetObjectXml(record), transactionNumber);
            }
            else
            {
                LogUnlinkedToDb(UserId, "Components", record.ComponentId, "U", XmlHelper.GetDifferenceXml(recordOld, record), transactionNumber);
            }

            return componentDb.ComponentId;
        }
开发者ID:urise,项目名称:JohanCorner,代码行数:31,代码来源:ComponentRepository.cs


示例6: AddListener

    public void AddListener(Component game_object, string notification_name)
    {
        if (listeners_dictionary.ContainsKey(notification_name))
            listeners_dictionary.Add(notification_name, new List<Component>());

        listeners_dictionary [notification_name].Add (game_object);
    }
开发者ID:elgarat,项目名称:sci-fi-mem-tool,代码行数:7,代码来源:NotificationManager.cs


示例7: OnManaChange

    void OnManaChange(Component Health, object newMana)
    {
        //If health has changed of this object
        if (this.GetInstanceID() != Health.GetInstanceID()) return;

        Debug.Log("Object: " + gameObject.name + "'s Mana is: " + newMana.ToString());
    }
开发者ID:cuongngo90,项目名称:Unity-Events,代码行数:7,代码来源:Health.cs


示例8: GetComponents

		private static List<ComponentListFactor> GetComponents(Component component, bool isMultiply = true)
		{
			if (component is DualFactorComponent)
			{
				var dfc = (DualFactorComponent)component;
				var leftComponent = Componentizer.ToComponent(dfc.LeftFactor);
				var rightComponent = Componentizer.ToComponent(dfc.RightFactor);

				var leftList = GetComponents(leftComponent, isMultiply);
				var rightList = GetComponents(rightComponent, isMultiply == dfc.IsMultiply);

				return leftList.Union(rightList).ToList();
			}

			if (component is IntegerFraction)
			{
				var frac = (IntegerFraction)component;
				return new List<ComponentListFactor>
				{
					new ComponentListFactor(new NumericFactor(new Integer(frac.Numerator))),
					new ComponentListFactor(new NumericFactor(new Integer(frac.Denominator)), false)
				};
			}

			return new List<ComponentListFactor> { new ComponentListFactor(Factorizer.ToFactor(component), isMultiply) };
		}
开发者ID:andrewsarnold,项目名称:Titanium,代码行数:26,代码来源:ComponentList.cs


示例9: Main

    public static void Main()
    {
        Console.Title = "Problem 3.	PC Catalog";

        Component monitor = new Component("monitor", 200);
        Component keyboard = new Component("keyboard", 43);
        Component mouse = new Component("mouse", 15);

        Component motherboard = new Component("motherboard", "G560 Intel Motherboard LA-5752P", 540);
        Component HDD = new Component("HDD", "256GB SSD", 188);
        Component proccesor = new Component("processor", " Intel Pentium G6950 (2.80 GHz, 3 MB)", 433);

        Computer firstPC = new Computer("Lenovo", motherboard, proccesor, HDD, monitor, mouse, keyboard);
        Computer secondPC = new Computer("HP", motherboard, proccesor, HDD, monitor);
        Computer thirdPC = new Computer("Acer", motherboard, proccesor, HDD);

        Computer[] pcArr = { firstPC, secondPC, thirdPC };
        pcArr = pcArr.OrderBy(pc => pc.Price()).ToArray();

        foreach (Computer pc in pcArr)
        {
            Console.WriteLine(pc.ToString());
        }

        Console.WriteLine("{0}\nMake your best choice!", new string('.', 25));
    }
开发者ID:Nezhdetov,项目名称:Software-University,代码行数:26,代码来源:CatalogMain.cs


示例10: Main

    static void Main()
    {
        var HDD = new Component("SSD Intel 530 Ser.", 149.04, "120GB SATA");
        var graphicsCard = new Component("Palit GTX750Ti KalmX", 321.00, "2GB");
        var motherboard = new Component("ASROCK 970 PERFORMANCE", 201.59);
        var processor = new Component("Intel i5-4460", 386.21, "3.2GHz 6MBs.1150");

        var myComponents = new List<Component>();
        myComponents.Add(processor);
        myComponents.Add(HDD);
        myComponents.Add(motherboard);
        myComponents.Add(graphicsCard);

        var hardDiscDrive = new Component("SSD KINGSTON", 190.51, "240GB V300 SATA3");
        var videoCard = new Component("Palit Nvidia", 197.10, " GT740 2GB DDR5");
        var CPU = new Component("AMD A8", 205.44, "X4 7650K BOX s.FM2+");
        var monitor = new Component("23\'\' Samsung", 321.00, " C23A750X Wireles");

        var yourComponents = new List<Component>() { hardDiscDrive, videoCard, CPU, monitor};

        var computer = new Computer("MyComputer", myComponents);
        var secondComputer = new Computer("YourComputer",yourComponents);

        var computers = new List<Computer>() { computer, secondComputer };

        computers.OrderBy(c => c.Price).ToList().ForEach(c => Console.WriteLine(c.ToString()));
    }
开发者ID:alvelchev,项目名称:SoftUni,代码行数:27,代码来源:Catalog.cs


示例11: GetContentByUrl

        /// <summary>
        /// Gets the raw string (xml) from the broker db by URL
        /// </summary>
        /// <param name="Url">URL of the page</param>
        /// <returns>String with page xml or empty string if no page was found</returns>
        public string GetContentByUrl(string Url)
        {
            Page page = new Page();
            page.Title = Randomizer.AnyString(15);
            page.Id = Randomizer.AnyUri(64);
            page.Filename = Randomizer.AnySafeString(8) + ".html";

            PageTemplate pt = new PageTemplate();
            pt.Title = Randomizer.AnyString(20);
            Field ptfieldView = new Field();
            ptfieldView.Name = "view";
            ptfieldView.Values.Add("Standard");
            pt.MetadataFields = new FieldSet();
            pt.MetadataFields.Add(ptfieldView.Name, ptfieldView);

            page.PageTemplate = pt;

            Schema schema = new Schema();
            schema.Title = Randomizer.AnyString(10);

            Component component = new Component();
            component.Title = Randomizer.AnyString(30);
            component.Id = Randomizer.AnyUri(16);
            component.Schema = schema;

            Field field1 = Randomizer.AnyTextField(6, 120, true);
            Field field2 = Randomizer.AnyTextField(8, 40, false);

            FieldSet fieldSet = new FieldSet();
            fieldSet.Add(field1.Name, field1);
            fieldSet.Add(field2.Name, field2);
            component.Fields = fieldSet;

            ComponentTemplate ct = new ComponentTemplate();
            ct.Title = Randomizer.AnyString(20);
            Field fieldView = new Field();
            fieldView.Name = "view";
            fieldView.Values.Add("DefaultComponentView");
            ct.MetadataFields = new FieldSet();
            ct.MetadataFields.Add(fieldView.Name, fieldView);

            ComponentPresentation cp = new ComponentPresentation();
            cp.Component = component;
            cp.ComponentTemplate = ct;

            page.ComponentPresentations = new List<ComponentPresentation>();
            page.ComponentPresentations.Add(cp);

            FieldSet metadataFields = new FieldSet();
            page.MetadataFields = metadataFields;

            var serializer = new XmlSerializer(typeof(Page));
            StringBuilder builder = new StringBuilder();
            StringWriter writer = new StringWriter(builder);
            //XmlTextWriter writer = new XmlTextWriter(page.Filename, Encoding.UTF8);
            //serializer.Serialize(writer, page);
            serializer.Serialize(writer, page);
            string pageAsString = builder.ToString();
            return pageAsString;
        }
开发者ID:flaithbheartaigh,项目名称:dynamic-delivery-4-tridion,代码行数:65,代码来源:TridionPageProvider.cs


示例12: Parser

    public MyJson.IJsonNode Parser(Component com, NeedList needlist)
    {

        UISlider t = com as UISlider;
        var json = new MyJson.JsonNode_Object();

        json["value"] = new MyJson.JsonNode_ValueNumber(t.value);
        json["alpha"] = new MyJson.JsonNode_ValueNumber(t.alpha);
        json["numberOfSteps"] = new MyJson.JsonNode_ValueNumber(t.numberOfSteps);
        if (t.foregroundWidget != null)
        {
            json["foregroundWidget"] = new MyJson.JsonNode_ValueNumber(GameObjParser.ObjToID(t.foregroundWidget.gameObject));
        }
        if (t.backgroundWidget != null)
        {
            json["backgroundWidget"] = new MyJson.JsonNode_ValueNumber(GameObjParser.ObjToID(t.backgroundWidget.gameObject));
        }
        if (t.thumb != null)
        {
            json["thumb"] = new MyJson.JsonNode_ValueNumber(GameObjParser.ObjToID(t.thumb.gameObject));
        }
        json["fillDirection"] = new MyJson.JsonNode_ValueString(t.fillDirection.ToString());

        return json;

    }
开发者ID:GraphicGame,项目名称:easydown,代码行数:26,代码来源:ParserUISlider.cs


示例13: FadeOutAnimation

 public FadeOutAnimation(Component i_BoundSprite)
     : base(i_BoundSprite)
 {
     m_TimeLeft = r_FadeEffectTimeSpan;
     m_AnimationTime = r_FadeEffectTimeSpan;
     m_BoundSprite.Opacity = 100;
 }
开发者ID:rockem,项目名称:spaceintruders,代码行数:7,代码来源:FadeOutAnimation.cs


示例14: Format

        public string Format(Component component)
        {
            Regex variable = new Regex("\\$[a-zA-z]+ ");
            string plainVars = variable.Replace(Value, new MatchEvaluator(delegate(Match match)
            {
                string propertyName = match.Value.Replace("$", "").Trim().ToLowerInvariant();
                ComponentProperty propertyInfo = component.FindProperty(propertyName);
                if (propertyInfo != null)
                    return component.GetProperty(propertyInfo).ToString();
                return "";
            }));

            variable = new Regex("\\$[a-zA-Z]+[\\(\\)a-z_0-9]+ ");
            string formattedVars = variable.Replace(plainVars, new MatchEvaluator(delegate(Match match)
            {
                Regex propertyNameRegex = new Regex("\\$[a-zA-z]+");
                string propertyName = propertyNameRegex.Match(match.Value).Value.Replace("$", "").Trim().ToLowerInvariant();
                ComponentProperty propertyInfo = component.FindProperty(propertyName);
                if (propertyInfo != null)
                {
                    return ApplySpecialFormatting(component.GetProperty(propertyInfo), match.Value.Replace(propertyNameRegex.Match(match.Value).Value, "").Trim());
                }
                return "";
            }));

            Regex regex = new Regex(@"\\[uU]([0-9A-F]{4})");
            return regex.Replace(formattedVars, match => ((char)Int32.Parse(match.Value.Substring(2), NumberStyles.HexNumber)).ToString());
        }
开发者ID:csuffyy,项目名称:circuitdiagram,代码行数:28,代码来源:ComponentPropertyFormat.cs


示例15: switch

        void ICmpInitializable.OnInit(Component.InitContext context)
        {
            if (context == InitContext.Activate && DualityApp.ExecContext != DualityApp.ExecutionContext.Editor)
            {
                AnimSpriteRenderer r = this.GameObj.Renderer as AnimSpriteRenderer;
                SoundEmitter s = this.GameObj.GetComponent<SoundEmitter>();
                Transform t = this.GameObj.Transform;

                r.AnimDuration = MathF.RoundToInt(0.4f * r.AnimDuration * MathF.Rnd.NextFloat(0.8f, 1.25f) * MathF.Sqrt(intensity));
                t.RelativeScale *= MathF.Sqrt(intensity);
                t.RelativeAngle = MathF.Rnd.NextFloat(MathF.RadAngle360);
                t.RelativeVel = new Vector3(MathF.Rnd.NextVector2(1.0f));

                ContentRef<Sound> soundRes = ContentRef<Sound>.Null;
                switch (MathF.Rnd.Next(5))
                {
                    case 0:	soundRes = GameRes.Data.Sound.Explo1_Sound; break;
                    case 1:	soundRes = GameRes.Data.Sound.Explo2_Sound; break;
                    case 2:	soundRes = GameRes.Data.Sound.Explo3_Sound; break;
                    case 3:	soundRes = GameRes.Data.Sound.Explo4_Sound; break;
                    case 4:	soundRes = GameRes.Data.Sound.Explo5_Sound; break;
                }
                SoundEmitter.Source source = new SoundEmitter.Source(soundRes, false);
                source.Volume = MathF.Rnd.NextFloat(0.9f, 1.15f) * MathF.Sqrt(intensity);
                source.Pitch = MathF.Rnd.NextFloat(0.8f, 1.25f) / MathF.Sqrt(intensity);
                source.Paused = false;
                s.Sources.Add(source);
            }
        }
开发者ID:Andrea,项目名称:dualityTechDemos,代码行数:29,代码来源:ExploEffect.cs


示例16: Observation

 public Observation(Component.IIdentity entity, Component.IIdentity observable, DateTimeOffset date, Component.IMeasurement measurement)
 {
     Entity = entity;
     Observable = observable;
     Date = date;
     Measurement = measurement;
 }
开发者ID:Zananok,项目名称:Harmonize,代码行数:7,代码来源:Observation.cs


示例17: DriveModes

 public DriveModes(BadgerControlSubsystem badgerControlSubsystem, Component parentComponent, RemoteDriverService remoteDriveService, string serviceName)
 {
     this.badgerControlSubsystem = badgerControlSubsystem;
     this.parentComponent = parentComponent;
     this.remoteDriveService = remoteDriveService;
     this.serviceName = serviceName;
 }
开发者ID:WisconsinRobotics,项目名称:BadgerControlSystem,代码行数:7,代码来源:DriveModes.cs


示例18: Invoke

	public void Invoke(GameObject target){
		if (finished) {
			return;
		}
		if (!cached && target != null) {
			List<Type> paramTypes=new List<Type>();
			List<object> args1= new List<object>();
			
			foreach(MethodArgument arg in arguments){
				paramTypes.Add(arg.SerializedType);
				args1.Add(arg.Get());
			}
			args=args1.ToArray();
			methodInfo=SerializedType.GetMethod(method,paramTypes.ToArray());
			if(SerializedType==typeof(Component) || SerializedType.IsSubclassOf(typeof(Component))){
				component=target.GetComponent(SerializedType);
			}
		}
		
		try{
			methodInfo.Invoke (component, args);
		}catch{
			
		}
		finished = true;
	}
开发者ID:AlexGam,项目名称:TowerIsland,代码行数:26,代码来源:EventNode.cs


示例19: Parser

    public MyJson.IJsonNode Parser(Component com,NeedList list)
    {

        UITexture t = com as UITexture;
        var json = new MyJson.JsonNode_Object();


        if(t.mainTexture!=null)
        {
            string needtex = AtlasMgr.SaveTexture(t.mainTexture, System.IO.Path.Combine(Application.streamingAssetsPath, "nguitex"));
            json["mainTexture"] = new MyJson.JsonNode_ValueString(needtex);
            list.AddDependTexture(needtex);
            if(t.shader!=null)
            {
                string shader = t.shader.name;
                json["shader"] = new MyJson.JsonNode_ValueString(shader);
            }
        }
        else
        {
            Debug.LogWarning("不支持 导出使用材质的UITexture");
        }

        json["uvRect"] = new MyJson.JsonNode_ValueString(ComponentTypeConvert.RectToString(t.uvRect));
        ComponentParser.ParserWidget(json, t);

        return json;

    }
开发者ID:GraphicGame,项目名称:easydown,代码行数:29,代码来源:ParserUITexture.cs


示例20: AddObserver

	public void AddObserver (Component observer, String name, object sender) {
	    // If the name isn't good, then throw an error and return.
	    if (name == null || name == "") { Debug.Log("Null name specified for notification in AddObserver."); return; }
	    // If this specific notification doens't exist yet, then create it.
		if (!notifications.ContainsKey(name)) {
	        notifications[name] = new List<Component>();
	    }
//	    if (!notifications[name]) {
//	        notifications[name] = new List<Component>();
//	    }
 
	    List<Component> notifyList = (List<Component>)notifications[name];

        // If the list of observers doesn't already contain the one that's registering, then add it.
        //if (!notifyList.Contains(observer)) {
        //    notifyList.Add(observer);
        //}

        bool add = true;
        foreach(Component c in notifyList)
        {
            if(c.gameObject.Equals(observer.gameObject))
            {
                add = false;
            }
        }

        if(add)
        {
            notifyList.Add(observer);
        }
	}
开发者ID:ludu12,项目名称:SoftwareEngProject,代码行数:32,代码来源:NotificationCenter.cs



注:本文中的Component类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ComponentInstanceDelegate类代码示例发布时间:2022-05-24
下一篇:
C# ComplexStructureQueryDetail类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap