• 大小: 3.8MB
    文件类型: .rar
    金币: 2
    下载: 0 次
    发布日期: 2024-02-02
  • 语言: C#
  • 标签: UNITY,C#  

资源简介

UNITY 俄罗斯方框的项目文件, 手把手教你怎么写俄罗斯方块游戏。初学者必备,C#

资源截图

代码片段和文件信息

using UnityEngine;
using System.Collections;


public class BlockTextures
{
//custom textures used for each possible color
Texture2D red_texture = null;
Texture2D light_blue_texture = null;
Texture2D dark_blue_texture = null;
Texture2D green_texture = null;
Texture2D yellow_texture = null;
Texture2D purple_texture = null;
Texture2D gray_texture = null;

//create a beveled texture with the main color in the center and darker and lighter
//versions of the color for the upper and lower sides similar to classic Tetris
public void CreateBeveledTexture(Texture2D tex float r float g float b)
{
//get the dimensions of the texture
int w = tex.width;
int h = tex.height;
int i j;
//fill the entire texture with the color
Color color = new Color(r g b 1);
for(i = 0;i {
for(j = 0;j {
tex.SetPixel(i j color);
}
}
//now to add the “bevel“ effect we just need make the edges
//lighter or darker using modified versions of the original color

//get a dark color for the lower right
float r2 = r-0.5f;//darken everything
float g2 = g-0.5f;
float b2 = b-0.5f;
if(r2<0)r2 = 0;//make sure nothing goes below 0
if(g2<0)g2 = 0;
if(b2<0)b2 = 0;
Color dark_color = new Color(r2 g2 b2);
//and a bright color for the upper left
float r3 = r+0.5f;//brighten everything
float g3 = g+0.5f;
float b3 = b+0.5f;
if(r3>1)r3 = 1;//make sure nothing goes above 1
if(g3>1)g3 = 1;
if(b3>1)b3 = 1;
Color light_color = new Color(r3 g3 b3);
//now set the top and bottom pixels
for(i = 0;i {
tex.SetPixel(i h-1 light_color);//light on the top
tex.SetPixel(i 0 dark_color);//dark on the bottom
}
//then set the left and right sides
for(j = 0;j {
tex.SetPixel(0 j light_color);//light on the left side
tex.SetPixel(w-1 j dark_color);//dark on the right side
}
tex.Apply();//update the texture
}
//initialize all block textures
public void InitBlockTextures(int w int h)
{
red_texture = new Texture2D(w h);
light_blue_texture = new Texture2D(w h);
dark_blue_texture = new Texture2D(w h);
green_texture = new Texture2D(w h);
yellow_texture = new Texture2D(w h);
purple_texture = new Texture2D(w h);
gray_texture = new Texture2D(w h);
CreateBeveledTexture(red_texture 1 0 0);
CreateBeveledTexture(light_blue_texture 0.25f 0.25f 1);
CreateBeveledTexture(dark_blue_texture 0 0 1);
CreateBeveledTexture(green_texture 0 1 0);
CreateBeveledTexture(yellow_texture 1 1 0);
CreateBeveledTexture(purple_texture 1 0 1);
CreateBeveledTexture(gray_texture 0.5f 0.5f 0.5f);
}
//get the appropriate texture for the specified color
public Texture2D GetBlockTexture(int color)
{
if(color==1)return red_texture;
if(color==2)return light_blue_texture;
if(color==3)return dark_blue_texture;
if(color==4)return green_texture;
if(co

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

     文件       2611  2013-01-09 16:15  tetris tutorial\UnityTetris1\UnityTetris1\Assembly-CSharp-vs.csproj

     文件       2611  2013-01-09 16:15  tetris tutorial\UnityTetris1\UnityTetris1\Assembly-CSharp.csproj

     文件      10151  2013-01-09 16:20  tetris tutorial\UnityTetris1\UnityTetris1\Assembly-CSharp.pidb

     文件       7072  2013-01-23 21:12  tetris tutorial\UnityTetris1\UnityTetris1\Assets\TetrisGrid.cs

     文件        663  2013-01-10 13:09  tetris tutorial\UnityTetris1\UnityTetris1\Assets\UnityTetrisMain.cs

     文件      11724  2011-11-19 16:50  tetris tutorial\UnityTetris1\UnityTetris1\Assets\UnityTetrisMainScene.unity

     文件       1184  2011-11-19 16:48  tetris tutorial\UnityTetris1\UnityTetris1\Library\AnnotationManager

    I.A....     12284  2013-01-09 16:20  tetris tutorial\UnityTetris1\UnityTetris1\Library\assetDatabase3

    I.A....         6  2013-01-09 16:15  tetris tutorial\UnityTetris1\UnityTetris1\Library\AssetImportState

    I.A....      5044  2013-01-09 16:20  tetris tutorial\UnityTetris1\UnityTetris1\Library\AssetServerCacheV3

     文件        458  2011-11-19 16:48  tetris tutorial\UnityTetris1\UnityTetris1\Library\AudioManager.asset

    I.A....         0  2011-11-19 16:48  tetris tutorial\UnityTetris1\UnityTetris1\Library\BuildPlayer.prefs

     文件        797  2011-11-19 16:48  tetris tutorial\UnityTetris1\UnityTetris1\Library\BuildSettings.asset

     文件       1367  2011-11-19 16:48  tetris tutorial\UnityTetris1\UnityTetris1\Library\cache\00\00000000000000001000000000000000

    I.A....      4132  2013-01-09 16:15  tetris tutorial\UnityTetris1\UnityTetris1\Library\cache\00\00000000000000002000000000000000

    I.A....      4132  2013-01-09 16:15  tetris tutorial\UnityTetris1\UnityTetris1\Library\cache\00\00000000000000003000000000000000

    I.A....      4136  2013-01-09 16:20  tetris tutorial\UnityTetris1\UnityTetris1\Library\cache\00\00000000000000004000000000000000

    I.A....      4136  2013-01-09 16:15  tetris tutorial\UnityTetris1\UnityTetris1\Library\cache\00\00000000000000004100000000000000

    I.A....      4132  2013-01-09 16:15  tetris tutorial\UnityTetris1\UnityTetris1\Library\cache\00\00000000000000005000000000000000

    I.A....      4132  2013-01-09 16:15  tetris tutorial\UnityTetris1\UnityTetris1\Library\cache\00\00000000000000006000000000000000

    I.A....      4132  2013-01-09 16:15  tetris tutorial\UnityTetris1\UnityTetris1\Library\cache\00\00000000000000007000000000000000

    I.A....      4136  2013-01-09 16:15  tetris tutorial\UnityTetris1\UnityTetris1\Library\cache\00\00000000000000008000000000000000

    I.A....      4136  2013-01-09 16:15  tetris tutorial\UnityTetris1\UnityTetris1\Library\cache\00\00000000000000009000000000000000

    I.A....      4136  2013-01-09 16:15  tetris tutorial\UnityTetris1\UnityTetris1\Library\cache\00\0000000000000000a000000000000000

    I.A....      4140  2013-01-09 16:15  tetris tutorial\UnityTetris1\UnityTetris1\Library\cache\00\0000000000000000b000000000000000

    I.A....      4136  2013-01-09 16:15  tetris tutorial\UnityTetris1\UnityTetris1\Library\cache\00\0000000000000000c000000000000000

    I.A....     11025  2013-01-09 16:18  tetris tutorial\UnityTetris1\UnityTetris1\Library\cache\87\87e93a3b38df03442a6a19ccad5dd6d9

    I.A....      4140  2013-01-09 16:15  tetris tutorial\UnityTetris1\UnityTetris1\Library\cache\d7\d7d5aa940be8473469375d13bce973d9

    I.A....      4861  2013-01-09 16:19  tetris tutorial\UnityTetris1\UnityTetris1\Library\cache\ec\ecc047972489c5544a57fc9a8d35468c

     文件       1148  2011-11-19 16:48  tetris tutorial\UnityTetris1\UnityTetris1\Library\DynamicsManager.asset

............此处省略2622个文件信息

评论

共有 条评论

相关资源