资源简介
在Umedy上找到一门Unity的入门课,跟着课程写了一个俄罗斯方块的游戏。涉及到unity的基本概念,以及particle模块。
代码片段和文件信息
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Board : MonoBehaviour {
public Transform m_emptySprite;
public int m_height = 30;
public int m_width = 10;
public int m_header = 8;
public int m_completedRows = 0;
Transform[] m_grid;
// create reference to the particle player
public ParticlePlayer[] m_rowGlowFX = new ParticlePlayer[4];
void Awake() // prestart
{
m_grid = new Transform[m_width m_height];
}
// Use this for initialization
void Start () {
DrawEmptyCells();
}
// Update is called once per frame
void Update () {
}
bool IsWitinBoard(int x int y) {
return (x >= 0 && x < m_width && y >= 0);
}
public bool IsValidPosition(Shape shape) {
foreach(Transform child in shape.transform) {
Vector2 pos = Vectorf.Round(child.position);
if(!IsWitinBoard((int)pos.x (int)pos.y)) { // float to int cast here
return false;
}
if(IsOccupied((int)pos.x (int)pos.y shape)) {
return false;
}
}
return true;
}
void DrawEmptyCells() {
if(m_emptySprite != null)
{
for (int y = 0; y < m_height - m_header; y++)
{
for (int x = 0; x < m_width; x++)
{
Transform clone;
clone = Instantiate(m_emptySprite new Vector3(x y 0) Quaternion.identity) as Transform; // Quaternion.identity rotation zero...
clone.name = “Board Space: x=“ + x.ToString() + “ y=“ + y.ToString();
clone.transform.parent = transform;
}
}
} else
{
Debug.Log(“init sprite“);
}
}
public void StoreShapeInGrid(Shape shape) {
if (shape == null) return;
foreach(Transform child in shape.transform) {
Vector2 pos = Vectorf.Round(child.position);
Debug.LogWarning(“vector postiion: “ + pos.x + “ “ + pos.y);
m_grid[(int)pos.x (int)pos.y] = child;
}
}
bool IsOccupied(int x int y Shape shape) {
return (m_grid[x y] != null && m_grid[x y].parent != shape.transform);// differet object
}
bool IsCompleted(int y) {
for(int x=0;x {
if(m_grid[x y] == null)
{
return false;
}
}
return true;
}
void ClearRow(int y) {
for(int x=0;x {
if(m_grid[x y] != null) {
Destroy(m_grid[x y].gameobject);
}
m_grid[x y] = null;
}
}
void ShiftOneRowDown(int y)
{
for(int x=0;x {
if(m_grid[x y] != null)
{
m_grid[x y - 1] = m_grid[x y];
m_grid[x y] = null;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-04-17 18:51 TetrisClone-section11\
文件 422 2018-04-17 18:51 TetrisClone-section11\.gitignore
目录 0 2018-04-17 18:51 TetrisClone-section11\Assets\
文件 241944 2018-04-17 18:51 TetrisClone-section11\Assets\4-0-ShapePivots.jpeg
文件 1687 2018-04-17 18:51 TetrisClone-section11\Assets\4-0-ShapePivots.jpeg.me
文件 192 2018-04-17 18:51 TetrisClone-section11\Assets\Fonts.me
目录 0 2018-04-17 18:51 TetrisClone-section11\Assets\Fonts\
文件 214 2018-04-17 18:51 TetrisClone-section11\Assets\Fonts\hemi-head-426.me
文件 111219 2018-04-17 18:51 TetrisClone-section11\Assets\Fonts\hemi-head-426.zip
文件 197 2018-04-17 18:51 TetrisClone-section11\Assets\Fonts\hemi-head-426.zip.me
目录 0 2018-04-17 18:51 TetrisClone-section11\Assets\Fonts\hemi-head-426\
文件 81048 2018-04-17 18:51 TetrisClone-section11\Assets\Fonts\hemi-head-426\hemi head bd it.ttf
文件 509 2018-04-17 18:51 TetrisClone-section11\Assets\Fonts\hemi-head-426\hemi head bd it.ttf.me
文件 12396 2018-04-17 18:51 TetrisClone-section11\Assets\Fonts\hemi-head-426\read-this.html
文件 200 2018-04-17 18:51 TetrisClone-section11\Assets\Fonts\hemi-head-426\read-this.html.me
文件 71442 2018-04-17 18:51 TetrisClone-section11\Assets\Fonts\hemi-head-426\typodermic-eula-02-2014.pdf
文件 197 2018-04-17 18:51 TetrisClone-section11\Assets\Fonts\hemi-head-426\typodermic-eula-02-2014.pdf.me
文件 192 2018-04-17 18:51 TetrisClone-section11\Assets\Particles.me
目录 0 2018-04-17 18:51 TetrisClone-section11\Assets\Particles\
文件 214 2018-04-17 18:51 TetrisClone-section11\Assets\Particles\Materials.me
目录 0 2018-04-17 18:51 TetrisClone-section11\Assets\Particles\Materials\
文件 4296 2018-04-17 18:51 TetrisClone-section11\Assets\Particles\Materials\CircleMat.mat
文件 95 2018-04-17 18:51 TetrisClone-section11\Assets\Particles\Materials\CircleMat.mat.me
文件 4296 2018-04-17 18:51 TetrisClone-section11\Assets\Particles\Materials\HexagonMat.mat
文件 138 2018-04-17 18:51 TetrisClone-section11\Assets\Particles\Materials\HexagonMat.mat.me
文件 4292 2018-04-17 18:51 TetrisClone-section11\Assets\Particles\Materials\LineMat.mat
文件 138 2018-04-17 18:51 TetrisClone-section11\Assets\Particles\Materials\LineMat.mat.me
文件 5068 2018-04-17 18:51 TetrisClone-section11\Assets\Particles\Materials\SparkleMat.mat
文件 230 2018-04-17 18:51 TetrisClone-section11\Assets\Particles\Materials\SparkleMat.mat.me
文件 5072 2018-04-17 18:51 TetrisClone-section11\Assets\Particles\Materials\SquareGlowMat.mat
文件 230 2018-04-17 18:51 TetrisClone-section11\Assets\Particles\Materials\SquareGlowMat.mat.me
............此处省略245个文件信息
相关资源
- Unity3D贪吃蛇源码
- Unity3D 使用Vuforia Vuforia Engine 8.0发布
- unity 3d迷宫 NPC 小地图
- Final IK 2.0
- unity简单的2D飞机大战游戏
- NGUI v3.12.0 Unity3D2017~2018
- Unity3D VText 2.0.2
- 传智播客Unity3D视频教程—3-案例:地
- 《Unity3D ShaderLab开发实战详解》源代码
- Unity3D特效包 100种unity特效
- unity3d小游戏源码
- 次表面散射玉石
- 3D MAX 9(2009) FBX插件 官方版
- unity3d解包工具
- SALSA with RandomEyes for unity3d
- Unity3D坦克大战 源代码3D游戏开发
- unity简单的2D飞机大战
- Unity3D StarTrooper多人游戏源码(可运行
- Unity3D官方地形包,TerrainAsset.unitypac
- Unity3D 坦克射击游戏完整工程文件
- 超好用的公路创建插件RoadBuilder.zip
- 树木与草地
- unity3d鸟与家禽动画模型
- MegaFiers_Mesh V3.36
- 基于qt的俄罗斯方块源代码
- unity3d 地形资源
- Unity3d 5.x滚动小球完整项目 demo
- Unity3D合金弹头游戏项目资源
- UNITY3D桂电校园漫游
- Unity小游戏【Roll a ball】源码231346
评论
共有 条评论