| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class LockSoul : MonoBehaviour
- {
- public int maxLockSoul;
- private int nowLock;
- public List<Demonic> souls = new List<Demonic>();
- public PlayerController pc;
- public void AddDenomic(Demonic d)
- {
- if (!d.isRecorded)
- {
- d.isInSoulTower = true;
- d.origSoulPos = d.transform.position;
- if (IsSoulsFull())
- {
- Demonic s = souls[0];
- s.isInSoulTower = false;
- souls.Remove(s);
- s.isRecorded = false;
- s.ChangeState(CharacterState.Idle);
- }
- souls.Add(d);
- d.isRecorded = true;
- }
- }
- private void OnTriggerEnter(Collider other)
- {
- if (other.gameObject.layer == 6)
- {
- Character c = other.GetComponentInParent<Character>();
- if (c.ls == null)
- {
- c.ls = this;
- pc = other.GetComponentInParent<PlayerController>();
- }
- c.isInSoulTower = true;
- pc.curSoulTower = gameObject;
- }
- }
- private bool IsSoulsFull()
- {
- bool isFull = false;
- List<Demonic> re = new List<Demonic>();
- nowLock = 0;
- foreach(Demonic d in souls)
- {
- if(d.isDie || !d.isInSoulTower)
- {
- re.Add(d);
- }
- else
- {
- nowLock++;
- }
- }
- foreach(Demonic d in re)
- {
- souls.Remove(d);
- }
- if (nowLock >= maxLockSoul)
- {
- isFull = true;
- }
- return isFull;
- }
- private void OnTriggerExit(Collider other)
- {
- if (other.gameObject.layer == 6)
- {
- Character c = other.GetComponentInParent<Character>();
- c.isInSoulTower = false;
- }
- }
- public void ReleaseAllSouls()
- {
- if (pc.curSoulTower == gameObject && pc.isInSoulTower)
- {
- pc.isInSoulTower = false;
- }
- foreach(Demonic d in souls)
- {
- if (!d.isDie)
- {
- d.isInSoulTower = false;
- d.ChangeState(CharacterState.Idle);
- }
- }
- }
- }
|