资源简介

学习委托过程中写的小程序。利用了多线程和鼠标钩子。
模拟重力等。随机产生小球会不断的攻击你的鼠标。 每个小球会思考并决定下一步动作,有一定智能性。

资源截图

代码片段和文件信息

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

namespace Replicator
{
    public partial class frmResult : Form
    {
        private string mstrState = ““;

        public frmResult()
        {
            InitializeComponent();
            this.lblLife.Text = string.Empty.PadLeft(10 fullLife);
            this.lblScore.Text = “0“;
            //this.lblStatus.Text = ““;
        }
        private const int fullLifeValue = 10;
        private const char fullLife = ‘◆‘;
        private const char emptyLife = ‘◇‘;
        private const float score_01 = 2f;
        private const float score_02 = 5f;
        private const float score_03 = 10f;

        public void SetResult(string strState)
        {
            mstrState = strState;
            switch (strState)
            {
                //case “Idle“:
                //    this.lblStatus.Text = “休息会,zzz~~~“;
                //    break;
                //case “FollowingA“:
                //    this.lblStatus.Text = “这样可不得分的噢。“;
                //    break;
                //case “FollowingB“:
                //    this.lblStatus.Text = “嘿嘿,看到你咯!“;
                //    break;
                //case “Attacking“:
                //    this.lblStatus.Text = “来追你了噢~被逮着你就死定啦!“;
                //    break;
                //case “CursorCatched“:
                //    this.lblStatus.Text = “真可怜,你被逮住了,快甩掉它!“;
                //    break;
                //case “Wait“:
                //    break;
                //default:
                //    break;
            }
        }
        /// 
        /// Called when the form is shown
        /// Starts the robot thread
        /// 

        /// -
        /// 
        private void frmResult_Shown(object sender EventArgs e)
        {
            //Start our acting thread
            Thread a = new Thread(Loop);
            a.Start();
        }

        /// 
        /// The Mainloop of the robot
        /// Calls Act() and Think()
        /// 

        public void Loop()
        {
            Thread.Sleep(20);
        }

        private void frmResult_Load(object sender EventArgs e)
        {
            this.TimeClock.Interval = 1000;
            this.TimeClock.Start();
        }

        private void TimeClock_Tick(object sender EventArgs e)
        {

            switch (mstrState )
            {
                case “Idle“:
                    //this.lblBBB.Text = “太远啦,胆小鬼,扣你 “ + score_02.ToString() + “分“;
                    this.lblScore.Text = Math.Round((float.Parse(this.lblScore.Text) - score_02) 2).ToString();
                    break;
                case “FollowingA“:
                    //this.lblBBB.Text = “胆小鬼,扣你 “ + 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        113  2008-09-02 13:21  obj\AutoBall.csproj.FileList.txt

     文件       5612  2008-09-01 11:21  Properties\Resources.resx

     文件        249  2008-09-01 11:21  Properties\Settings.settings

     文件       1182  2008-09-01 11:21  Properties\AssemblyInfo.cs

     文件       2870  2008-09-01 11:21  Properties\Resources.Designer.cs

     文件       1091  2008-09-01 11:21  Properties\Settings.Designer.cs

     文件        655  2008-09-01 11:37  Properties\app.manifest

     文件       4851  2008-09-02 13:20  AutoBall.csproj

     文件        617  2008-09-01 15:11  AutoBall.csproj.user

     文件       4564  2008-09-02 13:08  frmResult.cs

     文件       5597  2008-09-02 13:08  frmResult.Designer.cs

     文件       6011  2008-09-02 13:08  frmResult.resx

     文件       1279  2008-09-01 16:38  Program.cs

     文件      12169  2008-09-01 11:22  Robot.cs

     文件       2522  2008-09-01 11:22  Robot.Designer.cs

     目录          0  2008-09-01 11:21  obj\Debug\TempPE

     目录          0  2008-09-01 11:22  obj\Debug\Refactor

     目录          0  2008-09-01 11:21  obj\Debug

     目录          0  2008-09-01 11:21  bin\Debug

     目录          0  2008-09-01 11:21  obj

     目录          0  2008-09-01 11:21  Properties

     目录          0  2008-09-01 11:21  bin

----------- ---------  ---------- -----  ----

                49382                    22


评论

共有 条评论