Beispiel #1
0
        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;
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
 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);
     }
 }
Beispiel #4
0
        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);
                }
            }
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
 private void OnDestroy()
 {
     InteractiveBehaviour.RemoveOnCameraView(UpdateObjectInView);
 }
Beispiel #7
0
 private void Awake()
 {
     objectView = new List <InteractiveBehaviour>();
     InteractiveBehaviour.AddOnCameraView(UpdateObjectInView);
 }
Beispiel #8
0
 private void OnDestroy()
 {
     InteractiveBehaviour.RemoveOnCreateEntity(UpdateEntities);
 }
Beispiel #9
0
 private void Awake()
 {
     allEntities = new HashSet <IRespawnable>();
     InteractiveBehaviour.AddOnCreateEntity(UpdateEntities);
 }
Beispiel #10
0
 private void Awake()
 {
     interactiveVariable = gameObject.GetComponent <InteractiveBehaviour>();
 }
Beispiel #11
0
 private static void InvokeOnCreateEntity(InteractiveBehaviour obj, bool isCreated)
 {
     OnCreateEntity?.Invoke(obj, isCreated);
 }
Beispiel #12
0
 private static void InvokeOnCameraView(InteractiveBehaviour obj, bool visible)
 {
     OnCameraView?.Invoke(obj, visible);
 }