This file contains hidden or 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
using System; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class Pool : MonoBehaviour | |
{ | |
private static Dictionary<PooledMonoBehaviour, Pool> pools = new Dictionary<PooledMonoBehaviour, Pool>(); | |
private Queue<PooledMonoBehaviour> objects = new Queue<PooledMonoBehaviour>(); | |
private List<PooledMonoBehaviour> disabledObjects = new List<PooledMonoBehaviour>(); |
This file contains hidden or 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
using System; | |
using UnityEngine; | |
public class PooledMonoBehaviour : MonoBehaviour | |
{ | |
[SerializeField] | |
private int initialPoolSize = 100; | |
public int InitialPoolSize {get {return initialPoolSize; } } |
This file contains hidden or 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
using UnityEngine; | |
public class Grid : MonoBehaviour | |
{ | |
[SerializeField] | |
private float size = 1f; | |
public Vector3 GetNearestPointOnGrid(Vector3 position) | |
{ | |
position -= transform.position; |
This file contains hidden or 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
using UnityEngine; | |
public class CubePlacer : MonoBehaviour | |
{ | |
private Grid grid; | |
private void Awake() | |
{ | |
grid = FindObjectOfType<Grid>(); | |
} |
This file contains hidden or 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
using UnityEngine; | |
public class TerrainDetector | |
{ | |
private TerrainData terrainData; | |
private int alphamapWidth; | |
private int alphamapHeight; | |
private float[,,] splatmapData; | |
private int numTextures; |
This file contains hidden or 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
using UnityEngine; | |
public class FootSteps : MonoBehaviour | |
{ | |
[SerializeField] | |
private AudioClip[] stoneClips; | |
[SerializeField] | |
private AudioClip[] mudClips; | |
[SerializeField] | |
private AudioClip[] grassClips; |
This file contains hidden or 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
public class NumberDemoAgent : Agent | |
{ | |
[SerializeField] | |
private float currentNumber; | |
[SerializeField] | |
private float targetNumber; | |
[SerializeField] | |
private Text text; | |
[SerializeField] | |
private Transform cube; |
This file contains hidden or 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
public override List<float> CollectState() | |
{ | |
List<float> state = new List<float>(); | |
state.Add(currentNumber); | |
state.Add(targetNumber); | |
return state; | |
} |
This file contains hidden or 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
public override void AgentReset() | |
{ | |
targetNumber = UnityEngine.Random.RandomRange(-1f, 1f); | |
sphere.position = new Vector3(targetNumber * 5, 0, 0); | |
currentNumber = 0f; | |
} |
This file contains hidden or 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
public override void AgentStep(float[] action) | |
{ | |
if (text != null) | |
text.text = string.Format("C:{0} / T:{1} [{2}]", currentNumber, targetNumber, solved); | |
switch ((int)action[0]) | |
{ | |
case 0: | |
currentNumber -= 0.01f; | |
break; |
NewerOlder