Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9607d9dfb9 | ||
|
|
e93d9d7c3f | ||
|
|
f0389d5cf4 | ||
|
|
758c86dcfc | ||
|
|
f7c17cba0d | ||
|
|
92564bf817 | ||
|
|
69339f2001 | ||
|
|
cc11f92f0a | ||
|
|
cb3e7563a6 | ||
|
|
af90d64644 | ||
|
|
12aeb116dd | ||
|
|
4667e3a0b3 | ||
|
|
4041338420 | ||
|
|
29ec7e7eed |
@@ -0,0 +1,13 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Rider ignored files
|
||||||
|
/modules.xml
|
||||||
|
/projectSettingsUpdater.xml
|
||||||
|
/.idea.Chess Recode.iml
|
||||||
|
/contentModel.xml
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="UserContentModel">
|
||||||
|
<attachedFolders />
|
||||||
|
<explicitIncludes />
|
||||||
|
<explicitExcludes />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
|
After Width: | Height: | Size: 35 KiB |
@@ -0,0 +1,96 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: bde12a919cdf6874cb517b5f5203db06
|
||||||
|
TextureImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 11
|
||||||
|
mipmaps:
|
||||||
|
mipMapMode: 0
|
||||||
|
enableMipMap: 0
|
||||||
|
sRGBTexture: 1
|
||||||
|
linearTexture: 0
|
||||||
|
fadeOut: 0
|
||||||
|
borderMipMap: 0
|
||||||
|
mipMapsPreserveCoverage: 0
|
||||||
|
alphaTestReferenceValue: 0.5
|
||||||
|
mipMapFadeDistanceStart: 1
|
||||||
|
mipMapFadeDistanceEnd: 3
|
||||||
|
bumpmap:
|
||||||
|
convertToNormalMap: 0
|
||||||
|
externalNormalMap: 0
|
||||||
|
heightScale: 0.25
|
||||||
|
normalMapFilter: 0
|
||||||
|
isReadable: 0
|
||||||
|
streamingMipmaps: 0
|
||||||
|
streamingMipmapsPriority: 0
|
||||||
|
vTOnly: 0
|
||||||
|
grayScaleToAlpha: 0
|
||||||
|
generateCubemap: 6
|
||||||
|
cubemapConvolution: 0
|
||||||
|
seamlessCubemap: 0
|
||||||
|
textureFormat: 1
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
filterMode: 1
|
||||||
|
aniso: 1
|
||||||
|
mipBias: 0
|
||||||
|
wrapU: 1
|
||||||
|
wrapV: 1
|
||||||
|
wrapW: 1
|
||||||
|
nPOTScale: 0
|
||||||
|
lightmap: 0
|
||||||
|
compressionQuality: 50
|
||||||
|
spriteMode: 1
|
||||||
|
spriteExtrude: 1
|
||||||
|
spriteMeshType: 1
|
||||||
|
alignment: 0
|
||||||
|
spritePivot: {x: 0.5, y: 0.5}
|
||||||
|
spritePixelsToUnits: 100
|
||||||
|
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
spriteGenerateFallbackPhysicsShape: 1
|
||||||
|
alphaUsage: 1
|
||||||
|
alphaIsTransparency: 1
|
||||||
|
spriteTessellationDetail: -1
|
||||||
|
textureType: 8
|
||||||
|
textureShape: 1
|
||||||
|
singleChannelComponent: 0
|
||||||
|
flipbookRows: 1
|
||||||
|
flipbookColumns: 1
|
||||||
|
maxTextureSizeSet: 0
|
||||||
|
compressionQualitySet: 0
|
||||||
|
textureFormatSet: 0
|
||||||
|
ignorePngGamma: 0
|
||||||
|
applyGammaDecoding: 0
|
||||||
|
platformSettings:
|
||||||
|
- serializedVersion: 3
|
||||||
|
buildTarget: DefaultTexturePlatform
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
spriteSheet:
|
||||||
|
serializedVersion: 2
|
||||||
|
sprites: []
|
||||||
|
outline: []
|
||||||
|
physicsShape: []
|
||||||
|
bones: []
|
||||||
|
spriteID: 5e97eb03825dee720800000000000000
|
||||||
|
internalID: 0
|
||||||
|
vertices: []
|
||||||
|
indices:
|
||||||
|
edges: []
|
||||||
|
weights: []
|
||||||
|
secondaryTextures: []
|
||||||
|
spritePackingTag:
|
||||||
|
pSDRemoveMatte: 0
|
||||||
|
pSDShowRemoveMatteOption: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
Before Width: | Height: | Size: 596 B After Width: | Height: | Size: 596 B |
|
Before Width: | Height: | Size: 905 B After Width: | Height: | Size: 905 B |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 558 B After Width: | Height: | Size: 558 B |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 622 B After Width: | Height: | Size: 622 B |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 970 B After Width: | Height: | Size: 970 B |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 814 B After Width: | Height: | Size: 814 B |
|
Before Width: | Height: | Size: 594 B After Width: | Height: | Size: 594 B |
@@ -0,0 +1,107 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class Bishop : Character
|
||||||
|
{
|
||||||
|
public static readonly Vector2[,] moves =
|
||||||
|
{
|
||||||
|
{
|
||||||
|
//up, right
|
||||||
|
new Vector2(1, 1),
|
||||||
|
new Vector2(2, 2),
|
||||||
|
new Vector2(3, 3),
|
||||||
|
new Vector2(4, 4),
|
||||||
|
new Vector2(5, 5),
|
||||||
|
new Vector2(6, 6),
|
||||||
|
new Vector2(7, 7),
|
||||||
|
new Vector2(8.5f, 8.5f),
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
//up, left
|
||||||
|
new Vector2(-1, 1),
|
||||||
|
new Vector2(-2, 2),
|
||||||
|
new Vector2(-3, 3),
|
||||||
|
new Vector2(-4, 4),
|
||||||
|
new Vector2(-5, 5),
|
||||||
|
new Vector2(-6, 6),
|
||||||
|
new Vector2(-7, 7),
|
||||||
|
new Vector2(-8.5f, 8.5f),
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
//down, right
|
||||||
|
new Vector2(1, -1),
|
||||||
|
new Vector2(2, -2),
|
||||||
|
new Vector2(3, -3),
|
||||||
|
new Vector2(4, -4),
|
||||||
|
new Vector2(5, -5),
|
||||||
|
new Vector2(6, -6),
|
||||||
|
new Vector2(7, -7),
|
||||||
|
new Vector2(8.5f, -8.5f),
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
//down, left
|
||||||
|
new Vector2(-1, -1),
|
||||||
|
new Vector2(-2, -2),
|
||||||
|
new Vector2(-3, -3),
|
||||||
|
new Vector2(-4, -4),
|
||||||
|
new Vector2(-5, -5),
|
||||||
|
new Vector2(-6, -6),
|
||||||
|
new Vector2(-7, -7),
|
||||||
|
new Vector2(-8.5f, -8.5f),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
public override bool[,] GetValidMoves(Cell[,] cells, Game game)
|
||||||
|
{
|
||||||
|
bool[,] result = new bool[8, 8];
|
||||||
|
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < 8; j++)
|
||||||
|
{
|
||||||
|
Vector3 testPosition = transform.position + (Vector3)moves[i, j];
|
||||||
|
Cell testCell = game.GetCellOnPosition(testPosition);
|
||||||
|
|
||||||
|
if (testCell != null)
|
||||||
|
{
|
||||||
|
if (testCell.connected == null)
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
|
||||||
|
string nameX = testCell.gameObject.name.Substring(5, 1);
|
||||||
|
string nameY = testCell.gameObject.name.Substring(7, 1);
|
||||||
|
|
||||||
|
x = int.Parse(nameX);
|
||||||
|
y = int.Parse(nameY);
|
||||||
|
|
||||||
|
result[x, y] = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (testCell.connected.team != game.currentTeam)
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
|
||||||
|
string nameX = testCell.gameObject.name.Substring(5, 1);
|
||||||
|
string nameY = testCell.gameObject.name.Substring(7, 1);
|
||||||
|
|
||||||
|
x = int.Parse(nameX);
|
||||||
|
y = int.Parse(nameY);
|
||||||
|
|
||||||
|
result[x, y] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
j = 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 82078bc56df7bd948ae23d6db04fd436
|
guid: 843bca5b9b65c744b8f87208f3ce7aef
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class Buttons : MonoBehaviour
|
||||||
|
{
|
||||||
|
public Button buttonRestart1, buttonRestart2;
|
||||||
|
|
||||||
|
private bool restart1 = false, restart2 = false;
|
||||||
|
|
||||||
|
public void ButtonRestart1()
|
||||||
|
{
|
||||||
|
restart1 = !restart1;
|
||||||
|
if (restart1)
|
||||||
|
{
|
||||||
|
buttonRestart1.GetComponent<Image>().color = new Color(.1f, .5f, .1f, .2f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
buttonRestart1.GetComponent<Image>().color = new Color(.1f, .1f, .1f, .2f);
|
||||||
|
}
|
||||||
|
RestartRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ButtonRestart2()
|
||||||
|
{
|
||||||
|
restart2 = !restart2;
|
||||||
|
if (restart2)
|
||||||
|
{
|
||||||
|
buttonRestart2.GetComponent<Image>().color = new Color(.1f, .5f, .1f, .2f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
buttonRestart2.GetComponent<Image>().color = new Color(.1f, .1f, .1f, .2f);
|
||||||
|
}
|
||||||
|
RestartRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RestartRequest()
|
||||||
|
{
|
||||||
|
if (restart1 && restart2)
|
||||||
|
{
|
||||||
|
SceneManager.LoadScene(0, LoadSceneMode.Single);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 65b66293cc480be4e8c0ff3534cf4834
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -4,5 +4,5 @@ using UnityEngine;
|
|||||||
|
|
||||||
public class Cell : MonoBehaviour
|
public class Cell : MonoBehaviour
|
||||||
{
|
{
|
||||||
public GameObject connected;
|
public Character connected;
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public abstract class Character : MonoBehaviour
|
||||||
|
{
|
||||||
|
public Teams team;
|
||||||
|
|
||||||
|
public abstract bool[,] GetValidMoves(Cell[,] cells, Game game);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Teams
|
||||||
|
{
|
||||||
|
White, Black
|
||||||
|
}
|
||||||
@@ -0,0 +1,333 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class Game : MonoBehaviour
|
||||||
|
{
|
||||||
|
public Camera cam;
|
||||||
|
|
||||||
|
private Cell[,] cells = new Cell[8, 8];
|
||||||
|
private Cell[] killedCharacCellsWhite = new Cell[16];
|
||||||
|
private int indexKilledCharacCellWhite = 0, indexKilledCharacCellBlack = 0;
|
||||||
|
private Cell[] killedCharacCellsBlack = new Cell[16];
|
||||||
|
public Teams currentTeam = Teams.White;
|
||||||
|
private bool areKilledCellsActive = false;
|
||||||
|
|
||||||
|
private Cell clickedCell = null;
|
||||||
|
private List<Cell> validMovesList = new List<Cell>();
|
||||||
|
public bool isPaused = false;
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
//Get all the Cells from the hierachy
|
||||||
|
for (int x = 0; x < 8; x++)
|
||||||
|
{
|
||||||
|
for (int y = 0; y < 8; y++)
|
||||||
|
{
|
||||||
|
cells[x, y] = GameObject.Find("Field" + y + "," + x).gameObject.GetComponent<Cell>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 16; i++)
|
||||||
|
{
|
||||||
|
killedCharacCellsWhite[i] = GameObject.Find("AddCell" + i).gameObject.GetComponent<Cell>();
|
||||||
|
killedCharacCellsBlack[i] = GameObject.Find("AddCell" + i + " (1)").gameObject.GetComponent<Cell>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
if (!isPaused)
|
||||||
|
{
|
||||||
|
//Check if left clicked
|
||||||
|
if (Input.GetMouseButtonDown(0))
|
||||||
|
{
|
||||||
|
if(areKilledCellsActive && (currentTeam == Teams.White && indexKilledCharacCellWhite == 0 || currentTeam == Teams.Black && indexKilledCharacCellBlack == 0) )
|
||||||
|
{
|
||||||
|
areKilledCellsActive = false;
|
||||||
|
DeColorAllCells();
|
||||||
|
if (currentTeam == Teams.White)
|
||||||
|
{
|
||||||
|
currentTeam = Teams.Black;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
currentTeam = Teams.White;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get the clicked cell
|
||||||
|
Cell tempCell = GetCellOnPositionMouse(Input.mousePosition);
|
||||||
|
|
||||||
|
//check the clicked cell is valid
|
||||||
|
if (tempCell != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
//check if player has the possibilty to revive a character and kill his pawn
|
||||||
|
if (areKilledCellsActive)
|
||||||
|
{
|
||||||
|
//destroy the pawn
|
||||||
|
Destroy(clickedCell.connected.gameObject);
|
||||||
|
//connect the revived character to the pawns field
|
||||||
|
clickedCell.connected = tempCell.connected;
|
||||||
|
clickedCell.connected.gameObject.transform.position =
|
||||||
|
clickedCell.gameObject.transform.position + Vector3.back;
|
||||||
|
//change the team
|
||||||
|
if (currentTeam == Teams.White)
|
||||||
|
{
|
||||||
|
currentTeam = Teams.Black;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
currentTeam = Teams.White;
|
||||||
|
}
|
||||||
|
|
||||||
|
areKilledCellsActive = false;
|
||||||
|
DeColorAllCells();
|
||||||
|
clickedCell = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//check if clicked cell is "a green field"
|
||||||
|
if (validMovesList.Contains(tempCell))
|
||||||
|
{
|
||||||
|
//check if there's a others color character on the cell
|
||||||
|
if (tempCell.connected != null)
|
||||||
|
{
|
||||||
|
if (tempCell.connected.team == Teams.White)
|
||||||
|
{
|
||||||
|
//remove the character from the game field
|
||||||
|
|
||||||
|
tempCell.connected.gameObject.transform.position =
|
||||||
|
killedCharacCellsWhite[indexKilledCharacCellWhite].gameObject.transform
|
||||||
|
.position +
|
||||||
|
Vector3.back;
|
||||||
|
killedCharacCellsWhite[indexKilledCharacCellWhite].connected = tempCell.connected;
|
||||||
|
indexKilledCharacCellWhite++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tempCell.connected.gameObject.transform.position =
|
||||||
|
killedCharacCellsBlack[indexKilledCharacCellBlack].gameObject.transform
|
||||||
|
.position +
|
||||||
|
Vector3.back;
|
||||||
|
killedCharacCellsBlack[indexKilledCharacCellBlack].connected = tempCell.connected;
|
||||||
|
indexKilledCharacCellBlack++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tempCell.connected = clickedCell.connected;
|
||||||
|
tempCell.connected.gameObject.transform.position =
|
||||||
|
tempCell.gameObject.transform.position + Vector3.back;
|
||||||
|
if (tempCell.connected.GetComponent<Pawn>() != null)
|
||||||
|
{
|
||||||
|
Pawn testPawn = tempCell.connected.GetComponent<Pawn>();
|
||||||
|
|
||||||
|
int endCellY;
|
||||||
|
|
||||||
|
if (testPawn.team == Teams.White)
|
||||||
|
{
|
||||||
|
endCellY = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
endCellY = 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
int x, y;
|
||||||
|
|
||||||
|
string nameX = tempCell.gameObject.name.Substring(7, 1);
|
||||||
|
string nameY = tempCell.gameObject.name.Substring(5, 1);
|
||||||
|
|
||||||
|
x = int.Parse(nameX);
|
||||||
|
y = int.Parse(nameY);
|
||||||
|
|
||||||
|
if (y == endCellY)
|
||||||
|
{
|
||||||
|
areKilledCellsActive = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
clickedCell.connected = null;
|
||||||
|
DeColorAllCells();
|
||||||
|
validMovesList.Clear();
|
||||||
|
|
||||||
|
if (!areKilledCellsActive)
|
||||||
|
{
|
||||||
|
if (currentTeam == Teams.White)
|
||||||
|
{
|
||||||
|
currentTeam = Teams.Black;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
currentTeam = Teams.White;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//if the clickedCell == tempCell, deselect the cell
|
||||||
|
if (clickedCell == tempCell)
|
||||||
|
{
|
||||||
|
clickedCell = null;
|
||||||
|
DeColorAllCells();
|
||||||
|
validMovesList.Clear();
|
||||||
|
}
|
||||||
|
//else select the cell
|
||||||
|
else
|
||||||
|
{
|
||||||
|
clickedCell = tempCell;
|
||||||
|
ColorCellExclusive(clickedCell, new Color(.5f, .1f, .1f));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//check if there is a clicked cell
|
||||||
|
if (clickedCell != null)
|
||||||
|
{
|
||||||
|
//check if any character is on the cell
|
||||||
|
if (clickedCell.connected != null)
|
||||||
|
{
|
||||||
|
//check if the character belongs to the curren team
|
||||||
|
if (clickedCell.connected.team == currentTeam)
|
||||||
|
{
|
||||||
|
//get all the valid moves from the character based on the current grid
|
||||||
|
bool[,] validMoves = clickedCell.connected.GetValidMoves(cells, this);
|
||||||
|
for (int x = 0; x < 8; x++)
|
||||||
|
{
|
||||||
|
for (int y = 0; y < 8; y++)
|
||||||
|
{
|
||||||
|
if (validMoves[y, x])
|
||||||
|
{
|
||||||
|
if (cells[x, y].connected != null)
|
||||||
|
{
|
||||||
|
ColorCell(x, y, new Color(.6f, .4f, .2f));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ColorCell(x, y, new Color(.1f, .5f, .1f));
|
||||||
|
}
|
||||||
|
|
||||||
|
validMovesList.Add(cells[x, y]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Reset all colors of the cells
|
||||||
|
private void DeColorAllCells()
|
||||||
|
{
|
||||||
|
for (int ix = 0; ix < 8; ix++)
|
||||||
|
{
|
||||||
|
for (int iy = 0; iy < 8; iy++)
|
||||||
|
{
|
||||||
|
ColorCell(ix, iy, Color.white);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Color the selected cell and deColor all others
|
||||||
|
private void ColorCellExclusive(Cell cell, Color color)
|
||||||
|
{
|
||||||
|
int x = 0, y = 0;
|
||||||
|
|
||||||
|
for (int ix = 0; ix < 8; ix++)
|
||||||
|
{
|
||||||
|
for (int iy = 0; iy < 8; iy++)
|
||||||
|
{
|
||||||
|
if (cells[ix, iy] == cell)
|
||||||
|
{
|
||||||
|
x = ix;
|
||||||
|
y = iy;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ColorCellExclusive(x, y, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Color the selected cell and deColor all others
|
||||||
|
private void ColorCellExclusive(int x, int y, Color color)
|
||||||
|
{
|
||||||
|
for (int ix = 0; ix < 8; ix++)
|
||||||
|
{
|
||||||
|
for (int iy = 0; iy < 8; iy++)
|
||||||
|
{
|
||||||
|
if (ix == x && iy == y)
|
||||||
|
{
|
||||||
|
ColorCell(ix, iy, color);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ColorCell(ix, iy, Color.white);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Color the selected cell in the given color
|
||||||
|
private void ColorCell(int x, int y, Color color)
|
||||||
|
{
|
||||||
|
cells[x, y].GetComponent<SpriteRenderer>().color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get the currently clicked cell
|
||||||
|
public Cell GetCellOnPositionMouse(Vector3 position)
|
||||||
|
{
|
||||||
|
return GetCellOnPosition(cam.ScreenToWorldPoint(position));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Cell GetCellOnPosition(Vector3 position)
|
||||||
|
{
|
||||||
|
Cell result = null;
|
||||||
|
|
||||||
|
//Shoot a raycast from mousePointer / touch position
|
||||||
|
RaycastHit2D hit = Physics2D.Raycast(position, Vector3.forward);
|
||||||
|
if (hit.collider != null)
|
||||||
|
{
|
||||||
|
if (ArrayContainsCell2D(hit.collider.gameObject.GetComponent<Cell>(), cells) && !areKilledCellsActive||
|
||||||
|
areKilledCellsActive && ArrayContainsCell1D(hit.collider.gameObject.GetComponent<Cell>(), killedCharacCellsWhite) ||
|
||||||
|
areKilledCellsActive && ArrayContainsCell1D(hit.collider.gameObject.GetComponent<Cell>(), killedCharacCellsBlack))
|
||||||
|
{
|
||||||
|
result = hit.collider.gameObject.GetComponent<Cell>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private bool ArrayContainsCell2D(Cell cell, Cell[,] cells)
|
||||||
|
{
|
||||||
|
for (int x = 0; x < cells.GetLength(0); x++)
|
||||||
|
{
|
||||||
|
for (int y = 0; y < cells.GetLength(1); y++)
|
||||||
|
{
|
||||||
|
if (cells[x, y] == cell)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool ArrayContainsCell1D(Cell cell, Cell[] cells)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < cells.Length; i++)
|
||||||
|
{
|
||||||
|
if (cells[i] == cell)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class King : Character
|
||||||
|
{
|
||||||
|
public static readonly Vector2[] moves =
|
||||||
|
{
|
||||||
|
//up
|
||||||
|
new Vector2(0, 1),
|
||||||
|
//down
|
||||||
|
new Vector2(0, -1),
|
||||||
|
//right
|
||||||
|
new Vector2(1, 0),
|
||||||
|
//left
|
||||||
|
new Vector2(-1, 0),
|
||||||
|
//up, right
|
||||||
|
new Vector2(1, 1),
|
||||||
|
//up, left
|
||||||
|
new Vector2(-1, 1),
|
||||||
|
//down, right
|
||||||
|
new Vector2(1, -1),
|
||||||
|
//down, left
|
||||||
|
new Vector2(-1, -1)
|
||||||
|
};
|
||||||
|
|
||||||
|
public override bool[,] GetValidMoves(Cell[,] cells, Game game)
|
||||||
|
{
|
||||||
|
bool[,] result = new bool[8, 8];
|
||||||
|
|
||||||
|
foreach (Vector2 move in moves)
|
||||||
|
{
|
||||||
|
Vector3 testPosition = transform.position + (Vector3)move;
|
||||||
|
|
||||||
|
Cell testCell = game.GetCellOnPosition(testPosition + Vector3.back);
|
||||||
|
|
||||||
|
if (testCell != null)
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
|
||||||
|
string nameX = testCell.gameObject.name.Substring(5, 1);
|
||||||
|
string nameY = testCell.gameObject.name.Substring(7, 1);
|
||||||
|
|
||||||
|
x = int.Parse(nameX);
|
||||||
|
y = int.Parse(nameY);
|
||||||
|
|
||||||
|
|
||||||
|
if (testCell.connected == null)
|
||||||
|
{
|
||||||
|
result[x, y] = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Character testCharacter = testCell.connected;
|
||||||
|
if (testCharacter.team != game.currentTeam)
|
||||||
|
{
|
||||||
|
result[x, y] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9fd968408c0465c4bb0d7960a1be6a9b
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class Knight : Character
|
||||||
|
{
|
||||||
|
private static readonly Vector2[] moves =
|
||||||
|
{
|
||||||
|
//(2, 1 combinations)
|
||||||
|
//up
|
||||||
|
new Vector2(-1, 2),
|
||||||
|
new Vector2(1, 2),
|
||||||
|
//down
|
||||||
|
new Vector2(-1, -2),
|
||||||
|
new Vector2(1, -2),
|
||||||
|
//right
|
||||||
|
new Vector2(2, 1),
|
||||||
|
new Vector2(2, -1),
|
||||||
|
//left
|
||||||
|
new Vector2(-2, 1),
|
||||||
|
new Vector2(-2, -1),
|
||||||
|
};
|
||||||
|
|
||||||
|
public override bool[,] GetValidMoves(Cell[,] cells, Game game)
|
||||||
|
{
|
||||||
|
bool[,] result = new bool[8, 8];
|
||||||
|
|
||||||
|
foreach (Vector2 move in moves)
|
||||||
|
{
|
||||||
|
Vector3 testPosition = transform.position + (Vector3)move;
|
||||||
|
|
||||||
|
Cell testCell = game.GetCellOnPosition(testPosition + Vector3.back);
|
||||||
|
|
||||||
|
if (testCell != null)
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
|
||||||
|
string nameX = testCell.gameObject.name.Substring(5, 1);
|
||||||
|
string nameY = testCell.gameObject.name.Substring(7, 1);
|
||||||
|
|
||||||
|
x = int.Parse(nameX);
|
||||||
|
y = int.Parse(nameY);
|
||||||
|
|
||||||
|
|
||||||
|
if (testCell.connected == null)
|
||||||
|
{
|
||||||
|
result[x, y] = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Character testCharacter = testCell.connected;
|
||||||
|
if (testCharacter.team != game.currentTeam)
|
||||||
|
{
|
||||||
|
result[x, y] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 413f30f504354374eac5ff0f4a42653d
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class Pawn : Character
|
||||||
|
{
|
||||||
|
public override bool[,] GetValidMoves(Cell[,] cells, Game game)
|
||||||
|
{
|
||||||
|
bool[,] result = new bool[8, 8];
|
||||||
|
|
||||||
|
Vector3 offsetDirection;
|
||||||
|
int yStartPos;
|
||||||
|
|
||||||
|
if (game.currentTeam == Teams.White)
|
||||||
|
{
|
||||||
|
offsetDirection = Vector3.up;
|
||||||
|
yStartPos = 5;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
offsetDirection = Vector3.down;
|
||||||
|
yStartPos = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector3 testPosition = transform.position + offsetDirection;
|
||||||
|
Cell testCell = game.GetCellOnPosition(testPosition);
|
||||||
|
|
||||||
|
if (testCell != null)
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
|
||||||
|
string nameX = testCell.gameObject.name.Substring(5, 1);
|
||||||
|
string nameY = testCell.gameObject.name.Substring(7, 1);
|
||||||
|
|
||||||
|
x = int.Parse(nameX);
|
||||||
|
y = int.Parse(nameY);
|
||||||
|
|
||||||
|
if (testCell.connected == null)
|
||||||
|
{
|
||||||
|
result[x, y] = true;
|
||||||
|
|
||||||
|
if (x == yStartPos)
|
||||||
|
{
|
||||||
|
testPosition = transform.position + offsetDirection * 2;
|
||||||
|
testCell = game.GetCellOnPosition(testPosition);
|
||||||
|
|
||||||
|
if (testCell != null)
|
||||||
|
{
|
||||||
|
nameX = testCell.gameObject.name.Substring(5, 1);
|
||||||
|
nameY = testCell.gameObject.name.Substring(7, 1);
|
||||||
|
|
||||||
|
x = int.Parse(nameX);
|
||||||
|
y = int.Parse(nameY);
|
||||||
|
|
||||||
|
if (testCell.connected == null)
|
||||||
|
{
|
||||||
|
result[x, y] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
testPosition = transform.position + offsetDirection + Vector3.left;
|
||||||
|
testCell = game.GetCellOnPosition(testPosition);
|
||||||
|
|
||||||
|
if (testCell != null)
|
||||||
|
{
|
||||||
|
nameX = testCell.gameObject.name.Substring(5, 1);
|
||||||
|
nameY = testCell.gameObject.name.Substring(7, 1);
|
||||||
|
|
||||||
|
x = int.Parse(nameX);
|
||||||
|
y = int.Parse(nameY);
|
||||||
|
|
||||||
|
if (testCell.connected != null)
|
||||||
|
{
|
||||||
|
if(testCell.connected.team != game.currentTeam)
|
||||||
|
{
|
||||||
|
result[x, y] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
testPosition = transform.position + offsetDirection + Vector3.right;
|
||||||
|
testCell = game.GetCellOnPosition(testPosition);
|
||||||
|
|
||||||
|
if (testCell != null)
|
||||||
|
{
|
||||||
|
nameX = testCell.gameObject.name.Substring(5, 1);
|
||||||
|
nameY = testCell.gameObject.name.Substring(7, 1);
|
||||||
|
|
||||||
|
x = int.Parse(nameX);
|
||||||
|
y = int.Parse(nameY);
|
||||||
|
|
||||||
|
if (testCell.connected != null)
|
||||||
|
{
|
||||||
|
if(testCell.connected.team != game.currentTeam)
|
||||||
|
{
|
||||||
|
result[x, y] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 451b5186406195f4c87dd2a0934390db
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,154 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class Queen : Character
|
||||||
|
{
|
||||||
|
public static readonly Vector2[,] moves =
|
||||||
|
{
|
||||||
|
{
|
||||||
|
//up
|
||||||
|
new Vector2(0, 1),
|
||||||
|
new Vector2(0, 2),
|
||||||
|
new Vector2(0, 3),
|
||||||
|
new Vector2(0, 4),
|
||||||
|
new Vector2(0, 5),
|
||||||
|
new Vector2(0, 6),
|
||||||
|
new Vector2(0, 7),
|
||||||
|
new Vector2(0, 8.5f), //.5 because of calculation error in game ^^
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
//down
|
||||||
|
new Vector2(0, -1),
|
||||||
|
new Vector2(0, -2),
|
||||||
|
new Vector2(0, -3),
|
||||||
|
new Vector2(0, -4),
|
||||||
|
new Vector2(0, -5),
|
||||||
|
new Vector2(0, -6),
|
||||||
|
new Vector2(0, -7),
|
||||||
|
new Vector2(0, -8.5f),
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
//right
|
||||||
|
new Vector2(1, 0),
|
||||||
|
new Vector2(2, 0),
|
||||||
|
new Vector2(3, 0),
|
||||||
|
new Vector2(4, 0),
|
||||||
|
new Vector2(5, 0),
|
||||||
|
new Vector2(6, 0),
|
||||||
|
new Vector2(7, 0),
|
||||||
|
new Vector2(8.5f, 0)
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
//left
|
||||||
|
new Vector2(-1, 0),
|
||||||
|
new Vector2(-2, 0),
|
||||||
|
new Vector2(-3, 0),
|
||||||
|
new Vector2(-4, 0),
|
||||||
|
new Vector2(-5, 0),
|
||||||
|
new Vector2(-6, 0),
|
||||||
|
new Vector2(-7, 0),
|
||||||
|
new Vector2(-8.5f, 0)
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
//up, right
|
||||||
|
new Vector2(1, 1),
|
||||||
|
new Vector2(2, 2),
|
||||||
|
new Vector2(3, 3),
|
||||||
|
new Vector2(4, 4),
|
||||||
|
new Vector2(5, 5),
|
||||||
|
new Vector2(6, 6),
|
||||||
|
new Vector2(7, 7),
|
||||||
|
new Vector2(8.5f, 8.5f),
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
//up, left
|
||||||
|
new Vector2(-1, 1),
|
||||||
|
new Vector2(-2, 2),
|
||||||
|
new Vector2(-3, 3),
|
||||||
|
new Vector2(-4, 4),
|
||||||
|
new Vector2(-5, 5),
|
||||||
|
new Vector2(-6, 6),
|
||||||
|
new Vector2(-7, 7),
|
||||||
|
new Vector2(-8.5f, 8.5f),
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
//down, right
|
||||||
|
new Vector2(1, -1),
|
||||||
|
new Vector2(2, -2),
|
||||||
|
new Vector2(3, -3),
|
||||||
|
new Vector2(4, -4),
|
||||||
|
new Vector2(5, -5),
|
||||||
|
new Vector2(6, -6),
|
||||||
|
new Vector2(7, -7),
|
||||||
|
new Vector2(8.5f, -8.5f),
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
//down, left
|
||||||
|
new Vector2(-1, -1),
|
||||||
|
new Vector2(-2, -2),
|
||||||
|
new Vector2(-3, -3),
|
||||||
|
new Vector2(-4, -4),
|
||||||
|
new Vector2(-5, -5),
|
||||||
|
new Vector2(-6, -6),
|
||||||
|
new Vector2(-7, -7),
|
||||||
|
new Vector2(-8.5f, -8.5f),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public override bool[,] GetValidMoves(Cell[,] cells, Game game)
|
||||||
|
{
|
||||||
|
bool[,] result = new bool[8, 8];
|
||||||
|
|
||||||
|
for (int i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < 8; j++)
|
||||||
|
{
|
||||||
|
Vector3 testPosition = transform.position + (Vector3)moves[i, j];
|
||||||
|
Cell testCell = game.GetCellOnPosition(testPosition);
|
||||||
|
|
||||||
|
if(testCell != null)
|
||||||
|
{
|
||||||
|
if (testCell.connected == null)
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
|
||||||
|
string nameX = testCell.gameObject.name.Substring(5, 1);
|
||||||
|
string nameY = testCell.gameObject.name.Substring(7, 1);
|
||||||
|
|
||||||
|
x = int.Parse(nameX);
|
||||||
|
y = int.Parse(nameY);
|
||||||
|
|
||||||
|
result[x, y] = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (testCell.connected.team != game.currentTeam)
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
|
||||||
|
string nameX = testCell.gameObject.name.Substring(5, 1);
|
||||||
|
string nameY = testCell.gameObject.name.Substring(7, 1);
|
||||||
|
|
||||||
|
x = int.Parse(nameX);
|
||||||
|
y = int.Parse(nameY);
|
||||||
|
|
||||||
|
result[x, y] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
j = 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4ecf79ff7b31c234f89070f40365082e
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class Rook : Character
|
||||||
|
{
|
||||||
|
private static readonly Vector2[,] moves =
|
||||||
|
{
|
||||||
|
{
|
||||||
|
//up
|
||||||
|
new Vector2(0, 1),
|
||||||
|
new Vector2(0, 2),
|
||||||
|
new Vector2(0, 3),
|
||||||
|
new Vector2(0, 4),
|
||||||
|
new Vector2(0, 5),
|
||||||
|
new Vector2(0, 6),
|
||||||
|
new Vector2(0, 7),
|
||||||
|
new Vector2(0, 8.5f), //.5 because of calculation error in game ^^
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
//down
|
||||||
|
new Vector2(0, -1),
|
||||||
|
new Vector2(0, -2),
|
||||||
|
new Vector2(0, -3),
|
||||||
|
new Vector2(0, -4),
|
||||||
|
new Vector2(0, -5),
|
||||||
|
new Vector2(0, -6),
|
||||||
|
new Vector2(0, -7),
|
||||||
|
new Vector2(0, -8.5f),
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
//right
|
||||||
|
new Vector2(1, 0),
|
||||||
|
new Vector2(2, 0),
|
||||||
|
new Vector2(3, 0),
|
||||||
|
new Vector2(4, 0),
|
||||||
|
new Vector2(5, 0),
|
||||||
|
new Vector2(6, 0),
|
||||||
|
new Vector2(7, 0),
|
||||||
|
new Vector2(8.5f, 0)
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
//left
|
||||||
|
new Vector2(-1, 0),
|
||||||
|
new Vector2(-2, 0),
|
||||||
|
new Vector2(-3, 0),
|
||||||
|
new Vector2(-4, 0),
|
||||||
|
new Vector2(-5, 0),
|
||||||
|
new Vector2(-6, 0),
|
||||||
|
new Vector2(-7, 0),
|
||||||
|
new Vector2(-8.5f, 0)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public override bool[,] GetValidMoves(Cell[,] cells, Game game)
|
||||||
|
{
|
||||||
|
bool[,] result = new bool[8, 8];
|
||||||
|
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < 8; j++)
|
||||||
|
{
|
||||||
|
Vector3 testPosition = transform.position + (Vector3)moves[i, j];
|
||||||
|
Cell testCell = game.GetCellOnPosition(testPosition);
|
||||||
|
|
||||||
|
if(testCell != null)
|
||||||
|
{
|
||||||
|
if (testCell.connected == null)
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
|
||||||
|
string nameX = testCell.gameObject.name.Substring(5, 1);
|
||||||
|
string nameY = testCell.gameObject.name.Substring(7, 1);
|
||||||
|
|
||||||
|
x = int.Parse(nameX);
|
||||||
|
y = int.Parse(nameY);
|
||||||
|
|
||||||
|
result[x, y] = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (testCell.connected.team != game.currentTeam)
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
|
||||||
|
string nameX = testCell.gameObject.name.Substring(5, 1);
|
||||||
|
string nameY = testCell.gameObject.name.Substring(7, 1);
|
||||||
|
|
||||||
|
x = int.Parse(nameX);
|
||||||
|
y = int.Parse(nameY);
|
||||||
|
|
||||||
|
result[x, y] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
j = 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e472b40b9823e414690354398c441ee1
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
Base path: 'C:/Program Files/Unity/Hub/Editor/2021.1.13f1/Editor/Data', plugins path 'C:/Program Files/Unity/Hub/Editor/2021.1.13f1/Editor/Data/PlaybackEngines'
|
||||||
|
Cmd: initializeCompiler
|
||||||
|
|
||||||
|
Unhandled exception: Protocol error - failed to read magic number (error -2147483644, transferred 0/4)
|
||||||
|
|
||||||
|
Quitting shader compiler process
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
Base path: 'C:/Program Files/Unity/Hub/Editor/2021.1.13f1/Editor/Data', plugins path 'C:/Program Files/Unity/Hub/Editor/2021.1.13f1/Editor/Data/PlaybackEngines'
|
Base path: 'C:/Program Files/Unity/Hub/Editor/2021.1.13f1/Editor/Data', plugins path 'C:/Program Files/Unity/Hub/Editor/2021.1.13f1/Editor/Data/PlaybackEngines'
|
||||||
Cmd: initializeCompiler
|
Cmd: initializeCompiler
|
||||||
|
|
||||||
Cmd: shutdown
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
Base path: 'C:/Program Files/Unity/Hub/Editor/2021.1.13f1/Editor/Data', plugins path 'C:/Program Files/Unity/Hub/Editor/2021.1.13f1/Editor/Data/PlaybackEngines'
|
||||||
|
Cmd: initializeCompiler
|
||||||
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
Base path: 'C:/Program Files/Unity/Hub/Editor/2021.1.13f1/Editor/Data', plugins path 'C:/Program Files/Unity/Hub/Editor/2021.1.13f1/Editor/Data/PlaybackEngines'
|
||||||
|
Cmd: initializeCompiler
|
||||||
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
Base path: 'C:/Program Files/Unity/Hub/Editor/2021.1.13f1/Editor/Data', plugins path 'C:/Program Files/Unity/Hub/Editor/2021.1.13f1/Editor/Data/PlaybackEngines'
|
||||||
|
Cmd: initializeCompiler
|
||||||
|
|
||||||
@@ -8,7 +8,7 @@ PlayerSettings:
|
|||||||
AndroidProfiler: 0
|
AndroidProfiler: 0
|
||||||
AndroidFilterTouchesWhenObscured: 0
|
AndroidFilterTouchesWhenObscured: 0
|
||||||
AndroidEnableSustainedPerformanceMode: 0
|
AndroidEnableSustainedPerformanceMode: 0
|
||||||
defaultScreenOrientation: 4
|
defaultScreenOrientation: 2
|
||||||
targetDevice: 2
|
targetDevice: 2
|
||||||
useOnDemandResources: 0
|
useOnDemandResources: 0
|
||||||
accelerometerFrequency: 60
|
accelerometerFrequency: 60
|
||||||