public void RespawnPlayers() { GameObject p1 = AtomicTags.FindAllByTag(playerTag.Value)[0]; GameObject p2 = AtomicTags.FindAllByTag(playerTag.Value)[1]; //!!!reset all in current cp pulled levers---------------------------------------------------------------------------------- p1.GetComponent <Player_Movement>().ResetBuffs(); p2.GetComponent <Player_Movement>().ResetBuffs(); items.items[numActive + 1].Clear(); transfer.InvokeEvent(); //unpull all levers //items.levers[numActive+1].Clear(); //reset list with in current cp pulled levers for (int i = 0; i <= numActive; i++) { if (hasBeenActivated[i]) { currentSpawnPlayer1 = spawnPlayer1[i].position; currentSpawnPlayer2 = spawnPlayer2[i].position; } } p1.transform.position = currentSpawnPlayer1; p2.transform.position = currentSpawnPlayer2; }
//Function to add Actions to Array public void AddEvent(actions action) { checkpoint = AtomicTags.FindByTag(checkpointTag.Value).GetComponent <SavePoint>(); if (myActions == null) { myActions = new actions[checkpoint.hasBeenActivated.Length + 1]; } /*for (int i=checkpoint.numActive+1;i<checkpoint.hasBeenActivated.Length;i++) * { * if (!checkpoint.hasBeenActivated[i]) * { * events[i] -= action; * events[i] += action; * Debug.Log("Added " + action.GetMethodInfo() +" to checksave " +i); * } * }*/ if (checkpoint.numActive >= myActions.Length) { Debug.Log("returning empty"); return; } Debug.Log(action.GetMethodInfo()); myActions[checkpoint.numActive + 1] -= action; myActions[checkpoint.numActive + 1] += action; }
private void Start() { InitializeSpawnPoints(); hasBeenActivated = new bool[GetComponentsInChildren <BoxCollider2D>().Length]; //items.items.Clear(); items.items = new List <List <GameObject> >(); items.levers = new List <List <GameObject> >(); foreach (var VARIABLE in hasBeenActivated) { items.items.Add(new List <GameObject>()); items.levers.Add(new List <GameObject>()); } items.items.Add(new List <GameObject>()); items.levers.Add(new List <GameObject>()); //PotionsThatWillDisappear.items.Clear(); PotionsThatWillDisappear.items = new List <List <GameObject> >(); PotionsThatWillDisappear.items.Add(new List <GameObject>()); PotionsThatWillDisappear.levers = new List <List <GameObject> >(); PotionsThatWillDisappear.levers.Add(new List <GameObject>()); GameObject p1 = AtomicTags.FindAllByTag(playerTag.Value)[0]; GameObject p2 = AtomicTags.FindAllByTag(playerTag.Value)[1]; currentSpawnPlayer1 = new Vector3(p1.transform.position.x, p1.transform.position.y, p1.transform.position.z); currentSpawnPlayer2 = new Vector3(p2.transform.position.x, p2.transform.position.y, p2.transform.position.z); //transfer.InvokeEvent(); }
private void Start() { StartPosition = transform.position; CameraSize = Camera.main.orthographicSize; //find players Players = AtomicTags.FindAllByTag(PlayerTag.Value); }
/// <returns> /// - False if the GameObject does not have the AtomicTag, else True /// </returns> public static bool HasTag(this GameObject go, string tag) { var atomicTags = AtomicTags.GetForGameObject(go); if (atomicTags == null) { return(false); } return(atomicTags.HasTag(tag)); }
// Start is called before the first frame update void Start() { _light1GameObject = AtomicTags.FindAllByTag(Lights.Value)[0]; _light1 = _light1GameObject.GetComponent <Light2D>(); _light2GameObject = AtomicTags.FindAllByTag(Lights.Value)[1]; _light2 = _light2GameObject.GetComponent <Light2D>(); _bigLightGameObject = AtomicTags.FindByTag(BigLight.Value); _bLight = _bigLightGameObject.GetComponent <Light2D>(); Debug.Log("Bighlight:" + _bigLightGameObject + " smallight1:" + _light1GameObject + " smalllight2: " + _light2GameObject); }
void Start() { var Players = AtomicTags.FindAllByTag(PlayerTag.Value); foreach (var player in Players) { if (!player.HasTag(_tags.Tags[1])) { OtherPlayer = player; } } }
// Start is called before the first frame update void Start() { dialogFirable = true; DeathDialogStatus.Value = 0; ChangeTurn(); Player1 = AtomicTags.FindByTag(Player1Tag.Value); Player2 = AtomicTags.FindByTag(Player2Tag.Value); _animator = GetComponentInChildren <Animator>(); _audio = GetComponent <AudioSource>(); }
public void InvokeEvent() { checkpoint = AtomicTags.FindByTag(checkpointTag.Value).GetComponent <SavePoint>(); //Debug.Log(checkpoint.numActive+1 +" checkpoints are active"); Debug.Log("a cockroach"); if (checkpoint.numActive >= 0) { //Debug.Log("invoke action from set " + checkpoint.numActive ); //Debug.Log(myActions?[checkpoint.numActive]?.GetMethodInfo()); Debug.Log("in a bunker"); myActions?[checkpoint.numActive]?.Invoke(); } } //on death
/* public void ResetDestructables() * { * if (eventActivateDestructables==null) * { * return; * } * foreach (Action action in eventActivateDestructables?.GetInvocationList() ) * { * eventActivateDestructables -= action; * } * }*/ public void LoadScene() { //SceneManager.LoadScene(SceneManager.GetActiveScene().name); //don´t reload scene but reset Player //set all relevant variables back to normal values foreach (GameObject obj in AtomicTags.FindAllByTag(PlayerTag.Value)) { obj.GetComponent <Player_Movement>().ResetBuffs(); } //then invoke event InvokeEvent(); }
public static bool HasAnyTag(this GameObject go, List <string> strings) { var atomicTags = AtomicTags.GetForGameObject(go); if (atomicTags == null) { return(false); } for (var i = 0; i < strings.Count; i++) { if (atomicTags.HasTag(strings[i])) { return(true); } } return(false); }
public static bool HasAnyTag(this GameObject go, List <StringConstant> stringConstants) { // basically same method as above, the code is mostly copy and pasted because its not preferable to convert // stringconstants to strings and calling the other method, because of memory allocation var atomicTags = AtomicTags.GetForGameObject(go); if (atomicTags == null) { return(false); } for (var i = 0; i < stringConstants.Count; i++) { if (atomicTags.HasTag(stringConstants[i].Value)) { return(true); } } return(false); }
/// <summary> /// Retrieves all AtomicTags for a given GameObject /// </summary> /// <returns> /// - null if the GameObject does not have Atomic Tags or they (or the GO) are disabled) /// - an readonly list of strings containing the tags /// </returns> public static ReadOnlyList <StringConstant> GetAtomicTags(this GameObject go) { return(AtomicTags.GetAtomicTags(go)); }
void Update() { Distance.Value = (AtomicTags.FindByTag(TagPlayer2.Value).transform.position - transform.position).magnitude; }
// Start is called before the first frame update void Start() { P1 = AtomicTags.FindByTag(TagP1.Value); P2 = AtomicTags.FindByTag(TagP2.Value); }
public IEnumerator TestingAndProfiling() { var go = new GameObject(); var atomicTags = go.AddComponent <AtomicTags>(); List <string> random_tags_raw = new List <string>() { "a", "c", "e", "g", "i", "k", "m" }; random_tags_raw.OrderBy((s => Random.value)).ToList(); var fieldinfo = typeof(StringConstant).GetField("value", BindingFlags.NonPublic | BindingFlags.Instance); for (int i = 0; i < random_tags_raw.Count; ++i) { var stringConstant = ScriptableObject.CreateInstance <StringConstant>(); fieldinfo.SetValue(stringConstant, random_tags_raw[i]); atomicTags.AddTag(stringConstant); } var newConstant = ScriptableObject.CreateInstance <StringConstant>(); fieldinfo.SetValue(newConstant, "b"); yield return(null); yield return(new WaitForFixedUpdate()); // with the help of those ProfilerMarkers you can check GC Alloc in the Profiler Window Pretty easy // an alternative would be: https://docs.unity3d.com/2018.3/Documentation/ScriptReference/TestTools.Constraints.AllocatingGCMemoryConstraint.html // Assert.That(() => { }, Is.Not.AllocatingGCMemory()); but it does not work correctly half of the time Assert.That(() => { var t1 = atomicTags.Tags; }, Is.Not.AllocatingGCMemory()); Assert.That(() => { var t1 = atomicTags.Tags[1]; }, Is.Not.AllocatingGCMemory()); Assert.That(() => { var t1 = atomicTags.Tags[2].Value; }, Is.Not.AllocatingGCMemory()); Assert.That(() => { atomicTags.HasTag(null); }, Is.Not.AllocatingGCMemory()); Assert.AreSame(go, AtomicTags.FindByTag("e")); using (new ProfilerMarker("MySystem.FindByTag").Auto()) { AtomicTags.FindByTag("e"); } // THIS: // Assert.That(() => { var t1 = AtomicTags.FindByTag("e"); }, Is.AllocatingGCMemory()); // says it allocates, the profiler says it does not using (new ProfilerMarker("MySystem.MultpleGet").Auto()) { var t1 = atomicTags.Tags; var t10 = t1[0]; var t11 = atomicTags.Tags[0]; var t2 = atomicTags.Tags; } using (new ProfilerMarker("MySystem.GetGlobal").Auto()) { AtomicTags.GetForGameObject(go); } Assert.AreEqual(random_tags_raw.Count, atomicTags.Tags.Count); for (var i = 0; i < atomicTags.Tags.Count - 1; i++) { Assert.IsTrue(String.CompareOrdinal(atomicTags.Tags[i].Value, atomicTags.Tags[i + 1].Value) < 0); } using (new ProfilerMarker("MySystem.AddCompletelyNewTag").Auto()) { atomicTags.AddTag(newConstant); } Assert.AreEqual(random_tags_raw.Count + 1, atomicTags.Tags.Count); for (var i = 0; i < atomicTags.Tags.Count - 1; i++) { Assert.IsTrue(String.CompareOrdinal(atomicTags.Tags[i].Value, atomicTags.Tags[i + 1].Value) < 0); } using (new ProfilerMarker("MySystem.RemoveTag").Auto()) { atomicTags.RemoveTag("b"); } using (new ProfilerMarker("MySystem.AddTagAgain").Auto()) { atomicTags.AddTag(newConstant); } Assert.IsTrue(atomicTags.HasTag("a")); using (new ProfilerMarker("MySystem.HasTagTrue1").Auto()) { atomicTags.HasTag("a"); } Assert.IsTrue(go.HasTag("a")); using (new ProfilerMarker("MySystem.HasTagTrue1Global").Auto()) { go.HasTag("a"); } Assert.IsTrue(go.HasTag("m")); using (new ProfilerMarker("MySystem.HasTagTrue2").Auto()) { go.HasTag("m"); } Assert.IsFalse(go.HasTag("z")); using (new ProfilerMarker("MySystem.HasTagFalse").Auto()) { go.HasTag("z"); } var falseList = new List <string>() { "d", "f", "h", "j", "l" }; var truelist = new List <string>() { "d", "f", "h", "j", "m" }; Assert.IsFalse(go.HasAnyTag(falseList)); using (new ProfilerMarker("MySystem.HasAnyTag_allFalse").Auto()) { go.HasAnyTag(falseList); } Assert.IsTrue(go.HasAnyTag(truelist)); using (new ProfilerMarker("MySystem.HasAnyTag_lastTrue").Auto()) { go.HasAnyTag(truelist); } yield return(null); }
private void Start() { checkpoint = AtomicTags.FindByTag(checkpointTag.Value).GetComponent <SavePoint>(); }
private void Awake() { _tags = GetComponent <AtomicTags>(); }