Files
taptap2024_GJ_chidouren/Assets/Scripts/Game/Component/ScenePart.cs

64 lines
2.0 KiB
C#
Raw Normal View History

2024-10-21 17:02:25 +08:00
using System.Collections.Generic;
2024-10-23 14:56:16 +08:00
using Game.Component.SceneProp;
2024-10-21 17:02:25 +08:00
using Sirenix.OdinInspector;
2024-10-21 16:20:37 +08:00
using UnityEngine;
2024-10-23 14:56:16 +08:00
using UnityEngine.Serialization;
2024-10-21 16:20:37 +08:00
namespace Game.Component
{
public class ScenePart : MonoBehaviour
{
public PolygonCollider2D cameraCollider;
public Transform createPos;
public int completeConditionNumber = 10;
public float playerBaseSpeed = 4f;
2024-10-27 19:08:26 +08:00
[Header("关卡背景音乐")]public string BGM = "";
2024-10-23 14:56:16 +08:00
[FormerlySerializedAs ("completeProp")] public SuccessProp successProp;
2024-10-21 16:20:37 +08:00
[LabelText ("当前完成数:")] private int _currentConditionNumber = 0;
2024-10-28 00:40:00 +08:00
public int LossCount;
2024-10-21 22:29:53 +08:00
public int CurrentConditionNumber => this._currentConditionNumber;
2024-10-21 17:02:25 +08:00
private List<EnemyEntity> _enemyEntities;
2024-10-23 14:56:16 +08:00
private List<BaseProp> _baseProps;
2024-10-21 17:02:25 +08:00
2024-10-26 21:50:45 +08:00
public SuccessProp SuccessProp => this.successProp;
2024-10-21 22:29:53 +08:00
public float CurProgress => this._currentConditionNumber * 1f / completeConditionNumber;
2024-10-21 16:20:37 +08:00
2024-10-23 14:56:16 +08:00
public bool IsCondition => _currentConditionNumber >= completeConditionNumber;
2024-10-21 16:20:37 +08:00
public bool AddConditionNumber (int number = 1)
{
this._currentConditionNumber += number;
return _currentConditionNumber >= completeConditionNumber;
}
2024-10-21 17:02:25 +08:00
public void RefreshInit ()
{
this._currentConditionNumber = 0;
foreach (var enemyEntity in this._enemyEntities)
{
enemyEntity.ResetState ();
}
2024-10-23 14:56:16 +08:00
foreach (var baseProp in this._baseProps)
{
baseProp.ResetProp ();
}
this.successProp.gameObject.SetActive (false);
2024-10-21 17:02:25 +08:00
}
public void InitPart ()
{
this._enemyEntities = new List<EnemyEntity> ();
this._enemyEntities = new List<EnemyEntity> (transform.GetComponentsInChildren<EnemyEntity> (true));
2024-10-23 14:56:16 +08:00
this._baseProps = new List<BaseProp> (transform.GetComponentsInChildren<BaseProp> (true));
2024-10-21 17:02:25 +08:00
}
2024-10-21 16:20:37 +08:00
}
}