You've already forked taptap2024_GJ_chidouren
updat core
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
using System;
|
||||
using Framework.Timer;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.Component
|
||||
{
|
||||
public class MapContent : MonoBehaviour
|
||||
{
|
||||
public PlayerEntity PlayerEntity;
|
||||
public PlayerEntity PlayerEntity;
|
||||
[HideInInspector] public ScenePart ScenePart;
|
||||
public AstarPath Pathfinder;
|
||||
|
||||
//玩家位置
|
||||
public Vector2 PlayerPosition { private set; get; }
|
||||
|
||||
@@ -16,13 +20,55 @@ namespace Game.Component
|
||||
{
|
||||
//全局特殊单例
|
||||
Instance = this;
|
||||
var componentInChildren = this.transform.GetComponentInChildren<ScenePart> ();
|
||||
if (componentInChildren != null)
|
||||
{
|
||||
SetPart (componentInChildren);
|
||||
}
|
||||
}
|
||||
|
||||
private void Update ()
|
||||
|
||||
private void OnEnable ()
|
||||
{
|
||||
this.PlayerPosition = PlayerEntity.transform.position;
|
||||
GameUpdateMgr.Instance.AddUpdater (DoUpdate);
|
||||
}
|
||||
|
||||
private void OnDisable ()
|
||||
{
|
||||
GameUpdateMgr.Instance.RemoveUpdater (DoUpdate);
|
||||
}
|
||||
|
||||
private void DoUpdate ()
|
||||
{
|
||||
this.PlayerPosition = this.PlayerEntity.transform.position;
|
||||
}
|
||||
|
||||
public void SetPart (ScenePart scenePart)
|
||||
{
|
||||
if (this.ScenePart != null)
|
||||
{
|
||||
GameObject.Destroy (this.ScenePart.gameObject);
|
||||
}
|
||||
|
||||
this.ScenePart = scenePart;
|
||||
this.Pathfinder.data.SetData (this.ScenePart.mapCacheData.bytes);
|
||||
CameraManager.Instance.SetBoxCollider (this.ScenePart.cameraCollider);
|
||||
ResetPlayer ();
|
||||
CameraManager.Instance.SetCameraState (CameraManager.CameraState.Player_Near);
|
||||
}
|
||||
|
||||
public void ResetPlayer ()
|
||||
{
|
||||
this.PlayerEntity.transform.position = this.ScenePart.createPos.position;
|
||||
this.PlayerEntity.gameObject.SetActive (true);
|
||||
this.PlayerEntity.RefreshInit ();
|
||||
//播放特效
|
||||
}
|
||||
|
||||
public void OverlyCoin (int messageOverlyCoin)
|
||||
{
|
||||
// ReSharper disable once Unity.NoNullPropagation
|
||||
this.ScenePart?.AddConditionNumber (messageOverlyCoin);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user