Board development complete.
This commit is contained in:
parent
13243ff54d
commit
1c02e728a0
29 changed files with 799 additions and 139 deletions
39
Angels and Demons/.vscode/launch.json
vendored
Normal file
39
Angels and Demons/.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
|
||||
{
|
||||
"name": "Unity Editor",
|
||||
"type": "unity",
|
||||
"request": "launch"
|
||||
},
|
||||
{
|
||||
"name": "Windows Player",
|
||||
"type": "unity",
|
||||
"request": "launch"
|
||||
},
|
||||
{
|
||||
"name": "OSX Player",
|
||||
"type": "unity",
|
||||
"request": "launch"
|
||||
},
|
||||
{
|
||||
"name": "Linux Player",
|
||||
"type": "unity",
|
||||
"request": "launch"
|
||||
},
|
||||
{
|
||||
"name": "iOS Player",
|
||||
"type": "unity",
|
||||
"request": "launch"
|
||||
},
|
||||
{
|
||||
"name": "Android Player",
|
||||
"type": "unity",
|
||||
"request": "launch"
|
||||
}
|
||||
]
|
||||
}
|
56
Angels and Demons/.vscode/settings.json
vendored
Normal file
56
Angels and Demons/.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
{
|
||||
"files.exclude":
|
||||
{
|
||||
"**/.DS_Store":true,
|
||||
"**/.git":true,
|
||||
"**/.gitignore":true,
|
||||
"**/.gitmodules":true,
|
||||
"**/*.booproj":true,
|
||||
"**/*.pidb":true,
|
||||
"**/*.suo":true,
|
||||
"**/*.user":true,
|
||||
"**/*.userprefs":true,
|
||||
"**/*.unityproj":true,
|
||||
"**/*.dll":true,
|
||||
"**/*.exe":true,
|
||||
"**/*.pdf":true,
|
||||
"**/*.mid":true,
|
||||
"**/*.midi":true,
|
||||
"**/*.wav":true,
|
||||
"**/*.gif":true,
|
||||
"**/*.ico":true,
|
||||
"**/*.jpg":true,
|
||||
"**/*.jpeg":true,
|
||||
"**/*.png":true,
|
||||
"**/*.psd":true,
|
||||
"**/*.tga":true,
|
||||
"**/*.tif":true,
|
||||
"**/*.tiff":true,
|
||||
"**/*.3ds":true,
|
||||
"**/*.3DS":true,
|
||||
"**/*.fbx":true,
|
||||
"**/*.FBX":true,
|
||||
"**/*.lxo":true,
|
||||
"**/*.LXO":true,
|
||||
"**/*.ma":true,
|
||||
"**/*.MA":true,
|
||||
"**/*.obj":true,
|
||||
"**/*.OBJ":true,
|
||||
"**/*.asset":true,
|
||||
"**/*.cubemap":true,
|
||||
"**/*.flare":true,
|
||||
"**/*.mat":true,
|
||||
"**/*.meta":true,
|
||||
"**/*.prefab":true,
|
||||
"**/*.unity":true,
|
||||
"build/":true,
|
||||
"Build/":true,
|
||||
"Library/":true,
|
||||
"library/":true,
|
||||
"obj/":true,
|
||||
"Obj/":true,
|
||||
"ProjectSettings/":true,
|
||||
"temp/":true,
|
||||
"Temp/":true
|
||||
}
|
||||
}
|
|
@ -1,20 +1,19 @@
|
|||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor.SceneManagement;
|
||||
|
||||
namespace GitMerge
|
||||
{
|
||||
namespace GitMerge {
|
||||
/// <summary>
|
||||
/// The window that lets you perform merges on scenes and prefabs.
|
||||
/// </summary>
|
||||
public class GitMergeWindow : EditorWindow
|
||||
{
|
||||
private VCS vcs = new VCSGit();
|
||||
public class GitMergeWindow : EditorWindow {
|
||||
private VCS vcs = new VCSGit ();
|
||||
|
||||
//EditorPrefs keys for settings
|
||||
private const string epAutomerge = "GitMerge_automerge";
|
||||
private const string epAutofocus = "GitMerge_autofocus";
|
||||
|
||||
|
||||
//Settings
|
||||
public static bool automerge { private set; get; }
|
||||
public static bool autofocus { private set; get; }
|
||||
|
@ -22,10 +21,8 @@ namespace GitMerge
|
|||
//The MergeManager that has the actual merging logic
|
||||
private MergeManager manager;
|
||||
|
||||
public bool mergeInProgress
|
||||
{
|
||||
get
|
||||
{
|
||||
public bool mergeInProgress {
|
||||
get {
|
||||
return manager != null;
|
||||
}
|
||||
}
|
||||
|
@ -33,83 +30,67 @@ namespace GitMerge
|
|||
private Vector2 scrollPosition = Vector2.zero;
|
||||
private int tab = 0;
|
||||
|
||||
|
||||
[MenuItem("Window/GitMerge")]
|
||||
static void OpenEditor()
|
||||
{
|
||||
var window = EditorWindow.GetWindow(typeof(GitMergeWindow), false, "GitMerge");
|
||||
[MenuItem ("Window/GitMerge")]
|
||||
static void OpenEditor () {
|
||||
var window = EditorWindow.GetWindow (typeof (GitMergeWindow), false, "GitMerge");
|
||||
//In case we're merging and the scene becomes edited,
|
||||
//the shown SerializedProperties should be repainted
|
||||
window.autoRepaintOnSceneChange = true;
|
||||
window.minSize = new Vector2(500, 100);
|
||||
window.minSize = new Vector2 (500, 100);
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
LoadSettings();
|
||||
void OnEnable () {
|
||||
LoadSettings ();
|
||||
}
|
||||
|
||||
private static void LoadSettings()
|
||||
{
|
||||
if(EditorPrefs.HasKey(epAutomerge))
|
||||
{
|
||||
automerge = EditorPrefs.GetBool(epAutomerge);
|
||||
}
|
||||
else
|
||||
{
|
||||
private static void LoadSettings () {
|
||||
if (EditorPrefs.HasKey (epAutomerge)) {
|
||||
automerge = EditorPrefs.GetBool (epAutomerge);
|
||||
} else {
|
||||
automerge = true;
|
||||
}
|
||||
if(EditorPrefs.HasKey(epAutofocus))
|
||||
{
|
||||
autofocus = EditorPrefs.GetBool(epAutofocus);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (EditorPrefs.HasKey (epAutofocus)) {
|
||||
autofocus = EditorPrefs.GetBool (epAutofocus);
|
||||
} else {
|
||||
autofocus = true;
|
||||
}
|
||||
}
|
||||
|
||||
void OnHierarchyChange()
|
||||
{
|
||||
void OnHierarchyChange () {
|
||||
//Repaint if we changed the scene
|
||||
this.Repaint();
|
||||
this.Repaint ();
|
||||
}
|
||||
|
||||
//Always check for editor state changes, and abort the active merge process if needed
|
||||
void Update()
|
||||
{
|
||||
if(MergeAction.inMergePhase
|
||||
&& (EditorApplication.isCompiling
|
||||
|| EditorApplication.isPlayingOrWillChangePlaymode))
|
||||
{
|
||||
ShowNotification(new GUIContent("Aborting merge due to editor state change."));
|
||||
AbortMerge();
|
||||
void Update () {
|
||||
if (MergeAction.inMergePhase &&
|
||||
(EditorApplication.isCompiling ||
|
||||
EditorApplication.isPlayingOrWillChangePlaymode)) {
|
||||
ShowNotification (new GUIContent ("Aborting merge due to editor state change."));
|
||||
AbortMerge ();
|
||||
}
|
||||
}
|
||||
|
||||
private void AbortMerge()
|
||||
{
|
||||
manager.AbortMerge();
|
||||
private void AbortMerge () {
|
||||
manager.AbortMerge ();
|
||||
manager = null;
|
||||
}
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
Resources.DrawLogo();
|
||||
DrawTabButtons();
|
||||
void OnGUI () {
|
||||
Resources.DrawLogo ();
|
||||
DrawTabButtons ();
|
||||
|
||||
switch(tab)
|
||||
{
|
||||
switch (tab) {
|
||||
case 0:
|
||||
OnGUISceneTab();
|
||||
OnGUISceneTab ();
|
||||
break;
|
||||
|
||||
case 1:
|
||||
OnGUIPrefabTab();
|
||||
OnGUIPrefabTab ();
|
||||
break;
|
||||
|
||||
default:
|
||||
OnGUISettingsTab();
|
||||
OnGUISettingsTab ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -117,91 +98,75 @@ namespace GitMerge
|
|||
/// <summary>
|
||||
/// Tab that offers scene merging.
|
||||
/// </summary>
|
||||
private void OnGUISceneTab()
|
||||
{
|
||||
GUILayout.Label("Open Scene: " + EditorApplication.currentScene);
|
||||
if(EditorApplication.currentScene != ""
|
||||
&& !mergeInProgress
|
||||
&& GUILayout.Button("Start merging this scene", GUILayout.Height(80)))
|
||||
{
|
||||
var mm = new MergeManagerScene(this, vcs);
|
||||
if(mm.InitializeMerge())
|
||||
{
|
||||
private void OnGUISceneTab () {
|
||||
GUILayout.Label ("Open Scene: " + EditorSceneManager.GetActiveScene().ToString());
|
||||
if (EditorSceneManager.GetActiveScene().ToString() != "" &&
|
||||
!mergeInProgress &&
|
||||
GUILayout.Button ("Start merging this scene", GUILayout.Height (80))) {
|
||||
var mm = new MergeManagerScene (this, vcs);
|
||||
if (mm.InitializeMerge ()) {
|
||||
manager = mm;
|
||||
}
|
||||
}
|
||||
|
||||
DisplayMergeProcess();
|
||||
DisplayMergeProcess ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tab that offers prefab merging.
|
||||
/// </summary>
|
||||
private void OnGUIPrefabTab()
|
||||
{
|
||||
private void OnGUIPrefabTab () {
|
||||
GameObject prefab;
|
||||
if(!mergeInProgress)
|
||||
{
|
||||
GUILayout.Label("Drag your prefab here to start merging:");
|
||||
if(prefab = EditorGUILayout.ObjectField(null, typeof(GameObject), false, GUILayout.Height(60)) as GameObject)
|
||||
{
|
||||
var mm = new MergeManagerPrefab(this, vcs);
|
||||
if(mm.InitializeMerge(prefab))
|
||||
{
|
||||
if (!mergeInProgress) {
|
||||
GUILayout.Label ("Drag your prefab here to start merging:");
|
||||
if (prefab = EditorGUILayout.ObjectField (null, typeof (GameObject), false, GUILayout.Height (60)) as GameObject) {
|
||||
var mm = new MergeManagerPrefab (this, vcs);
|
||||
if (mm.InitializeMerge (prefab)) {
|
||||
manager = mm;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DisplayMergeProcess();
|
||||
DisplayMergeProcess ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tab that offers various settings for the tool.
|
||||
/// </summary>
|
||||
private void OnGUISettingsTab()
|
||||
{
|
||||
var vcsPath = vcs.exe();
|
||||
var vcsPathNew = EditorGUILayout.TextField("Path to git.exe", vcsPath);
|
||||
if(vcsPath != vcsPathNew)
|
||||
{
|
||||
vcs.SetPath(vcsPathNew);
|
||||
private void OnGUISettingsTab () {
|
||||
var vcsPath = vcs.exe ();
|
||||
var vcsPathNew = EditorGUILayout.TextField ("Path to git.exe", vcsPath);
|
||||
if (vcsPath != vcsPathNew) {
|
||||
vcs.SetPath (vcsPathNew);
|
||||
}
|
||||
|
||||
var amNew = EditorGUILayout.Toggle("Automerge", automerge);
|
||||
if(automerge != amNew)
|
||||
{
|
||||
var amNew = EditorGUILayout.Toggle ("Automerge", automerge);
|
||||
if (automerge != amNew) {
|
||||
automerge = amNew;
|
||||
EditorPrefs.SetBool(epAutomerge, automerge);
|
||||
EditorPrefs.SetBool (epAutomerge, automerge);
|
||||
}
|
||||
GUILayout.Label("(Automerge new/deleted GameObjects/Components upon merge start)");
|
||||
GUILayout.Label ("(Automerge new/deleted GameObjects/Components upon merge start)");
|
||||
|
||||
var afNew = EditorGUILayout.Toggle("Auto Highlight", autofocus);
|
||||
if(autofocus != afNew)
|
||||
{
|
||||
var afNew = EditorGUILayout.Toggle ("Auto Highlight", autofocus);
|
||||
if (autofocus != afNew) {
|
||||
autofocus = afNew;
|
||||
EditorPrefs.SetBool(epAutofocus, autofocus);
|
||||
EditorPrefs.SetBool (epAutofocus, autofocus);
|
||||
}
|
||||
GUILayout.Label("(Highlight GameObjects when applying a MergeAction to it)");
|
||||
GUILayout.Label ("(Highlight GameObjects when applying a MergeAction to it)");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If no merge is in progress, draws the buttons to switch between tabs.
|
||||
/// Otherwise, draws the "abort merge" button.
|
||||
/// </summary>
|
||||
private void DrawTabButtons()
|
||||
{
|
||||
if(!mergeInProgress)
|
||||
{
|
||||
private void DrawTabButtons () {
|
||||
if (!mergeInProgress) {
|
||||
string[] tabs = { "Merge Scene", "Merge Prefab", "Settings" };
|
||||
tab = GUI.SelectionGrid(new Rect(72, 36, 300, 22), tab, tabs, 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUI.backgroundColor = new Color(1,0.4f,0.4f,1);
|
||||
if(GUI.Button(new Rect(72, 36, 300, 22), "Abort merge"))
|
||||
{
|
||||
manager.AbortMerge();
|
||||
tab = GUI.SelectionGrid (new Rect (72, 36, 300, 22), tab, tabs, 3);
|
||||
} else {
|
||||
GUI.backgroundColor = new Color (1, 0.4f, 0.4f, 1);
|
||||
if (GUI.Button (new Rect (72, 36, 300, 22), "Abort merge")) {
|
||||
manager.AbortMerge ();
|
||||
manager = null;
|
||||
}
|
||||
GUI.backgroundColor = Color.white;
|
||||
|
@ -211,18 +176,15 @@ namespace GitMerge
|
|||
/// <summary>
|
||||
/// Displays all MergeActions and the "apply merge" button if a merge is in progress.
|
||||
/// </summary>
|
||||
private void DisplayMergeProcess()
|
||||
{
|
||||
if(mergeInProgress)
|
||||
{
|
||||
var done = DisplayMergeActions();
|
||||
GUILayout.BeginHorizontal();
|
||||
if(done && GUILayout.Button("Apply merge"))
|
||||
{
|
||||
manager.CompleteMerge();
|
||||
private void DisplayMergeProcess () {
|
||||
if (mergeInProgress) {
|
||||
var done = DisplayMergeActions ();
|
||||
GUILayout.BeginHorizontal ();
|
||||
if (done && GUILayout.Button ("Apply merge")) {
|
||||
manager.CompleteMerge ();
|
||||
manager = null;
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.EndHorizontal ();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -230,25 +192,23 @@ namespace GitMerge
|
|||
/// Displays all GameObjectMergeActions.
|
||||
/// </summary>
|
||||
/// <returns>True, if all MergeActions are flagged as "merged".</returns>
|
||||
private bool DisplayMergeActions()
|
||||
{
|
||||
scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, true);
|
||||
GUILayout.BeginVertical(GUILayout.MinWidth(480));
|
||||
private bool DisplayMergeActions () {
|
||||
scrollPosition = GUILayout.BeginScrollView (scrollPosition, false, true);
|
||||
GUILayout.BeginVertical (GUILayout.MinWidth (480));
|
||||
|
||||
var textColor = GUI.skin.label.normal.textColor;
|
||||
GUI.skin.label.normal.textColor = Color.black;
|
||||
|
||||
var done = true;
|
||||
foreach(var actions in manager.allMergeActions)
|
||||
{
|
||||
actions.OnGUI();
|
||||
foreach (var actions in manager.allMergeActions) {
|
||||
actions.OnGUI ();
|
||||
done = done && actions.merged;
|
||||
}
|
||||
|
||||
GUI.skin.label.normal.textColor = textColor;
|
||||
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.EndScrollView();
|
||||
GUILayout.EndVertical ();
|
||||
GUILayout.EndScrollView ();
|
||||
return done;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace GitMerge
|
||||
|
@ -21,7 +22,7 @@ namespace GitMerge
|
|||
|
||||
public bool InitializeMerge(GameObject prefab)
|
||||
{
|
||||
if(!EditorApplication.SaveCurrentSceneIfUserWantsTo())
|
||||
if(!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -38,8 +39,8 @@ namespace GitMerge
|
|||
ourPrefab = prefab;
|
||||
|
||||
//Open a new Scene that will only display the prefab
|
||||
previouslyOpenedScene = EditorApplication.currentScene;
|
||||
EditorApplication.NewScene();
|
||||
previouslyOpenedScene = EditorSceneManager.GetActiveScene().ToString();
|
||||
EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects);
|
||||
|
||||
//make the new scene empty
|
||||
Object.DestroyImmediate(Camera.main.gameObject);
|
||||
|
@ -141,7 +142,7 @@ namespace GitMerge
|
|||
{
|
||||
if(!string.IsNullOrEmpty(previouslyOpenedScene))
|
||||
{
|
||||
EditorApplication.OpenScene(previouslyOpenedScene);
|
||||
EditorSceneManager.OpenScene(previouslyOpenedScene);
|
||||
previouslyOpenedScene = "";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace GitMerge
|
||||
|
@ -17,19 +18,19 @@ namespace GitMerge
|
|||
isMergingScene = true;
|
||||
|
||||
//Ask if the scene should be saved, because...
|
||||
if(!EditorApplication.SaveCurrentSceneIfUserWantsTo())
|
||||
if(!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
//...we are reloading it to prevent objects from not having a scene id.
|
||||
EditorApplication.OpenScene(EditorApplication.currentScene);
|
||||
EditorSceneManager.OpenScene(EditorSceneManager.GetActiveScene().ToString());
|
||||
|
||||
MergeAction.inMergePhase = false;
|
||||
|
||||
ObjectDictionaries.Clear();
|
||||
|
||||
//checkout "their" version
|
||||
GetTheirVersionOf(EditorApplication.currentScene);
|
||||
GetTheirVersionOf(EditorSceneManager.GetActiveScene().ToString());
|
||||
AssetDatabase.Refresh();
|
||||
|
||||
//find all of "our" objects
|
||||
|
@ -37,7 +38,7 @@ namespace GitMerge
|
|||
ObjectDictionaries.SetAsOurObjects(ourObjects);
|
||||
|
||||
//add "their" objects
|
||||
EditorApplication.OpenSceneAdditive(theirFilename);
|
||||
EditorSceneManager.OpenScene(theirFilename);
|
||||
|
||||
//delete scene file
|
||||
AssetDatabase.DeleteAsset(theirFilename);
|
||||
|
@ -91,7 +92,7 @@ namespace GitMerge
|
|||
|
||||
ObjectDictionaries.DestroyTheirObjects();
|
||||
ObjectDictionaries.Clear();
|
||||
EditorApplication.SaveScene();
|
||||
EditorSceneManager.SaveOpenScenes();
|
||||
|
||||
allMergeActions = null;
|
||||
|
||||
|
@ -112,7 +113,7 @@ namespace GitMerge
|
|||
base.AbortMerge();
|
||||
|
||||
//Save scene
|
||||
EditorApplication.SaveScene();
|
||||
EditorSceneManager.SaveOpenScenes();
|
||||
}
|
||||
}
|
||||
}
|
BIN
Angels and Demons/Assets/Materials/Angel.mat
Normal file
BIN
Angels and Demons/Assets/Materials/Angel.mat
Normal file
Binary file not shown.
8
Angels and Demons/Assets/Materials/Angel.mat.meta
Normal file
8
Angels and Demons/Assets/Materials/Angel.mat.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 37962f192a2e24b1ab2b8d25958f2e17
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
BIN
Angels and Demons/Assets/Materials/Demon.mat
Normal file
BIN
Angels and Demons/Assets/Materials/Demon.mat
Normal file
Binary file not shown.
8
Angels and Demons/Assets/Materials/Demon.mat.meta
Normal file
8
Angels and Demons/Assets/Materials/Demon.mat.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6ddf6409ba9464744b426077d9f8f194
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Angels and Demons/Assets/Materials/New Material.mat
Normal file
BIN
Angels and Demons/Assets/Materials/New Material.mat
Normal file
Binary file not shown.
8
Angels and Demons/Assets/Materials/New Material.mat.meta
Normal file
8
Angels and Demons/Assets/Materials/New Material.mat.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e0e5fcafbd13a41df84a38ad88cf5d89
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,5 +1,6 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6f41f0233cb7644e4a83e5f5543ed237
|
||||
guid: 5208081e0c9554b408a216e7bbde1f99
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
BIN
Angels and Demons/Assets/Prefabs/Angel.prefab
Normal file
BIN
Angels and Demons/Assets/Prefabs/Angel.prefab
Normal file
Binary file not shown.
8
Angels and Demons/Assets/Prefabs/Angel.prefab.meta
Normal file
8
Angels and Demons/Assets/Prefabs/Angel.prefab.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7453ff1d2cbcf4c6483f203ee524077f
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 100100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Angels and Demons/Assets/Prefabs/Demon.prefab
Normal file
BIN
Angels and Demons/Assets/Prefabs/Demon.prefab
Normal file
Binary file not shown.
8
Angels and Demons/Assets/Prefabs/Demon.prefab.meta
Normal file
8
Angels and Demons/Assets/Prefabs/Demon.prefab.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 27cf7281b7c8649f4a2f237c6cc0876c
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 100100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Angels and Demons/Assets/Prefabs/Move Selection.prefab
Normal file
BIN
Angels and Demons/Assets/Prefabs/Move Selection.prefab
Normal file
Binary file not shown.
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 10bacab99ba8a424886194f09ac0549f
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 100100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Angels and Demons/Assets/Prefabs/Piece Space.prefab
Normal file
BIN
Angels and Demons/Assets/Prefabs/Piece Space.prefab
Normal file
Binary file not shown.
8
Angels and Demons/Assets/Prefabs/Piece Space.prefab.meta
Normal file
8
Angels and Demons/Assets/Prefabs/Piece Space.prefab.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bed2e0f0ee6474bf6ad36acc1d4655df
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 100100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
Binary file not shown.
443
Angels and Demons/Assets/Scripts/BoardManager.cs
Normal file
443
Angels and Demons/Assets/Scripts/BoardManager.cs
Normal file
|
@ -0,0 +1,443 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
|
||||
public class BoardManager : MonoBehaviour
|
||||
{
|
||||
// Global reference to the canvas' width and height.
|
||||
private float canvaswidth;
|
||||
private float canvasheight;
|
||||
|
||||
// Variable to change spacing of the board from the edges of the canvas.
|
||||
private float canvasspacing = 80f;
|
||||
public Image board;
|
||||
|
||||
// Board size references.
|
||||
private float boardwidth;
|
||||
private float boardheight;
|
||||
|
||||
// Might want to make this part modular in the future.
|
||||
private float numberofspaces = 11;
|
||||
|
||||
// Spaces for the board need to be spawned and resized based on canvas.
|
||||
private float spacespacing;
|
||||
public Button blackspaceasset;
|
||||
public Transform blackspacetransform;
|
||||
public Image whitespaceasset;
|
||||
public Transform whitespacetransform;
|
||||
|
||||
// Image assets for the board spaces.
|
||||
public Sprite angelimage;
|
||||
public Image demonimage;
|
||||
|
||||
// Keep references of all the space GameObjects.
|
||||
private Button[] blackspaces = new Button[61];
|
||||
private Image[] whitespaces = new Image[60];
|
||||
|
||||
// Use this for initialization
|
||||
void Start ()
|
||||
{
|
||||
canvasheight = this.GetComponentInParent<RectTransform>().rect.height;
|
||||
canvaswidth = this.GetComponentInParent<RectTransform>().rect.width;
|
||||
boardheight = board.GetComponent<RectTransform>().rect.height;
|
||||
boardwidth = board.GetComponent<RectTransform>().rect.width;
|
||||
spacespacing = ((canvaswidth - canvasspacing)/11f);
|
||||
SpawnInitialBoard();
|
||||
}
|
||||
|
||||
private void UpdateBoardScale()
|
||||
{
|
||||
canvasheight = this.GetComponentInParent<RectTransform>().rect.height;
|
||||
canvaswidth = this.GetComponentInParent<RectTransform>().rect.width;
|
||||
|
||||
if(canvaswidth > canvasheight)
|
||||
{
|
||||
board.rectTransform.sizeDelta = new Vector2(canvasheight - canvasspacing, canvasheight - canvasspacing);
|
||||
}
|
||||
else
|
||||
{
|
||||
board.rectTransform.sizeDelta = new Vector2(canvaswidth - canvasspacing, canvaswidth - canvasspacing);
|
||||
}
|
||||
|
||||
boardheight = board.GetComponent<RectTransform>().rect.height;
|
||||
boardwidth = board.GetComponent<RectTransform>().rect.width;
|
||||
|
||||
spacespacing = ((boardwidth)/11f);
|
||||
|
||||
UpdatePieceScale();
|
||||
}
|
||||
|
||||
private Button SpawnBlackSpace(int i)
|
||||
{
|
||||
Button bsbutton;
|
||||
bsbutton = Instantiate(blackspaceasset, blackspacetransform);
|
||||
bsbutton.name += "" + i;
|
||||
bsbutton.onClick.AddListener(delegate{ButtonAction(bsbutton);});
|
||||
return bsbutton;
|
||||
}
|
||||
|
||||
private Image SpawnWhiteSpace()
|
||||
{
|
||||
Image wsimage;
|
||||
wsimage = Instantiate(whitespaceasset, whitespacetransform);
|
||||
return wsimage;
|
||||
}
|
||||
|
||||
private void SpawnInitialBoard()
|
||||
{
|
||||
for(int i = 0; i < blackspaces.Length; ++i)
|
||||
{
|
||||
Button temp;
|
||||
temp = SpawnBlackSpace(i);
|
||||
temp.GetComponent<RectTransform>().sizeDelta = new Vector2(spacespacing, spacespacing);
|
||||
|
||||
float x = (spacespacing*i*2 + (temp.GetComponent<RectTransform>().rect.width / 2f)) % (boardwidth) - ((boardwidth) / 2f);
|
||||
float y = (boardheight / 2f) - ((temp.GetComponent<RectTransform>().rect.height / 2f) + spacespacing*(Mathf.Floor(i/(11f/2f))));
|
||||
temp.transform.localPosition = new Vector3(x, y, 0);
|
||||
|
||||
blackspaces[i] = temp;
|
||||
|
||||
if(i < blackspaces.Length - 1)
|
||||
{
|
||||
Image tempimage;
|
||||
tempimage = SpawnWhiteSpace();
|
||||
tempimage.GetComponent<RectTransform>().sizeDelta = new Vector2(spacespacing, spacespacing);
|
||||
|
||||
x = (spacespacing*i*2 + (tempimage.GetComponent<RectTransform>().rect.width / 2f)*3) % (boardwidth) - ((boardwidth) / 2f);
|
||||
y = (boardheight / 2f) - ((tempimage.GetComponent<RectTransform>().rect.height / 2f) + spacespacing*(Mathf.Floor((i + 1)/(11.01f/2f))));
|
||||
tempimage.transform.localPosition = new Vector3(x, y, 0);
|
||||
|
||||
whitespaces[i] = tempimage;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdatePieceScale()
|
||||
{
|
||||
for(int i = 0; i < blackspaces.Length; ++i)
|
||||
{
|
||||
Button temp = blackspaces[i];
|
||||
temp.GetComponent<RectTransform>().sizeDelta = new Vector2(spacespacing, spacespacing);
|
||||
float x = (spacespacing*i*2 + (temp.GetComponent<RectTransform>().rect.width / 2f)) % (boardwidth) - ((boardwidth) / 2f);
|
||||
float y = (boardheight / 2f) - ((temp.GetComponent<RectTransform>().rect.height / 2f) + spacespacing*(Mathf.Floor(i/(11f/2f))));
|
||||
temp.transform.localPosition = new Vector3(x, y, 0);
|
||||
blackspaces[i] = temp;
|
||||
|
||||
if(i < blackspaces.Length - 1)
|
||||
{
|
||||
Image tempimage = whitespaces[i];
|
||||
tempimage.GetComponent<RectTransform>().sizeDelta = new Vector2(spacespacing, spacespacing);
|
||||
|
||||
x = (spacespacing*i*2 + (tempimage.GetComponent<RectTransform>().rect.width / 2f)*3) % (boardwidth) - ((boardwidth) / 2f);
|
||||
y = (boardheight / 2f) - ((tempimage.GetComponent<RectTransform>().rect.height / 2f) + spacespacing*(Mathf.Floor((i + 1)/(11.01f/2f))));
|
||||
tempimage.transform.localPosition = new Vector3(x, y, 0);
|
||||
|
||||
whitespaces[i] = tempimage;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update ()
|
||||
{
|
||||
UpdateBoardScale();
|
||||
}
|
||||
|
||||
public void ButtonAction(Button b)
|
||||
{
|
||||
int buttonindex = 0;
|
||||
int.TryParse(b.name.Replace("Move Selection(Clone)", ""), out buttonindex);
|
||||
|
||||
Vector2 boardcoords = ConvertButtonIndex(buttonindex);
|
||||
|
||||
// This is completely incorrect and will most likely need a switch case of some kind in the future.
|
||||
Debug.Log("Board coordinates: " + boardcoords.x + " " + boardcoords.y);
|
||||
|
||||
ChangeSpaces(boardcoords);
|
||||
}
|
||||
|
||||
private Vector2 ConvertButtonIndex(int i)
|
||||
{
|
||||
Vector2 temp;
|
||||
temp.x = (i*2)%11;
|
||||
temp.y = 0;
|
||||
|
||||
switch(i)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
return temp;
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
temp.y = 1;
|
||||
return temp;
|
||||
case 11:
|
||||
case 12:
|
||||
case 13:
|
||||
case 14:
|
||||
case 15:
|
||||
case 16:
|
||||
temp.y = 2;
|
||||
return temp;
|
||||
case 17:
|
||||
case 18:
|
||||
case 19:
|
||||
case 20:
|
||||
case 21:
|
||||
temp.y = 3;
|
||||
return temp;
|
||||
case 22:
|
||||
case 23:
|
||||
case 24:
|
||||
case 25:
|
||||
case 26:
|
||||
case 27:
|
||||
temp.y = 4;
|
||||
return temp;
|
||||
case 28:
|
||||
case 29:
|
||||
case 30:
|
||||
case 31:
|
||||
case 32:
|
||||
temp.y = 5;
|
||||
return temp;
|
||||
case 33:
|
||||
case 34:
|
||||
case 35:
|
||||
case 36:
|
||||
case 37:
|
||||
case 38:
|
||||
temp.y = 6;
|
||||
return temp;
|
||||
case 39:
|
||||
case 40:
|
||||
case 41:
|
||||
case 42:
|
||||
case 43:
|
||||
temp.y = 7;
|
||||
return temp;
|
||||
case 44:
|
||||
case 45:
|
||||
case 46:
|
||||
case 47:
|
||||
case 48:
|
||||
case 49:
|
||||
temp.y = 8;
|
||||
return temp;
|
||||
case 50:
|
||||
case 51:
|
||||
case 52:
|
||||
case 53:
|
||||
case 54:
|
||||
temp.y = 9;
|
||||
return temp;
|
||||
case 55:
|
||||
case 56:
|
||||
case 57:
|
||||
case 58:
|
||||
case 59:
|
||||
case 60:
|
||||
temp.y = 10;
|
||||
return temp;
|
||||
default:
|
||||
return temp;
|
||||
}
|
||||
}
|
||||
|
||||
private int ConvertImageIndex(Vector2 bc)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
switch(Mathf.RoundToInt(bc.y))
|
||||
{
|
||||
case 0:
|
||||
i = (Mathf.RoundToInt(bc.x) - 1)/2;
|
||||
break;
|
||||
case 1:
|
||||
i = (Mathf.RoundToInt(bc.x))/2;
|
||||
i += 5;
|
||||
break;
|
||||
case 2:
|
||||
i = (Mathf.RoundToInt(bc.x) - 1)/2;
|
||||
i += 11;
|
||||
break;
|
||||
case 3:
|
||||
i = (Mathf.RoundToInt(bc.x))/2;
|
||||
i += 16;
|
||||
break;
|
||||
case 4:
|
||||
i = (Mathf.RoundToInt(bc.x) - 1)/2;
|
||||
i += 22;
|
||||
break;
|
||||
case 5:
|
||||
i = (Mathf.RoundToInt(bc.x))/2;
|
||||
i += 27;
|
||||
break;
|
||||
case 6:
|
||||
i = (Mathf.RoundToInt(bc.x) - 1)/2;
|
||||
i += 33;
|
||||
break;
|
||||
case 7:
|
||||
i = (Mathf.RoundToInt(bc.x))/2;
|
||||
i += 38;
|
||||
break;
|
||||
case 8:
|
||||
i = (Mathf.RoundToInt(bc.x) - 1)/2;
|
||||
i += 44;
|
||||
break;
|
||||
case 9:
|
||||
i = (Mathf.RoundToInt(bc.x))/2;
|
||||
i += 49;
|
||||
break;
|
||||
case 10:
|
||||
i = (Mathf.RoundToInt(bc.x) - 1)/2;
|
||||
i += 55;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
private void ChangeSpaces(Vector2 bc)
|
||||
{
|
||||
Vector2 tempbc = bc;
|
||||
int wsi = 0;
|
||||
|
||||
if(bc.x > 0 && bc.x < (numberofspaces - 1))
|
||||
{
|
||||
if(bc.y > 0)
|
||||
{
|
||||
Debug.Log(
|
||||
"changing space:" +
|
||||
(bc.x) + " " + (bc.y - 1)
|
||||
);
|
||||
tempbc = bc;
|
||||
tempbc.y -= 1;
|
||||
wsi = ConvertImageIndex(tempbc);
|
||||
whitespaces[wsi].sprite = angelimage;
|
||||
}
|
||||
if(bc.y < (numberofspaces - 1))
|
||||
{
|
||||
Debug.Log(
|
||||
"changing space:" +
|
||||
(bc.x) + " " + (bc.y + 1)
|
||||
);
|
||||
tempbc = bc;
|
||||
tempbc.y += 1;
|
||||
wsi = ConvertImageIndex(tempbc);
|
||||
whitespaces[wsi].sprite = angelimage;
|
||||
}
|
||||
Debug.Log(
|
||||
"changing spaces:" +
|
||||
(bc.x - 1) + " " + (bc.y) + "\t" +
|
||||
(bc.x + 1) + " " + (bc.y)
|
||||
);
|
||||
tempbc = bc;
|
||||
|
||||
tempbc.x -= 1;
|
||||
wsi = ConvertImageIndex(tempbc);
|
||||
whitespaces[wsi].sprite = angelimage;
|
||||
|
||||
tempbc.x += 2;
|
||||
wsi = ConvertImageIndex(tempbc);
|
||||
whitespaces[wsi].sprite = angelimage;
|
||||
}
|
||||
else if(bc.y > 0 && bc.y < (numberofspaces - 1))
|
||||
{
|
||||
if(bc.x == 0)
|
||||
{
|
||||
Debug.Log(
|
||||
"changing space:" +
|
||||
(bc.x + 1) + " " + (bc.y)
|
||||
);
|
||||
tempbc = bc;
|
||||
tempbc.x += 1;
|
||||
wsi = ConvertImageIndex(tempbc);
|
||||
whitespaces[wsi].sprite = angelimage;
|
||||
}
|
||||
if(bc.x == (numberofspaces - 1))
|
||||
{
|
||||
Debug.Log(
|
||||
"changing space:" +
|
||||
(bc.x - 1) + " " + (bc.y)
|
||||
);
|
||||
tempbc = bc;
|
||||
tempbc.x -= 1;
|
||||
wsi = ConvertImageIndex(tempbc);
|
||||
whitespaces[wsi].sprite = angelimage;
|
||||
}
|
||||
Debug.Log(
|
||||
"changing spaces:" +
|
||||
(bc.x) + " " + (bc.y - 1) + "\t" +
|
||||
(bc.x) + " " + (bc.y + 1)
|
||||
);
|
||||
tempbc = bc;
|
||||
|
||||
tempbc.y -= 1;
|
||||
wsi = ConvertImageIndex(tempbc);
|
||||
whitespaces[wsi].sprite = angelimage;
|
||||
|
||||
tempbc.y += 2;
|
||||
wsi = ConvertImageIndex(tempbc);
|
||||
whitespaces[wsi].sprite = angelimage;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(bc.x == 0)
|
||||
{
|
||||
Debug.Log(
|
||||
"changing space:" +
|
||||
(bc.x + 1) + " " + (bc.y)
|
||||
);
|
||||
tempbc = bc;
|
||||
tempbc.x += 1;
|
||||
wsi = ConvertImageIndex(tempbc);
|
||||
whitespaces[wsi].sprite = angelimage;
|
||||
}
|
||||
if(bc.x == (numberofspaces - 1))
|
||||
{
|
||||
Debug.Log(
|
||||
"changing space:" +
|
||||
(bc.x - 1) + " " + (bc.y)
|
||||
);
|
||||
tempbc = bc;
|
||||
tempbc.x -= 1;
|
||||
wsi = ConvertImageIndex(tempbc);
|
||||
whitespaces[wsi].sprite = angelimage;
|
||||
}
|
||||
if(bc.y > 0)
|
||||
{
|
||||
Debug.Log(
|
||||
"changing space:" +
|
||||
(bc.x) + " " + (bc.y - 1)
|
||||
);
|
||||
tempbc = bc;
|
||||
tempbc.y -= 1;
|
||||
wsi = ConvertImageIndex(tempbc);
|
||||
whitespaces[wsi].sprite = angelimage;
|
||||
}
|
||||
if(bc.y < (numberofspaces - 1))
|
||||
{
|
||||
Debug.Log(
|
||||
"changing space:" +
|
||||
(bc.x) + " " + (bc.y + 1)
|
||||
);
|
||||
tempbc = bc;
|
||||
tempbc.y += 1;
|
||||
wsi = ConvertImageIndex(tempbc);
|
||||
whitespaces[wsi].sprite = angelimage;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Angels and Demons/Assets/Scripts/BoardManager.cs.meta
Normal file
11
Angels and Demons/Assets/Scripts/BoardManager.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8b4ca8083201141f388e345f2beecffb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Angels and Demons/Assets/Sprites.meta
Normal file
8
Angels and Demons/Assets/Sprites.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 50c0d0a843af248dc8b1be7ac3b4c63e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Angels and Demons/Assets/Sprites/gitea-lg.png
Normal file
BIN
Angels and Demons/Assets/Sprites/gitea-lg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
84
Angels and Demons/Assets/Sprites/gitea-lg.png.meta
Normal file
84
Angels and Demons/Assets/Sprites/gitea-lg.png.meta
Normal file
|
@ -0,0 +1,84 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 80e6f163eb4504e0cbd7e886f3ea4f6d
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
externalObjects: {}
|
||||
serializedVersion: 5
|
||||
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
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: -1
|
||||
aniso: -1
|
||||
mipBias: -1
|
||||
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
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 2
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: b7b8277dba3c0425892944924e2372d0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
spritePackingTag:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
Reference in a new issue