GameEngine.cs

(开头部分) 8KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ClassicGame
{
    public class GameEngine
    {
        /// <summary>
        /// 每个小框框的宽度
        /// </summary>
        protected int WidthOfItem { get; set; } = 20;
        protected GameItem[,] GameArrays { get; set; }

        /// <summary>
        /// 游戏画布的大小
        /// </summary>
        protected Size BoardSize { get; set; }

        /// <summary>
        /// 得分情况
        /// </summary>
        public int PlayerScore { get; set; } = 0;
        /// <summary>
        /// 游戏是否启动
        /// </summary>
        public bool IsGameStart { get; set; } = false;



        /// <summary>
        /// Initialization an object [实例化一个对象]
        /// </summary>
        /// <param name="size"></param>
        public virtual void Initialization(Size size)
        {
            BoardSize = size;

            GameArrays = new GameItem[size.Width, size.Height];
            for (int i = 0; i < BoardSize.Width; i++)
            {
                for (int j = 0; j < BoardSize.Height; j++)
                {
                    GameArrays[i, j] = new GameItem() ;
                }
            }
            //restore the colors [还原所有的颜色]
            TetrisArrayAction(t =>
            {
                t.ItemColor = Color.Black;
            });
        }
        
        private void TetrisArrayAction(Action<GameItem> action)
        {
            for (int i = 0; i < BoardSize.Width; i++)
后面还有 209 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。