updat core

This commit is contained in:
2024-10-21 16:20:37 +08:00
parent afc7f2d1bc
commit 93fe7b4d04
33 changed files with 1381 additions and 478 deletions

View File

@@ -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);
}
}
}