示例#1
0
        public NPCTemplate(string name, string id, INPCBehavior behavior)
        {
            Name = name;
            ID   = id;

            TileTemplate = new Tile(ID, this);

            Behavior = behavior != null ? behavior : new NullNPCBehavior();

            foreach (Direction direction in Enum.GetValues(typeof(Direction)))
            {
                int    i = 0;
                string textureTemplate = "";

                switch (direction)
                {
                case Direction.Up:
                    textureTemplate = NPC.UP_TEXTURE;
                    break;

                case Direction.Down:
                    textureTemplate = NPC.DOWN_TEXTURE;
                    break;

                case Direction.Left:
                    textureTemplate = NPC.LEFT_TEXTURE;
                    break;

                case Direction.Right:
                    textureTemplate = NPC.RIGHT_TEXTURE;
                    break;
                }

                while (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "data/" + textureTemplate.Replace("{name}", ID).Replace("{i}", i.ToString())))
                {
                    i++;
                }

                _frameCounts.Add(direction, i);
            }
        }
示例#2
0
 public void setNPCBehavior(INPCBehavior nB)
 {
     MyNPCBehavior = nB;
 }