This commit is contained in:
2025-05-13 05:19:58 +03:00
parent 853edaf0b4
commit 472b2aee18
1034 changed files with 41844 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
using UnityEngine;
using System.Collections;
public class SavePoint : PlayerSensor {
private GameAction _saveAction;
private AudioSource _audio;
private float lastSaveTime = -100;
public float savePeriod = 5.0f;
void Start(){
_saveAction = new GameAction();
_saveAction.target = gameObject;
_saveAction.text = "Save state";
_audio = GetComponent<AudioSource>();
}
protected override void OnPlayerEnter (GameObject player)
{
base.OnPlayerEnter (player);
ActionController.AddAction(_saveAction);
}
protected override void OnPlayerExit (GameObject player)
{
base.OnPlayerExit (player);
ActionController.RemoveAction(_saveAction);
}
void OnAction(ActionArgs a){
if(Time.time - lastSaveTime >= savePeriod){
Debug.Log("Save");
lastSaveTime = Time.time;
if(_audio != null){
_audio.Play();
}
}
}
}