当前位置: 首页>>代码示例>>C#>>正文


C# ICharacter.GetType方法代码示例

本文整理汇总了C#中ICharacter.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# ICharacter.GetType方法的具体用法?C# ICharacter.GetType怎么用?C# ICharacter.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICharacter的用法示例。


在下文中一共展示了ICharacter.GetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EnterAttackPhase

        private void EnterAttackPhase(ICharacter enemy)
        {
            if (enemy.HitPoints == 0)
            {
                return;
            }

            this.renderer.WriteLine(
                "Enemy encountered: {0} (damage: {1}, hit points: {2})",
                enemy.GetType().Name,
                enemy.Damage,
                enemy.HitPoints);

            while (enemy.HitPoints > 0)
            {
                this.renderer.WriteLine("Do you want to attack? (y/n)");

                string choice = this.inputHandler.ReadLine();

                while (choice != "n" & choice != "y")
                {
                    this.renderer.WriteLine("Invalid choice, please enter 'y' or 'n'.");
                    choice = this.inputHandler.ReadLine();
                }

                switch (choice)
                {
                    case "n":
                        this.renderer.WriteLine("Chicken!!! Y U no fight?!?");
                        return;
                    case "y":
                        this.PerformAttack(enemy);
                        break;
                }
            }
        }
开发者ID:hkostadinov,项目名称:SoftUni,代码行数:36,代码来源:GameEngine.cs

示例2: WriteCharacter

        private void WriteCharacter(ICharacter ch, ListSet<Timeline> unboundClasses)
        {
            int cid;

            if (ch == null)
            {
                return;
            }

            if (this.characterMarshal.HasMarshalled(ch))
            {
                return;
            }

            int fontID = -1;

            if (ch is IFontUserProcessor)
            {
                IFontUserProcessor fup = (IFontUserProcessor)ch;
                fup.FontUserProc(delegate(IFontUser fu)
                {
                    if (fu.HasFont && !characterMarshal.HasMarshalled(fu.Font))
                    {
                        fontID = characterMarshal.GetIDFor(fu.Font);
                        this.WriteFont(fu.Font, fontID);
                    }
                    else
                    {
                        fontID = characterMarshal.GetExistingIDFor(fu.Font);
                    }
                });
            }

            if (ch is IShape)
            {
                IImage[] images = ((IShape)ch).GetImages();

                if (images != null)
                {
                    foreach (IImage image in images)
                    {
                        this.WriteImage(image);
                    }
                }

                Tag format;
                byte[] shapeBytes = ShapeWriter.ShapeToBytes((IShape)ch, out format);

                WriteBuffer shapeTag = this.OpenTag(format);
                cid = this.characterMarshal.GetIDFor(ch);
                shapeTag.WriteUI16((uint)cid);
                shapeTag.WriteBytes(shapeBytes);
            #if DEBUG
                this.LogMessage("char id=" + cid);
            #endif
                this.CloseTag();
            }
            else if (ch is Sprite)
            {
                this.WriteSprite((Sprite)ch, unboundClasses);
            }
            else if (ch is EditText)
            {
                this.WriteEditText((EditText)ch, fontID);
            }
            else if (ch is StaticText)
            {
                this.WriteStaticText((StaticText)ch);
            }
            else
            {
                /* ISSUE 73 */
                throw new SWFModellerException(
                            SWFModellerError.UnimplementedFeature,
                            "Character of type " + ch.GetType().ToString() + " not currently supported in writer");
            }

            if (ch is Timeline)
            {
                Timeline tl = (Timeline)ch;
                if (tl.HasClass && !(tl.Class is AdobeClass) && !unboundClasses.Contains(tl))
                {
                    unboundClasses.Add(tl);
                }
            }
        }
开发者ID:WeeWorld,项目名称:Swiffotron,代码行数:86,代码来源:SWFWriter.cs


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