This repository has been archived by the owner on Jan 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Progress on the level loading procedure
- Loading branch information
Showing
10 changed files
with
252 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,20 @@ | ||
using Distance.AdventureMaker.Common.Enums; | ||
using Distance.AdventureMaker.Common.Models.Resources; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace Distance.AdventureMaker.Common.Models | ||
{ | ||
public partial class CampaignFile | ||
{ | ||
public CampaignResource GetResource(string guid, ResourceType type) | ||
{ | ||
public CampaignResource GetResource(string guid, ResourceType type) | ||
{ | ||
return Data.Resources.Find((res) => Equals(res.guid, guid) && Equals(res.resource_type, type)); | ||
} | ||
} | ||
|
||
public IEnumerable<CampaignResource> GetResources(ResourceType type) | ||
{ | ||
return Data.Resources.Where(x => x.resource_type == type); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System.IO; | ||
using UnityEngine; | ||
|
||
namespace Distance.AdventureMaker.DataModel | ||
{ | ||
public class LevelData | ||
{ | ||
public readonly string alias; | ||
public readonly FileInfo levelFile; | ||
public readonly FileInfo thumbnailFile; | ||
|
||
private Texture2D thumbnailTexture_; | ||
public Texture2D ThumbnailTexture | ||
{ | ||
get | ||
{ | ||
if (!thumbnailTexture_ && thumbnailFile?.Exists == true) | ||
{ | ||
thumbnailTexture_ = Resource.LoadTextureFromFile(thumbnailFile.FullName, 640, 360) as Texture2D; | ||
} | ||
|
||
return thumbnailTexture_; | ||
} | ||
} | ||
|
||
public LevelData(string alias, string level, string thumbnail = null) : this(alias, new FileInfo(level), new FileInfo(thumbnail)) | ||
{ | ||
} | ||
|
||
public LevelData(string alias, FileInfo level, FileInfo thumbnail = null) | ||
{ | ||
this.alias = alias; | ||
levelFile = level; | ||
thumbnailFile = thumbnail; | ||
} | ||
|
||
public override int GetHashCode() | ||
{ | ||
return levelFile.FullName.GetHashCode(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
Distance.AdventureMaker/Extensions/mscorlib/System/StringEx.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
public static class StringExtensions | ||
{ | ||
public static string NormalizePath(this string input) | ||
{ | ||
return input.Normalize().Replace('\\', '/'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System.IO; | ||
using UnityEngine; | ||
|
||
namespace Distance.AdventureMaker.Interfaces | ||
{ | ||
public interface ILevelRegister | ||
{ | ||
void RegisterLevel(string alias, FileInfo bytesFile, FileInfo thumbnailTexture = null); | ||
|
||
void RegisterLevel(string alias, string bytesFile, string thumbnailTexture = null); | ||
|
||
string GetLevelAlias(string levelPath); | ||
|
||
string GetLevelPath(string alias); | ||
|
||
Texture2D GetThumbnailFromPath(FileInfo levelFile); | ||
|
||
Texture2D GetThumbnailFromPath(string levelPath); | ||
|
||
Texture2D GetThumbnailFromAlias(string alias); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
Distance.AdventureMaker/Scripts/Managers/Campaigns/CampaignManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Distance.AdventureMaker.Interfaces; | ||
using System.IO; | ||
using UnityEngine; | ||
|
||
namespace Distance.AdventureMaker.Scripts.Managers.Campaigns | ||
{ | ||
public class CampaignManager : MonoBehaviour | ||
{ | ||
public ILevelRegister Levels { get; private set; } | ||
|
||
public void Awake() | ||
{ | ||
Levels = new LevelRegister(); | ||
} | ||
|
||
|
||
} | ||
} |
Oops, something went wrong.