public void Init() { if (active) { return; } associatedRespawnable.Clear(); foreach (var obj in levelContainer.GetAllEntities()) { associatedRespawnable.Add(obj); } player = levelContainer.Player?.GetComponent <InteractiveBehaviour>(); if (player) { player.GetVariable("LIFE")?.AddOnSetValue(RespawnPlayer); } else { Debug.LogError("There is no player"); } foreach (IRespawnable obj in associatedRespawnable) { obj.SaveCheckpoint(); } active = true; }
ConsoleLine.ECommandResult Do(string[] args) { if (args.Length != 2) { return(ConsoleLine.ECommandResult.Failed); } string objName = args[0]; int numColumn = -1; if (!int.TryParse(args[1], out numColumn)) { return(ConsoleLine.ECommandResult.Failed); } if (numColumn < 1 || numColumn > nbrColumn) { return(ConsoleLine.ECommandResult.Failed); } InteractiveBehaviour toSpawn = objectsToInstantiate.Find(obj => string.Compare(obj.Name, objName, true) == 0); if (toSpawn == null) { return(ConsoleLine.ECommandResult.Failed); } Instantiate(toSpawn, columns[numColumn - 1].position, Quaternion.identity); return(ConsoleLine.ECommandResult.Successed); }
private void UpdateObjectInView(InteractiveBehaviour obj, bool inView) { if (inView && objectView.Contains(obj) == false) { objectView.Add(obj); } else if (!inView && objectView.Contains(obj)) { objectView.Remove(obj); } }
private void UpdateEntities(InteractiveBehaviour obj, bool isCreated) { IRespawnable[] respawnablesComp = obj.GetComponentsInChildren <IRespawnable>(); foreach (IRespawnable comp in respawnablesComp) { if (isCreated) { allEntities.Add(comp); } else { allEntities.Remove(comp); } } }
public void Init(InteractiveBehaviour entity, IReadOnlyCollection <EntityVariable> variables, Transform target) { owner = entity; this.target = target; if (hideName) { if (timeToCrypt > 0.0f) { InvokeRepeating("CryptName", 0.0f, timeToCrypt); } else { objName.text = "<color=#ffffffff>" + owner.Name.Crypt() + "</color>"; } } else { objName.text = "<color=#ffffffff>" + owner.Name + "</color>"; } console = FindObjectOfType <ConsoleLine>(); dico = console.GetComponent <ConsoleDictionnary>(); // temporary fix to add objects without having a ref to the main camera if (mainCamera == null) { mainCamera = Camera.main; } console.AddOnWriteCommand(SetColor); console.AddOnActiveCommande(OnActiveConsole); InitTransform(); InitVariable(variables); }
private void OnDestroy() { InteractiveBehaviour.RemoveOnCameraView(UpdateObjectInView); }
private void Awake() { objectView = new List <InteractiveBehaviour>(); InteractiveBehaviour.AddOnCameraView(UpdateObjectInView); }
private void OnDestroy() { InteractiveBehaviour.RemoveOnCreateEntity(UpdateEntities); }
private void Awake() { allEntities = new HashSet <IRespawnable>(); InteractiveBehaviour.AddOnCreateEntity(UpdateEntities); }
private void Awake() { interactiveVariable = gameObject.GetComponent <InteractiveBehaviour>(); }
private static void InvokeOnCreateEntity(InteractiveBehaviour obj, bool isCreated) { OnCreateEntity?.Invoke(obj, isCreated); }
private static void InvokeOnCameraView(InteractiveBehaviour obj, bool visible) { OnCameraView?.Invoke(obj, visible); }