Initial Commit
This commit is contained in:
commit
5762e435dd
25
.gitignore
vendored
Normal file
25
.gitignore
vendored
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
# Created by https://www.gitignore.io/api/unity
|
||||||
|
|
||||||
|
### Unity ###
|
||||||
|
/[Ll]ibrary/
|
||||||
|
/[Tt]emp/
|
||||||
|
/[Oo]bj/
|
||||||
|
/[Bb]uild/
|
||||||
|
|
||||||
|
# Autogenerated VS/MD solution and project files
|
||||||
|
*.csproj
|
||||||
|
*.unityproj
|
||||||
|
*.sln
|
||||||
|
*.suo
|
||||||
|
*.tmp
|
||||||
|
*.user
|
||||||
|
*.userprefs
|
||||||
|
*.pidb
|
||||||
|
*.booproj
|
||||||
|
|
||||||
|
# Unity3D generated meta files
|
||||||
|
*.pidb.meta
|
||||||
|
|
||||||
|
# Unity3D Generated File On Crash Reports
|
||||||
|
sysinfo.txt
|
||||||
|
|
BIN
Assets/Game.unity
Normal file
BIN
Assets/Game.unity
Normal file
Binary file not shown.
8
Assets/Game.unity.meta
Normal file
8
Assets/Game.unity.meta
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9e67a3a591b256644a1daa40ebf32a2b
|
||||||
|
timeCreated: 1440645242
|
||||||
|
licenseType: Free
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
9
Assets/Resources.meta
Normal file
9
Assets/Resources.meta
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2e575c5b12b669b40b861bc5ff56ad2c
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1440639305
|
||||||
|
licenseType: Free
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
BIN
Assets/Resources/Bouncy.physicMaterial
Normal file
BIN
Assets/Resources/Bouncy.physicMaterial
Normal file
Binary file not shown.
8
Assets/Resources/Bouncy.physicMaterial.meta
Normal file
8
Assets/Resources/Bouncy.physicMaterial.meta
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 37cbe527af0aed6438ce40c2beae8260
|
||||||
|
timeCreated: 1440641514
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
9
Assets/Resources/Materials.meta
Normal file
9
Assets/Resources/Materials.meta
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 12900458aad356b48ab4ffd644ec05f1
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1440644678
|
||||||
|
licenseType: Free
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
BIN
Assets/Resources/Materials/Black.mat
Normal file
BIN
Assets/Resources/Materials/Black.mat
Normal file
Binary file not shown.
8
Assets/Resources/Materials/Black.mat.meta
Normal file
8
Assets/Resources/Materials/Black.mat.meta
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b66f9e7d5a4f43c4689ae1f1c814c68f
|
||||||
|
timeCreated: 1440644770
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
BIN
Assets/Resources/Materials/Blue.mat
Normal file
BIN
Assets/Resources/Materials/Blue.mat
Normal file
Binary file not shown.
8
Assets/Resources/Materials/Blue.mat.meta
Normal file
8
Assets/Resources/Materials/Blue.mat.meta
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 349f863a023bc5a438ae6df82cbc6ae9
|
||||||
|
timeCreated: 1440644693
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
BIN
Assets/Resources/Materials/Green.mat
Normal file
BIN
Assets/Resources/Materials/Green.mat
Normal file
Binary file not shown.
8
Assets/Resources/Materials/Green.mat.meta
Normal file
8
Assets/Resources/Materials/Green.mat.meta
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b8b897b2d7978e74ab8aefdd126fdd95
|
||||||
|
timeCreated: 1440644701
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
BIN
Assets/Resources/Materials/Orange.mat
Normal file
BIN
Assets/Resources/Materials/Orange.mat
Normal file
Binary file not shown.
8
Assets/Resources/Materials/Orange.mat.meta
Normal file
8
Assets/Resources/Materials/Orange.mat.meta
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8a5ef4b1cfd15bf46a56074b8608133f
|
||||||
|
timeCreated: 1440644755
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
BIN
Assets/Resources/Materials/Purple.mat
Normal file
BIN
Assets/Resources/Materials/Purple.mat
Normal file
Binary file not shown.
8
Assets/Resources/Materials/Purple.mat.meta
Normal file
8
Assets/Resources/Materials/Purple.mat.meta
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e3c8801d956f2034b8466dd0d921ff3e
|
||||||
|
timeCreated: 1440644761
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
BIN
Assets/Resources/Materials/Red.mat
Normal file
BIN
Assets/Resources/Materials/Red.mat
Normal file
Binary file not shown.
8
Assets/Resources/Materials/Red.mat.meta
Normal file
8
Assets/Resources/Materials/Red.mat.meta
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a54a669325f5641488ffbff0e4c9d872
|
||||||
|
timeCreated: 1440644688
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
BIN
Assets/Resources/Materials/Yellow.mat
Normal file
BIN
Assets/Resources/Materials/Yellow.mat
Normal file
Binary file not shown.
8
Assets/Resources/Materials/Yellow.mat.meta
Normal file
8
Assets/Resources/Materials/Yellow.mat.meta
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 64e4a72fb823c2a439a046c6af121783
|
||||||
|
timeCreated: 1440644724
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
9
Assets/Resources/Prefabs.meta
Normal file
9
Assets/Resources/Prefabs.meta
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 17093aed8ebf63d448e23e6cc2dd1612
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1440639314
|
||||||
|
licenseType: Free
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
BIN
Assets/Resources/Prefabs/Gem.prefab
Normal file
BIN
Assets/Resources/Prefabs/Gem.prefab
Normal file
Binary file not shown.
8
Assets/Resources/Prefabs/Gem.prefab.meta
Normal file
8
Assets/Resources/Prefabs/Gem.prefab.meta
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a0f118e7f2851f9419cb0bcd452b4424
|
||||||
|
timeCreated: 1440639401
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
9
Assets/Resources/Scripts.meta
Normal file
9
Assets/Resources/Scripts.meta
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3db396677d4ecb84cb133b123fe24518
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1440639318
|
||||||
|
licenseType: Free
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
202
Assets/Resources/Scripts/Board.cs
Normal file
202
Assets/Resources/Scripts/Board.cs
Normal file
|
@ -0,0 +1,202 @@
|
||||||
|
using UnityEngine;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public class Board : MonoBehaviour {
|
||||||
|
public List<Gem> gems = new List<Gem>();
|
||||||
|
public int GridWidth;
|
||||||
|
public int GridHeight;
|
||||||
|
|
||||||
|
public GameObject gemPrefab;
|
||||||
|
public Gem lastGem;
|
||||||
|
// Animation
|
||||||
|
public Vector3 gem1Start, gem1End, gem2Start, gem2End;
|
||||||
|
public bool isSwapping = false;
|
||||||
|
public Gem gem1, gem2;
|
||||||
|
public float startTime;
|
||||||
|
public float swapRate = 0.5f;
|
||||||
|
public int AmountToMatch = 3;
|
||||||
|
public bool isMatched = false;
|
||||||
|
int topLine = 6;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Use this for initialization
|
||||||
|
void Start () {
|
||||||
|
for (int h = 0; h < GridHeight; h++) {
|
||||||
|
for (int w = 0; w < GridWidth; w++){
|
||||||
|
GameObject g = Instantiate(gemPrefab, new Vector3(h,w,0), Quaternion.identity) as GameObject;
|
||||||
|
g.transform.parent = gameObject.transform;
|
||||||
|
gems.Add(g.GetComponent<Gem>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update () {
|
||||||
|
if (isMatched) {
|
||||||
|
for (int i =0; i<gems.Count; i++) {
|
||||||
|
if (gems [i].isMatched) {
|
||||||
|
// Move it back up top, and change the color.
|
||||||
|
gems [i].CreateGem ();
|
||||||
|
gems [i].transform.position = new Vector3 (gems [i].transform.position.x,
|
||||||
|
gems [i].transform.position.y + topLine,
|
||||||
|
gems [i].transform.position.z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
isMatched = false;
|
||||||
|
} else if (isSwapping) {
|
||||||
|
MoveGem (gem1, gem1End, gem1Start);
|
||||||
|
MoveNegGem (gem2, gem2End, gem2Start);
|
||||||
|
if (Vector3.Distance (gem1.transform.position, gem1End) < 0.1f ||
|
||||||
|
Vector3.Distance (gem2.transform.position, gem2End) < 0.1f) {
|
||||||
|
gem1.transform.position = gem1End;
|
||||||
|
gem2.transform.position = gem2End;
|
||||||
|
lastGem = null;
|
||||||
|
gem1.ToggleSelector ();
|
||||||
|
gem2.ToggleSelector ();
|
||||||
|
isSwapping = false;
|
||||||
|
TogglePhysics (false);
|
||||||
|
CheckMatch ();
|
||||||
|
}
|
||||||
|
} else if (!BoardInMotion()) {
|
||||||
|
for(int i=0;i<gems.Count;i++){
|
||||||
|
CheckForNearbyMatches(gems[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool BoardInMotion(){
|
||||||
|
for (int i=0; i<gems.Count; i++) {
|
||||||
|
if(gems[i].transform.localPosition.y > topLine) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (gems[i].GetComponent<Rigidbody>().velocity.y > 0.1f){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CheckForNearbyMatches (Gem g){
|
||||||
|
List<Gem> gemList = new List<Gem> ();
|
||||||
|
ConstructMatchList (g.color, g, g.XCoord, g.YCoord, ref gemList);
|
||||||
|
FixMatchList (g, gemList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ConstructMatchList(string color, Gem gem, int XCoord, int YCoord, ref List<Gem> MatchList){
|
||||||
|
if (gem == null || gem.color != color || MatchList.Contains(gem)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MatchList.Add (gem);
|
||||||
|
|
||||||
|
if (XCoord == gem.XCoord || YCoord == gem.YCoord){
|
||||||
|
foreach(Gem g in gem.Neighbors){
|
||||||
|
ConstructMatchList(color, g, XCoord, YCoord, ref MatchList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void CheckMatch(){
|
||||||
|
List<Gem> gem1List = new List<Gem> ();
|
||||||
|
List<Gem> gem2List = new List<Gem> ();
|
||||||
|
ConstructMatchList (gem1.color, gem1, gem1.XCoord, gem1.YCoord, ref gem1List);
|
||||||
|
FixMatchList (gem1, gem1List);
|
||||||
|
ConstructMatchList (gem2.color, gem2, gem2.XCoord, gem2.YCoord, ref gem2List);
|
||||||
|
FixMatchList (gem2, gem2List);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void FixMatchList(Gem gem, List<Gem> ListToFix){
|
||||||
|
List<Gem> rows = new List<Gem> ();
|
||||||
|
List<Gem> columns = new List<Gem> ();
|
||||||
|
|
||||||
|
for (int i=0; i <ListToFix.Count; i++) {
|
||||||
|
if (gem.XCoord == ListToFix[i].XCoord){
|
||||||
|
rows.Add(ListToFix[i]);
|
||||||
|
}
|
||||||
|
if (gem.YCoord == ListToFix[i].YCoord){
|
||||||
|
columns.Add(ListToFix[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rows.Count >= AmountToMatch) {
|
||||||
|
isMatched = true;
|
||||||
|
for (int i=0;i<rows.Count;i++){
|
||||||
|
rows[i].isMatched=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (columns.Count >= AmountToMatch) {
|
||||||
|
isMatched = true;
|
||||||
|
for (int i=0;i<columns.Count;i++){
|
||||||
|
columns[i].isMatched=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void MoveGem(Gem gemToMove, Vector3 toPos, Vector3 fromPos){
|
||||||
|
Vector3 center = (fromPos + toPos) * 0.5f;
|
||||||
|
center -= new Vector3 (0, 0, 0.1f);
|
||||||
|
Vector3 riseRelCenter = fromPos - center;
|
||||||
|
Vector3 setRelCenter = toPos - center;
|
||||||
|
float fracComplete = (Time.time - startTime) / swapRate;
|
||||||
|
gemToMove.transform.position = Vector3.Slerp (riseRelCenter, setRelCenter, fracComplete);
|
||||||
|
gemToMove.transform.position += center;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MoveNegGem(Gem gemToMove, Vector3 toPos, Vector3 fromPos){
|
||||||
|
Vector3 center = (fromPos + toPos) * 0.5f;
|
||||||
|
center -= new Vector3 (0, 0, -0.1f);
|
||||||
|
Vector3 riseRelCenter = fromPos - center;
|
||||||
|
Vector3 setRelCenter = toPos - center;
|
||||||
|
float fracComplete = (Time.time - startTime) / swapRate;
|
||||||
|
gemToMove.transform.position = Vector3.Slerp (riseRelCenter, setRelCenter, fracComplete);
|
||||||
|
gemToMove.transform.position += center;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void SwapGems(Gem currentGem){
|
||||||
|
if (lastGem == null) {
|
||||||
|
lastGem = currentGem;
|
||||||
|
} else if (lastGem == currentGem) {
|
||||||
|
lastGem = null;
|
||||||
|
} else {
|
||||||
|
if(lastGem.IsNeighborWith(currentGem)){
|
||||||
|
gem1Start = lastGem.transform.position;
|
||||||
|
gem1End = currentGem.transform.position;
|
||||||
|
|
||||||
|
gem2Start = currentGem.transform.position;
|
||||||
|
gem2End = lastGem.transform.position;
|
||||||
|
|
||||||
|
startTime = Time.time;
|
||||||
|
|
||||||
|
TogglePhysics(true);
|
||||||
|
gem1 = lastGem;
|
||||||
|
gem2 = currentGem;
|
||||||
|
isSwapping = true;
|
||||||
|
} else {
|
||||||
|
lastGem.ToggleSelector();
|
||||||
|
lastGem = currentGem;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void TogglePhysics(bool isOn){
|
||||||
|
for(int i = 0; i<gems.Count; i++){
|
||||||
|
gems[i].GetComponent<Rigidbody>().isKinematic = isOn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
12
Assets/Resources/Scripts/Board.cs.meta
Normal file
12
Assets/Resources/Scripts/Board.cs.meta
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 673a5430d64e7ce41aa8817b3db6ab98
|
||||||
|
timeCreated: 1440639417
|
||||||
|
licenseType: Free
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
20
Assets/Resources/Scripts/Feeler.cs
Normal file
20
Assets/Resources/Scripts/Feeler.cs
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
using UnityEngine;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
public class Feeler : MonoBehaviour {
|
||||||
|
|
||||||
|
public Gem owner;
|
||||||
|
|
||||||
|
void OnTriggerEnter(Collider c){
|
||||||
|
if (c.tag == "Gem") {
|
||||||
|
owner.AddNeighbor (c.GetComponent<Gem> ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnTriggerExit(Collider c){
|
||||||
|
if (c.tag == "Gem") {
|
||||||
|
owner.RemoveNeighbor (c.GetComponent<Gem> ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
12
Assets/Resources/Scripts/Feeler.cs.meta
Normal file
12
Assets/Resources/Scripts/Feeler.cs.meta
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: fbdd79d083fff1249b04e9ca1b097ea5
|
||||||
|
timeCreated: 1440640472
|
||||||
|
licenseType: Free
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
78
Assets/Resources/Scripts/Gem.cs
Normal file
78
Assets/Resources/Scripts/Gem.cs
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
using UnityEngine;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
|
||||||
|
public class Gem : MonoBehaviour {
|
||||||
|
|
||||||
|
public List<Gem> Neighbors = new List<Gem>();
|
||||||
|
string[] gemMats = {"Red", "Green", "Blue", "Orange", "Black", "Purple", "Yellow"};
|
||||||
|
public string color = "";
|
||||||
|
public GameObject gemSphere;
|
||||||
|
public GameObject selector;
|
||||||
|
public bool isSelected;
|
||||||
|
public bool isMatched;
|
||||||
|
|
||||||
|
|
||||||
|
public int XCoord {
|
||||||
|
get {
|
||||||
|
return Mathf.RoundToInt(transform.localPosition.x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public int YCoord {
|
||||||
|
get {
|
||||||
|
return Mathf.RoundToInt(transform.localPosition.y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Use this for initialization
|
||||||
|
void Start () {
|
||||||
|
CreateGem ();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update () {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnMouseDown(){
|
||||||
|
if (!GameObject.Find ("Board").GetComponent<Board> ().isSwapping) {
|
||||||
|
ToggleSelector ();
|
||||||
|
GameObject.Find ("Board").GetComponent<Board> ().SwapGems (this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ToggleSelector(){
|
||||||
|
isSelected = !isSelected;
|
||||||
|
selector.SetActive (isSelected);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsNeighborWith(Gem g){
|
||||||
|
if (Neighbors.Contains (g)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void AddNeighbor(Gem g){
|
||||||
|
if(!Neighbors.Contains (g)){
|
||||||
|
Neighbors.Add (g);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveNeighbor(Gem g){
|
||||||
|
Neighbors.Remove (g);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateGem(){
|
||||||
|
color = gemMats [Random.Range (0, gemMats.Length)];
|
||||||
|
|
||||||
|
Material m = Resources.Load ("Materials/" + color) as Material;
|
||||||
|
gemSphere.GetComponent<Renderer> ().material = m;
|
||||||
|
isMatched = false;
|
||||||
|
}
|
||||||
|
}
|
12
Assets/Resources/Scripts/Gem.cs.meta
Normal file
12
Assets/Resources/Scripts/Gem.cs.meta
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7ac8858139702bc48b6175229805ab0c
|
||||||
|
timeCreated: 1440645702
|
||||||
|
licenseType: Free
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
BIN
ProjectSettings/AudioManager.asset
Normal file
BIN
ProjectSettings/AudioManager.asset
Normal file
Binary file not shown.
BIN
ProjectSettings/DynamicsManager.asset
Normal file
BIN
ProjectSettings/DynamicsManager.asset
Normal file
Binary file not shown.
BIN
ProjectSettings/EditorBuildSettings.asset
Normal file
BIN
ProjectSettings/EditorBuildSettings.asset
Normal file
Binary file not shown.
BIN
ProjectSettings/EditorSettings.asset
Normal file
BIN
ProjectSettings/EditorSettings.asset
Normal file
Binary file not shown.
BIN
ProjectSettings/GraphicsSettings.asset
Normal file
BIN
ProjectSettings/GraphicsSettings.asset
Normal file
Binary file not shown.
BIN
ProjectSettings/InputManager.asset
Normal file
BIN
ProjectSettings/InputManager.asset
Normal file
Binary file not shown.
BIN
ProjectSettings/NavMeshAreas.asset
Normal file
BIN
ProjectSettings/NavMeshAreas.asset
Normal file
Binary file not shown.
BIN
ProjectSettings/NetworkManager.asset
Normal file
BIN
ProjectSettings/NetworkManager.asset
Normal file
Binary file not shown.
BIN
ProjectSettings/Physics2DSettings.asset
Normal file
BIN
ProjectSettings/Physics2DSettings.asset
Normal file
Binary file not shown.
BIN
ProjectSettings/ProjectSettings.asset
Normal file
BIN
ProjectSettings/ProjectSettings.asset
Normal file
Binary file not shown.
2
ProjectSettings/ProjectVersion.txt
Normal file
2
ProjectSettings/ProjectVersion.txt
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
m_EditorVersion: 5.1.2f1
|
||||||
|
m_StandardAssetsVersion: 0
|
BIN
ProjectSettings/QualitySettings.asset
Normal file
BIN
ProjectSettings/QualitySettings.asset
Normal file
Binary file not shown.
BIN
ProjectSettings/TagManager.asset
Normal file
BIN
ProjectSettings/TagManager.asset
Normal file
Binary file not shown.
BIN
ProjectSettings/TimeManager.asset
Normal file
BIN
ProjectSettings/TimeManager.asset
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user