コード例 #1
0
        //添加新Actor
        protected Image AddActor(GameActor actor, string actorRes = "MainImage")
        {
            var imageSource = (ImageSource)actor.GetType().GetField(actorRes)?.GetValue(actor);

            if (imageSource == null)
            {
                throw new ArgumentException("Can't find " + actorRes + " in actor " + actor.GetType().Name);
            }

            var image = new Control.RelevantImage(this)
            {
                Source            = imageSource,
                RelevantX         = actor.RelevantX,
                RelevantY         = actor.RelevantY,
                RelevantScale     = actor.RelevantScale,
                ImageRelevantType = actor.ImageRelevantType
            };

            mActorList.Add(new Tuple <GameActor, Control.RelevantImage>(actor, image));
            mActorLayout.Children.Add(image);

            return(image);
        }
コード例 #2
0
ファイル: Mover.cs プロジェクト: Yash-Codemaster/KoduGameLab
 /// <summary>
 /// Set owner and derive a debug name from it.
 /// </summary>
 /// <param name="owner"></param>
 public override void SetOwner(GameActor owner)
 {
     base.SetOwner(owner);
     DebugName = owner.GetType().ToString() + owner.uniqueNum;
 }