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


C# Layer.AddActor方法代码示例

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


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

示例1: LoadLevel


//.........这里部分代码省略.........
                        // ---- Read the actor data

                        //Create a new Actor instance
                        Actor actor =  null;

                        //Get the actor's ID
                        int ID = file.ReadInt32( );

                        //Get the sprite name
                        string spriteName = file.ReadString( );

                        //Get the script name
                        scriptName = file.ReadString( );
                        if( scriptName != GameManager.NO_SCRIPT )
                        {
                            Type type = _gameManager.GetClassType( scriptName );

                            if( type != null )
                                actor = Activator.CreateInstance( type ) as Actor;
                        }

                        if( actor == null )
                            actor = new Actor( );

                        actor.ID = ID;

                        //Assign the correct sprite to the actor if a match is found
                        if( Sprites.ContainsKey( spriteName ) )
                            actor.Sprite = Sprites[spriteName];

                        //Get and assign the name of the actor
                        actor.Name = file.ReadString( );

                        //Get and assign the actor's position
                        actor.Position = new Vector2( file.ReadSingle( ), file.ReadSingle( ) );

                        //Get and assign the actor's origin
                        actor.Origin = new Vector2( file.ReadSingle( ), file.ReadSingle( ) );

                        //Get and assign the actor's scale
                        actor.Scale = file.ReadSingle( );

                        //Get and assign the actor's rotation angle
                        actor.Rotation = file.ReadSingle( );

                        //Get and assign the actor's visibility
                        actor.Visible = file.ReadBoolean( );

                        if( levelVersion >= 3 )
                        {
                            int tagCount = file.ReadInt32( );
                            for( int k = 0; k < tagCount; k++ )
                            {
                                actor.AddTag( file.ReadString( ) );
                            }

                            bool isTextActor = file.ReadBoolean( );
                            if( isTextActor )
                            {
                                if( ( actor as TextActor ) == null )
                                {
                                    TextActor txtActor = new TextActor( );
                                    actor.CopyValues( txtActor );
                                    actor = txtActor;
                                }

                                string fontName = file.ReadString( );
                                if( Fonts.ContainsKey( fontName ) )
                                    ( actor as TextActor ).Font = Fonts[fontName];
                                ( actor as TextActor ).Text = file.ReadString( );
                                ( actor as TextActor ).TextColor = new Color( file.ReadByte( ), file.ReadByte( ), file.ReadByte( ), file.ReadByte( ) );
                            }
                        }

                        //Add the actor to the layer
                        layer.AddActor( actor );
                    }

                    //Add the layer instance to the level
                    lvl.NewLayer( layer );
                }

                file.Close( );

                lvl.Game = this;
                ActiveLevel = lvl;
            }

            LevelLoaded( );

            ActiveLevel.Init( );

            foreach( Layer layer in ActiveLevel.Layers.Values )
            {
                foreach( Actor actor in layer.Actors )
                {
                    actor.Init( );
                }
            }
        }
开发者ID:HaKDMoDz,项目名称:Lunar-Development-Kit,代码行数:101,代码来源:LunarGame.cs


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