2012年5月28日月曜日

「ゲームアップ」 アメバピーグ顔文字プラグイン作成方法

お庭とアイランドで顔文字を見せるプラグインです。

効果は下記のようです。


ゲームアンプ公式サイトはこちら

プロジェクトファイルのダウンロードはこちらです。
ダウンロード
binフォルダのプラグインファイルが作成しておきました。


コード
AAMojiPlugin.cs
using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;
using Internal.GameAmp;
using System.Threading;
using AAMoji;

public class AAMojiPlugin : Plugin
{
    public AAMojiPlugin()
        : base(typeof(AAMojiPlugin))
    {
        Enc = Encoding.UTF8;
        Form1 f = new Form1(delegate
        {
            string templ = "\0area.talk:{{\"message\":\"{0}\",\"color\":16711680}}";
            SendMessage(string.Format(templ, "/      \"));
            SendMessage(string.Format(templ, "/  _ノ  ヽ、_  \"));
            SendMessage(string.Format(templ, "/  o゚⌒   ⌒゚o  \ "));
            SendMessage(string.Format(templ, "|     (__人__)    |"));
            SendMessage(string.Format(templ, "\     ` ⌒´     /"));

        EnableChanged += new EnableChangedHandler(delegate(object sender, EnableChangedEventArgs e)
            {
                if (!f.IsDisposed)
                {
                    if (e.Enabled)
                        f.Show();
                    else f.Hide();
                }
            });
    }

    private void SendMessage(string msg)
    {
        Thread.Sleep(500);
        SendBytes(Enc.GetBytes(msg).Concat(new byte[] { 0xff }).ToArray());
    }
}
Form1.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace AAMoji
{
    public partial class Form1 : Form
    {

        public Form1(DoWorkEventHandler dowork)
        {
            InitializeComponent();
            _bgw.DoWork += new DoWorkEventHandler(dowork);
        }
        private BackgroundWorker _bgw = new BackgroundWorker();
        private void _buttonStart_Click(object sender, EventArgs e)
        {
            _bgw.RunWorkerAsync();
        }
    }
}

0 件のコメント:

コメントを投稿