Commit aba676c0 authored by Skydiver3's avatar Skydiver3

levers work with checkpoints now:)

parent 6b18b1e3
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 320ccd2dc511d4d1b9d768f703fd3bb8, type: 3}
m_Name: MenuHasBeenLoaded
m_EditorClassIdentifier:
DeveloperDescription:
value: 0
oldValue: 0
Changed: {fileID: 0}
ChangedWithHistory: {fileID: 0}
fileFormatVersion: 2
guid: c29aa0de4bb26a945ae50fd6de53f7ec
folderAsset: yes
DefaultImporter:
guid: 4032cf54e5376c241bc6860e23a961c0
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
......@@ -13,6 +13,7 @@ GameObject:
- component: {fileID: 46179617408924949}
- component: {fileID: 5810170731428422867}
- component: {fileID: 2783878841515753837}
- component: {fileID: 5374147668424276736}
m_Layer: 11
m_Name: Lever
m_TagString: Untagged
......@@ -163,6 +164,8 @@ MonoBehaviour:
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
pulledLevers: {fileID: 11400000, guid: 9612907be0f0e574196d911693f5fa81, type: 2}
checkpointTag: {fileID: 11400000, guid: 3458fcec955445a4f94e41fc34583bcd, type: 2}
IsTimed: 0
AfterTime: 0
--- !u!114 &2783878841515753837
......@@ -178,3 +181,16 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
_tags: []
--- !u!114 &5374147668424276736
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 46179617408924945}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 559838af38077ab4ab9c5c3d477b0096, type: 3}
m_Name:
m_EditorClassIdentifier:
transfer: {fileID: 11400000, guid: 7b22bba61d075c64e85adbda114d5db8, type: 2}
......@@ -9,6 +9,7 @@ public class NextLevel : MonoBehaviour
{
public void LoadNextLevel()
{
if (SceneManager.sceneCountInBuildSettings > SceneManager.GetActiveScene().buildIndex+1 )
{
int sceneIndex = SceneManager.GetActiveScene().buildIndex;
......
using System.Collections;
using System.Collections.Generic;
using UnityAtoms;
using UnityEngine;
public class StartScreen : MonoBehaviour
{
[SerializeField] private BoolVariable hasBeenLoaded;
[SerializeField] private GameObject MainMenu;
private void Start()
{
if (hasBeenLoaded.Value)
{
MainMenu.SetActive(true);
this.gameObject.SetActive(false);
}
hasBeenLoaded.Value = true;
}
// Update is called once per frame
void Update()
{
}
}
fileFormatVersion: 2
guid: 37e360c05330f334aa5e4141e5025142
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityAtoms;
using UnityEngine;
using UnityEngine.Events;
......@@ -8,23 +9,37 @@ public class LeverLogic : MonoBehaviour
{
[SerializeField] private UnityEvent _eventPulled;
[SerializeField] private UnityEvent _eventUnPulled;
[SerializeField] private PickedUpItems pulledLevers;
private SavePoint checkpoint;
[SerializeField] private StringConstant checkpointTag;
[SerializeField] private bool IsTimed = false;
[SerializeField] private float AfterTime = 0;
private bool pulled = false;
private void Start()
{
checkpoint = AtomicTags.FindByTag(checkpointTag.Value).GetComponent<SavePoint>();
}
void OnTriggerEnter2D(Collider2D other)
{
if (pulled)
{
GetComponent<ActionsToSave>()?.TransferAction(UnPull);
//GetComponent<ActionsToSave>()?.UnTransferAction(Pull);//replace by take this from list
pulledLevers.levers[0].Remove(gameObject);
Debug.Log("remove "+gameObject);
Debug.Log(pulledLevers.levers[0].Count);
UnPull();
}
else
{
GetComponent<ActionsToSave>()?.TransferAction(Pull);
GetComponent<ActionsToSave>()?.ForceTransferAction(UnPullAllLevers);
pulledLevers.levers[0].Add(gameObject);
Debug.Log("add "+gameObject );
Debug.Log(pulledLevers.levers[0].Count);
Pull();
if (IsTimed)
......@@ -43,6 +58,17 @@ public class LeverLogic : MonoBehaviour
FindObjectOfType<AudioManager>().Play("Lever");
}
public void UnPullAllLevers()
{
Debug.Log("pulling the levers. "+ pulledLevers.levers[0].Count+" are activated");
foreach (GameObject obj in pulledLevers.levers[0])
{
Debug.Log("pulling "+obj);
obj.GetComponent<LeverLogic>().UnPull();
}
}
public void UnPull()
{
pulled = false;
......@@ -56,6 +82,8 @@ public class LeverLogic : MonoBehaviour
FindObjectOfType<AudioManager>().StopPlaying("TimerTicks");
pulledLevers.levers[checkpoint.numActive+1].Remove(gameObject);
//GetComponent<ActionsToSave>()?.UnTransferAction(Pull);
UnPull();
}
}
......@@ -14,6 +14,10 @@ public class ActionsToSave : MonoBehaviour
{
transfer.AddEvent(action);
}
/*public void UnTransferAction(SavedActions.actions action)
{
transfer.RemoveEvent(action);
}*/
public void ForceTransferAction(SavedActions.actions action)
{
transfer.ForceAddEvent(action);
......
......@@ -6,6 +6,8 @@ using UnityEngine;
public class PickedUpItems : ScriptableObject
{
public List<List<GameObject>> items;
public List<List<GameObject>> levers;
public void ResetItems()
{
......
......@@ -24,6 +24,9 @@ public class SavePoint : MonoBehaviour
{
numActive = triggerNum;
PotionsThatWillDisappear.items[0].Clear();
Debug.Log("clearing levers");
PotionsThatWillDisappear.levers[0].Clear();
Debug.Log(PotionsThatWillDisappear.levers[0].Count);
}
//Debug.Log(numActive +1+ " checkpoints are active");
hasBeenActivated[numActive] = true;
......@@ -39,15 +42,20 @@ public class SavePoint : MonoBehaviour
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];
......@@ -61,14 +69,18 @@ public class SavePoint : MonoBehaviour
{
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();
//clear current set!
items.items[numActive+1].Clear();
transfer.InvokeEvent();
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])
......
......@@ -42,17 +42,24 @@ public class SavedActions : ScriptableObject
}
}*/
//AddEvent to checkpoint(active+1)
if (checkpoint.numActive>=myActions.Length)
{
Debug.Log("returning empty");
return;
}
Debug.Log(action.GetMethodInfo());
myActions[checkpoint.numActive + 1] -= action;
myActions[checkpoint.numActive + 1] += action;
}
public void RemoveEvent(actions action)
{
myActions[checkpoint.numActive + 1] -= action;
}
public void ForceAddEvent(actions action)
{
eventActivateDestructables -= action;
......@@ -64,10 +71,12 @@ public class SavedActions : ScriptableObject
{
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
......@@ -80,8 +89,9 @@ public class SavedActions : ScriptableObject
public void InvokeDestructables()
{
//Debug.Log("invoking");
Debug.Log("invoking");
eventActivateDestructables?.Invoke();
Debug.Log(eventActivateDestructables.GetMethodInfo());
}
/* public void ResetDestructables()
......
using System.Collections;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityAtoms;
using UnityEngine;
......@@ -6,15 +7,25 @@ using UnityEngine.SceneManagement;
public class MainMenu : MonoBehaviour
{
[SerializeField] private BoolVariable hasBeenLoaded;
private void Start()
{
hasBeenLoaded.Value = true;
}
public void PlayGame()
{
Debug.Log("Loaded New Scene");
SceneManager.LoadScene(3, LoadSceneMode.Single);
}
public void QuitGame()
{
hasBeenLoaded.Value = false;
#if UNITY_EDITOR
// Application.Quit() does not work in the editor so
// UnityEditor.EditorApplication.isPlaying need to be set to false to end the game
......
......@@ -43,7 +43,7 @@ public class PlayerTouching : MonoBehaviour
{
yield return new WaitForSeconds(0.05f);
Debug.Log(gameObject.name);
//Debug.Log(gameObject.name);
IsTouching.Value = false;
......
......@@ -45,7 +45,6 @@ public class AudioManager : MonoBehaviour
{
Debug.LogWarning("Sound: " + name + " not found!");
return;
}
if (s.randomized)
......@@ -56,7 +55,7 @@ public class AudioManager : MonoBehaviour
s.source.Play();
Debug.Log("Sound Played: " + s.source.clip.name);
//Debug.Log("Sound Played: " + s.source.clip.name);
}
public void StopPlaying(string sound)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment