Example #1
0
        void Awake()
        {
            _instance = this;

            foreach (string channel in preload_channels)
            {
                CreateChannel(channel);
            }
        }
Example #2
0
 void OnTriggerEnter2D(Collider2D collision)
 {
     if (tag_required == "" || tag_required == collision.gameObject.tag)
     {
         collisions.Add(collision);
         if (init_timer >= 0f)
         {
             TheAudio.Play("switch", activate_sound, 0.5f);
         }
     }
 }
Example #3
0
        public void Close()
        {
            if (is_opened)
            {
                is_opened = false;
                //collide.enabled = true;
                target_pos = start_pos;

                //animator.SetBool("Open", false);
                TheAudio.Play("door", audio_door_close, 0.5f);

                if (unique_id)
                {
                    unique_id.SetValue(0);
                }
            }
        }
Example #4
0
        public void Open()
        {
            if (!is_opened)
            {
                is_opened = true;
                //collide.enabled = false;
                Vector3 move_dir = transform.up;
                target_pos   = start_pos + move_dir.normalized * max_move;
                target_pos.z = 0f;

                //animator.SetBool("Open", true);
                TheAudio.Play("door", audio_door_open, 0.5f);

                if (unique_id)
                {
                    unique_id.SetValue(1);
                }
            }
        }
Example #5
0
        public void Activate()
        {
            //Can't activate twice very fast
            if (timer < 0f)
            {
                return;
            }

            if (!no_return || state == start_state)
            {
                timer = -0.8f;

                //Change state
                if (state == LeverState.left)
                {
                    state = (can_be_center) ? LeverState.center : LeverState.right;
                }
                else if (state == LeverState.center)
                {
                    state = LeverState.right;
                }
                else if (state == LeverState.right)
                {
                    state = LeverState.left;
                }

                //Audio
                TheAudio.Play("lever", activate_sound, 0.5f);

                //Trigger
                if (OnTriggerLever != null)
                {
                    OnTriggerLever.Invoke();
                }
            }
        }