Ejemplo n.º 1
0
 void Start()
 {
     collider           = GetComponent <Collider>();
     collider.isTrigger = true;
     echoManager        = FindObjectOfType <EchoManager>();
     pool = echoManager.pool;
 }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (em == null)
        {
            em = GameObject.Find("EchoManager").GetComponent <EchoManager>();
        }

        if (spawnEchos)
        {
            timeSinceLastEcho += Time.deltaTime;
            if (timeSinceLastEcho > timeBetweenEchos)
            {
                spawnTime = 0.0f;
                GameObject  temp = em.spawnAnEchoLocation(gameObject.transform.position);
                EchoSpawner t    = temp.GetComponent <EchoSpawner>();
                //Debug.Log(gameObject.name + ": "+ t.getEchoLocation());
                t.echoColor = echoColor;
                t.maxRadius = maxRadius;
                t.fade      = fade;
                t.echoSpeed = speed;

                timeSinceLastEcho = 0.0f;
                ++numEchoSpawned;
                if (numEchoSpawned > numEchos)
                {
                    timeSinceLastEcho = float.MaxValue;
                    numEchoSpawned    = 0;
                    spawnEchos        = false;
                }
            }
        }
    }
Ejemplo n.º 3
0
        public void UserInput(string argument)
        {
            var command = argument.Split(' ');

            if (command.Length < 2)
            {
                return;
            }

            if (command[0] != "RESET")
            {
                return;
            }

            ConfigHolder.Set(PriorityConfigKey, $"{GridTerminalSystem.GetBlocks().Count()}");
            ConfigHolder.Set(NameConfigKey, Me.CubeGrid.CustomName);

            switch (command[1])
            {
            case "SAFE":
            {
                ConfigHolder.Set(BroadcastEnabledConfigKey, "false");
                ConfigHolder.Set(IgnorePriorityConfigKey, "true");
                ConfigHolder.Set(IgnoreNameConfigKey, "true");
                break;
            }

            case "NORMAL":
            {
                ConfigHolder.Set(BroadcastEnabledConfigKey, "true");
                ConfigHolder.Set(IgnorePriorityConfigKey, "false");
                ConfigHolder.Set(IgnoreNameConfigKey, "false");
                break;
            }

            case "OBSTINATE":
            {
                ConfigHolder.Set(BroadcastEnabledConfigKey, "true");
                ConfigHolder.Set(IgnorePriorityConfigKey, "true");
                ConfigHolder.Set(IgnoreNameConfigKey, "false");
                break;
            }

            default:
            {
                EchoManager.Print($"Template {command[1]} does not exist");
                return;
            }
            }

            EchoManager.Print($"Reset configuration to the template {command[1]}");
            ConfigHolder.Save();
        }
        public void Dispose()
        {
            _logger.DebugFormat("Disposing dispatcher");

            try
            {
                RemoveAll();
            }
            finally
            {
                EchoManager.Dispose();
            }
        }
Ejemplo n.º 5
0
 public Manager()
 {
     if (Manager.manager != null)
     {
         throw new UnityException("Cannot create another instance of Manager");
     }
     this.rManager = new RelayManager();
     this.sManager = new SatelliteManager();
     this.eManager = new EchoManager();
     this.cManager = new CityManager();
     this.lManager = new LeverManager();
     this.mManager = new MusicManager();
 }
Ejemplo n.º 6
0
 // Use this for initialization
 void Start()
 {
     if (inputDevice == null || Microphone.devices != null)
     {
         Debug.Log(string.Format("{0} audio input devices connected", Microphone.devices.Length));
         inputDevice = Microphone.devices[0];
         audioClip   = Microphone.Start(inputDevice, true, 999, 44100);
     }
     em = GetComponent <EchoManager>();
     if (em != null)
     {
         Debug.Log(em.Proof);
     }
 }
Ejemplo n.º 7
0
        public void Initialize()
        {
            UpdateFromConfig();

            EchoManager.AddStatusLine("NIN.NAME.STATUS", () => _status);
            EchoManager.AddStatusLine("NIN.NAME.BROADCAST", () => $"Broadcast tag: {_broadcastTag}");
            EchoManager.Print("Monitoring grid for name changes...");
            EchoManager.Print("The name is configured inside the custom data of this block.");
            EchoManager.Print("Or run one of the following commands for a default configuration:");
            EchoManager.Print("'RESET SAFE' Makes sure the name wont cause the grid to be cleaned up but otherwise does nothing.");
            EchoManager.Print("'RESET NORMAL' Sets the grid name to the stored name unless another script is on the same grid with a higher priority.");
            EchoManager.Print("'RESET OBSTINATE' Sets the grid name to the stored name. Ignores priority and has max priority.");
            EchoManager.Print("Default priority is the logic block count of the grid.");
            EchoManager.Print("Default name is whatever the grid name was on configuration reset.");
        }
Ejemplo n.º 8
0
    public override void Init(GameObject obj, PlayerMovement PM, MonoBehaviour MB, GameObject statusBar)
    {
        if (this.obj == null)
        {
            this.obj       = obj;
            this.PM        = PM;
            this.MB        = MB;
            this.statusBar = statusBar;
            this.EM        = obj.GetComponent <EchoManager>();

            SR           = obj.transform.GetChild(2).GetComponent <SpriteRenderer>();
            statusPrefab = Resources.Load("PhotonPrefabs/Skills/StatusEcho") as GameObject;
        }

        this.MB.StopAllCoroutines();
        this.MB.StartCoroutine(Effect());
    }
Ejemplo n.º 9
0
        private IEnumerable <IMyBroadcastListener> UpdateBroadcast()
        {
            var broadcastTag = $"{Me.CubeGrid.EntityId}.NIN.NAME";

            if (_broadcastTag != broadcastTag)
            {
                IGC.UnregisterBroadcastListener(_broadcastTag);
                _broadcastTag = broadcastTag;
            }
            var broadcastListener = IGC.RegisterBroadcastListener(broadcastTag);

            yield return(null);

            IGC.SendBroadcastMessage(broadcastTag, _priority);

            yield return(null);

            while (broadcastListener.HasPendingMessage)
            {
                var message          = broadcastListener.AcceptMessage();
                var priorityReceived = -1;
                try
                {
                    priorityReceived = (int)message.Data;
                }
                catch
                {
                    EchoManager.Print($"Received an invalid message in broadcast channel: {message.Data}");
                }

                if (!_ignorePriority && priorityReceived > _priority)
                {
                    Disable();
                }

                yield return(null);
            }

            EnableIfReady();

            yield return(broadcastListener);
        }
Ejemplo n.º 10
0
    // Update is called once per frame
    void Update()
    {
        if (em == null)
        {
            em = GameObject.Find("EchoManager").GetComponent <EchoManager>();
        }

        spawnTime += Time.deltaTime;
        if (spawnTime >= intervalTimeOfEchos)
        {
            spawnTime = 0.0f;
            GameObject  temp = em.spawnAnEchoLocation(gameObject.transform.position);
            EchoSpawner t    = temp.GetComponent <EchoSpawner>();
            //Debug.Log(gameObject.name + ": "+ t.getEchoLocation());
            t.echoColor = echoColor;
            t.maxRadius = maxRadius;
            t.fade      = fade;
            t.echoSpeed = speed;
        }
    }
Ejemplo n.º 11
0
    public void ResetExceptMusic()
    {
        this.rManager.Destroy();
        this.rManager = null;

        this.sManager.Destroy();
        this.sManager = null;

        this.eManager.Destroy();
        this.eManager = null;

        this.cManager.Destroy();
        this.cManager = null;

        this.lManager.Destroy();
        this.lManager = null;

        this.rManager = new RelayManager();
        this.sManager = new SatelliteManager();
        this.eManager = new EchoManager();
        this.cManager = new CityManager();
        this.lManager = new LeverManager();
    }
Ejemplo n.º 12
0
    public void Destroy()
    {
        this.rManager.Destroy();
        this.rManager = null;

        this.sManager.Destroy();
        this.sManager = null;

        this.eManager.Destroy();
        this.eManager = null;

        this.cManager.Destroy();
        this.cManager = null;

        this.lManager.Destroy();
        this.lManager = null;

        this.mManager.Destroy();
        this.mManager = null;


        Manager.manager = null;
        //GameObject.Destroy(gameObject);
    }
 // Start is called before the first frame update
 void Start()
 {
     text.text = name;
     manager   = GameObject.Find("EchoManager").GetComponent <EchoManager>();
     playspace.transform.localScale = Vector3.one * manager.settings.diameter;
 }
Ejemplo n.º 14
0
    void Update()
    {
        if (em == null)
        {
            em            = GameObject.Find("EchoManager").GetComponent <EchoManager>();
            waitSoundTime = System.DateTime.Now;
            GameObject temp = em.spawnAnEchoLocation(Color.green, gameObject.transform.position);
            temp.GetComponent <EchoSpawner>().echoSpeed = 1f;
            temp.GetComponent <EchoSpawner>().maxRadius = 2;
            temp.GetComponent <EchoSpawner>().echoColor = Color.green;
            temp.GetComponent <EchoSpawner>().echoMaterial.SetColor("_MainColor" + temp.GetComponent <EchoSpawner>().getEchoLocation(), Color.green);
        }

        if (System.DateTime.Now.Subtract(waitSoundTime).Seconds >= 1)
        {
            waitSoundTime = System.DateTime.Now;


            GameObject temp = em.spawnAnEchoLocation(Color.green, gameObject.transform.position);
            temp.GetComponent <EchoSpawner>().echoSpeed = 1f;
            temp.GetComponent <EchoSpawner>().maxRadius = 2;
            temp.GetComponent <EchoSpawner>().echoColor = Color.green;
            temp.GetComponent <EchoSpawner>().echoColor = Color.green;
            temp.GetComponent <EchoSpawner>().echoMaterial.SetColor("_MainColor" + temp.GetComponent <EchoSpawner>().getEchoLocation(), Color.green);
        }

        //Don't move other people plz.
        if (!isLocalPlayer)
        {
            return;
        }

        #region Camera Fixes
        if (followingCamera == null)
        {
            GameObject newCam = GameObject.Find("PhysicalCamera");
            if (newCam != null)
            {
                followingCamera = newCam;
                followingCamera.transform.parent = transform;
            }
        }
        if (otherCamera == null)
        {
            GameObject newCam = GameObject.Find("SpiritualCamera");
            if (newCam != null)
            {
                otherCamera = newCam;
                otherCamera.transform.parent = transform;
            }
        }

        followingCamera.SetActive(true);
        otherCamera.SetActive(false);
        #endregion

        float   yMovement             = 0;
        float   xMovement             = Input.GetAxis("Horizontal") * Time.deltaTime * speed;
        float   zMovement             = Input.GetAxis("Vertical") * Time.deltaTime * speed;
        Vector3 currentMovementNormal = new Vector3(xMovement, 0, zMovement).normalized;
        bool    sprinting             = false;

        if (isSwimming)
        {
            xMovement *= swimMovementRate;
            zMovement *= swimMovementRate;
            if (Input.GetButton("Jump"))
            {
                yMovement = swimUpSpeed * Time.deltaTime;
            }
            else
            {
                yMovement = -sinkSpeed * Time.deltaTime;
            }
        }
        else if (leavingWater && Input.GetButton("Jump"))
        {
            if (controller.isGrounded)
            {
                leavingWater = false;
            }
            else
            {
                yMovement = 0;
            }
        }
        else
        {
            if (controller.isGrounded && !jumping)
            {
                gravityVelocity += Physics.gravity.y * Time.deltaTime;
                yMovement        = gravityVelocity * Time.deltaTime;
                fallTime         = 0;

                if (lastFrameJumping)
                {
                    audio.PlayOneShot(landingSound);
                    lastFrameJumping = false;
                }

                if (Input.GetButton("Jump"))
                {
                    jumpTracking             = 0;
                    jumping                  = true;
                    jumpingMovementDirection = new Vector3(xMovement, 0, zMovement);
                    currJumpCap              = transform.localPosition.y + jumpHeight + Physics.gravity.y * Time.deltaTime;
                    audio.PlayOneShot(jumpSound);
                }
                else if (Input.GetButton("Sprint"))
                {
                    sprinting  = true;
                    xMovement *= runMultiplier;
                    zMovement *= runMultiplier;
                }
            }
            else if (!controller.isGrounded)
            {
                if (!jumping)
                {
                    gravityVelocity  = (Physics.gravity.y * Time.deltaTime * fallTime);
                    yMovement        = gravityVelocity;
                    fallTime        += Time.deltaTime * 3.0f;
                    lastFrameJumping = true;
                }
                else
                {
                    gravityVelocity = (currJumpCap - transform.localPosition.y) / jumpingGravityEffectModifier;
                    float jumpShift = (jumpSpeed + gravityVelocity) * Time.deltaTime;
                    jumpTracking    += jumpShift;
                    yMovement        = jumpShift;
                    lastFrameJumping = true;
                    if (jumpTracking >= jumpHeight)
                    {
                        jumping  = false;
                        fallTime = 0;
                    }
                }
            }
        }

        // adjust rotationMovement
        hRotation += Input.GetAxisRaw("RotateCameraHorizontal") * Time.deltaTime * hCameraSpeed;
        vRotation += Input.GetAxisRaw("RotateCameraVertical") * Time.deltaTime * vCameraSpeed;
        if (vRotation > posCameraBounds)
        {
            vRotation = posCameraBounds;
        }
        else if (vRotation < negCameraBounds)
        {
            vRotation = negCameraBounds;
        }

        Vector2 groundMotion = new Vector2(xMovement, zMovement);
        animator.SetBool("OnGround", controller.isGrounded);
        if (groundMotion.magnitude > 0)
        {
            if (sprinting)
            {
                animator.SetFloat("Forward", 1.0f);
            }
            else
            {
                animator.SetFloat("Forward", .7f);
            }
        }
        else
        {
            animator.SetFloat("Forward", 0);
        }

        if (previousHRotation > hRotation)
        {
            animator.SetFloat("Turn", -100);
        }
        else if (previousHRotation < hRotation)
        {
            animator.SetFloat("Turn", 100);
        }
        else
        {
            animator.SetFloat("Turn", 0);
        }

        if (controller.isGrounded && groundMotion.magnitude > 0)
        {
            if (!dustCloud.isPlaying)
            {
                dustCloud.Play();
            }
        }
        else
        {
            dustCloud.Stop();
        }

        if (Mathf.Abs(xMovement) > 0 || Mathf.Abs(zMovement) > 0)
        {
            System.Random r = new System.Random();
            int           audioToPlayIndex = r.Next(footsteps.Length);
            if (!walkingSoundCooldown && controller.isGrounded)
            {
                audio.PlayOneShot(footsteps[audioToPlayIndex]);
                StartCoroutine(ResetWalkSound(sprinting ? .25f : .4f));
            }
        }

        // change rotation based on current camera angle
        transform.localEulerAngles = new Vector3(0, hRotation, 0);
        Quaternion cameraRotation = Quaternion.Euler(transform.localEulerAngles);
        followingCamera.transform.position = new Vector3(followingCamera.transform.position.x, transform.position.y + vRotation, followingCamera.transform.position.z);
        // apply movement
        Vector3 moveVector = new Vector3(xMovement, yMovement, zMovement);
        controller.Move(cameraRotation * moveVector);

        previousHRotation = hRotation;
    }
Ejemplo n.º 15
0
 public void subscribeToDeath(EchoManager manager)
 {
     listener = manager;
 }
Ejemplo n.º 16
0
 private void UpdateName()
 {
     EchoManager.Print($"Changing grid name from: '{Me.CubeGrid.CustomName}' to: '{_savedName}'");
     Me.CubeGrid.CustomName = _savedName;
 }