-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
46 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
namespace SWPPT3.Main.Prop | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,47 @@ | ||
using System; | ||
using UnityEngine; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
|
||
namespace SWPPT3.Main.Prop | ||
{ | ||
public class MagicCircle : StateDst | ||
{ | ||
[SerializeField] | ||
private int stateChangeAmount; | ||
protected override void OnSourceStateChanged(bool state) | ||
|
||
private int _progress = 0; | ||
private Dictionary<StateSource, bool> circleStates; | ||
|
||
public void Awake() | ||
{ | ||
if (this.State == On) | ||
circleStates = new Dictionary<StateSource, bool>(); | ||
StateSource[] sources = GetComponentsInChildren<StateSource>(); | ||
foreach (var source in sources) | ||
{ | ||
|
||
circleStates[source] = false; | ||
} | ||
else if (this.State == Off) | ||
} | ||
|
||
protected override void OnSourceStateChanged(StateSource src, bool state) | ||
{ | ||
circleStates[src] = state; | ||
_progress = 0; | ||
foreach (bool circleState in circleStates.Values) | ||
{ | ||
if(circleState) _progress ++; | ||
} | ||
|
||
if (_progress >= circleStates.Count) | ||
{ | ||
ActivateMagicCircle(); | ||
State = On; | ||
} | ||
} | ||
|
||
private void ActivateMagicCircle() | ||
{ | ||
Debug.Log("Magic Circle Activated"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,29 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
namespace SWPPT3.Main.Prop | ||
{ | ||
public abstract class StateDst : StatefulProp | ||
{ | ||
[SerializeField] | ||
private StateSource stateSource; | ||
private List<StateSource> stateSources; | ||
private void OnEnable() | ||
{ | ||
stateSource.OnStateChanged += OnSourceStateChanged; | ||
foreach (StateSource stateSource in stateSources) | ||
{ | ||
stateSource.OnStateChanged += OnSourceStateChanged; | ||
} | ||
|
||
} | ||
private void OnDisable() | ||
{ | ||
stateSource.OnStateChanged -= OnSourceStateChanged; | ||
foreach (StateSource stateSource in stateSources) | ||
{ | ||
stateSource.OnStateChanged -= OnSourceStateChanged; | ||
} | ||
} | ||
protected abstract void OnSourceStateChanged(bool state); | ||
protected abstract void OnSourceStateChanged(StateSource src, bool state); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters