Initial ARPG Port
ARPG scene assets from old project are now correctly visualizing sectors generated by ZoneGenerator and updated by GameContext
This commit is contained in:
parent
1e2b474fc1
commit
d12d7c5c45
379 changed files with 42700 additions and 7253 deletions
63
Assets/Scripts/ActionGameManager.cs
Normal file
63
Assets/Scripts/ActionGameManager.cs
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using MessagePack;
|
||||
using UnityEngine;
|
||||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
using float2 = Unity.Mathematics.float2;
|
||||
|
||||
public class ActionGameManager : MonoBehaviour
|
||||
{
|
||||
public DatabaseCache Cache { get; private set; }
|
||||
public GameContext Context { get; private set; }
|
||||
public Zone CurrentZone { get; private set; }
|
||||
|
||||
public event EventHandler<ZoneChangeEventArgs> ZoneChanged;
|
||||
|
||||
void Start()
|
||||
{
|
||||
var filePath = new DirectoryInfo(Application.dataPath).Parent;
|
||||
Cache = new DatabaseCache();
|
||||
Cache.Load(filePath.FullName);
|
||||
Context = new GameContext(Cache, Debug.Log);
|
||||
|
||||
var zoneFile = Path.Combine(filePath.FullName, "Home.msgpack");
|
||||
|
||||
// If the game has already been run, there will be a Home file containing a ZonePack; if not, generate one
|
||||
var zonePack = File.Exists(zoneFile) ?
|
||||
MessagePackSerializer.Deserialize<ZonePack>(File.ReadAllBytes(zoneFile)) :
|
||||
ZoneGenerator.GenerateZone(
|
||||
context: Context,
|
||||
name: "Home",
|
||||
position: float2.zero,
|
||||
mapLayers: Context.MapLayers.Values,
|
||||
resources: Context.Resources,
|
||||
mass: 100000,
|
||||
radius: 1500
|
||||
);
|
||||
|
||||
//var oldZone = CurrentZone;
|
||||
CurrentZone = Context.GetZone(zonePack);
|
||||
//ZoneChanged?.Invoke(this, new ZoneChangeEventArgs(oldZone, CurrentZone));
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
Context.Time = Time.time;
|
||||
Context.Update();
|
||||
}
|
||||
}
|
||||
|
||||
public class ZoneChangeEventArgs : EventArgs
|
||||
{
|
||||
public Zone OldZone { get; set; }
|
||||
public Zone NewZone { get; set; }
|
||||
|
||||
public ZoneChangeEventArgs(Zone oldZone, Zone newZone)
|
||||
{
|
||||
OldZone = oldZone;
|
||||
NewZone = newZone;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue