public void Activate(uint enemyID, int count, LG_LayerType layer, eLocalZoneIndex zoneIndex, string areaName)
        {
            var enemies  = UnityEngine.Object.FindObjectsOfType <EnemyAgent>();
            int curCount = 0;

            for (int index = 0; index < enemies.Count && (count == -1 || curCount < count); index++)
            {
                var enemy = enemies[index];

                var node = enemy.CourseNode;
                if (node != null && node.LayerType == layer && node.m_zone.LocalIndex == zoneIndex && node.m_area.m_navInfo.Suffix.ToLower() == areaName)
                {
                    if (enemy.EnemyData.persistentID == enemyID && enemy.AI != null && enemy.Alive)
                    {
                        NM_NoiseData data = new NM_NoiseData()
                        {
                            noiseMaker = null,
                            position   = enemy.Position,
                            radiusMin  = 0f,
                            radiusMax  = 100f,
                            yScale     = 1f,
                            node       = enemy.CourseNode,
                            type       = NM_NoiseType.InstaDetect,
                            includeToNeightbourAreas = true,
                            raycastFirstNode         = false
                        };

                        NoiseManager.MakeNoise(data);
                        curCount++;
                    }
                }
            }
        }
Example #2
0
 protected override void OnDisable()
 {
     base.OnDisable();
     AIManager.Get().OnDisableAI(this);
     NoiseManager.UnregisterReceiver(this);
     this.m_Visible = false;
 }
Example #3
0
        public static void Postfix(pReactorState newState, pReactorState oldState, LG_WardenObjective_Reactor __instance)
        {
            if (newState.status == oldState.status)
            {
                return;
            }

            if (newState.status == eReactorStatus.Shutdown_intro)
            {
                __instance.m_sound.Post(EVENTS.LIGHTS_OFF_GLOBAL);
                __instance.m_sound.Post(EVENTS.REACTOR_SHUTDOWN);
                var noise = new NM_NoiseData()
                {
                    noiseMaker = null,
                    position   = __instance.m_terminalAlign.position,
                    radiusMin  = 7,
                    radiusMax  = 100,
                    yScale     = 1f,
                    node       = __instance.SpawnNode,
                    type       = NM_NoiseType.InstaDetect,
                    includeToNeightbourAreas = false,
                    raycastFirstNode         = false
                };
                NoiseManager.MakeNoise(noise);
            }
        }
    private void Awake()
    {
        Cursor.lockState = CursorLockMode.Confined;
        Cursor.visible   = false;

        NoiseManager.AddAudioSource(this.gameObject);

        _cars        = FindObjectsOfType <PlayerCar>();
        _music       = FindObjectOfType <MusicManager>();
        _startPoints = new Transform[_startPositions.childCount];

        for (int i = 0; i < _startPositions.childCount; i++)
        {
            _startPoints[i] = _startPositions.GetChild(i);
        }

        foreach (PlayerCar car in _cars)
        {
            car.onKill.AddListener(() => AddCarToKilled(car));
        }

        _countDownWait = new WaitForSeconds(1f);
        _sorter        = new PlayerComparer();
        _looserOrder   = new List <PlayerCar>(_cars.Length);

        // add music stuff
        _music.CurrentMusic = _matchTrack;
        onMatchStart.AddListener(() => _music.Play(1f));
    }
 private void Awake()
 {
     _rb         = GetComponent <Rigidbody>();
     _carEffects = GetComponent <CarEffects>();
     _playerCar  = GetComponent <PlayerCar>();
     NoiseManager.AddAudioSource(this.gameObject);
     PlayerInputs = ReInput.players.GetPlayer(_playerNum);
 }
Example #6
0
 public void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.tag == "Wall")
     {
         NoiseManager.MakeNoise(transform.position, noiseAmount);
         Destroy(this.gameObject);
     }
 }
Example #7
0
    public void Setup()
    {
        Music = new MusicManager();
        Voice = new VoiceManager();
        Noise = new NoiseManager();

        Reset();
    }
 //Load on initialize the game
 private void Start()
 {
     noiseManager       = NoiseManager.Instance;
     player             = GameObject.FindGameObjectWithTag("Player").transform;
     loadRegionDistance = Constants.CHUNK_SIDE * Constants.REGION_SIZE * Constants.VOXEL_SIDE * 0.9f;
     lastPlayerPos.x    = Mathf.FloorToInt(player.position.x / loadRegionDistance) * loadRegionDistance + loadRegionDistance / 2;
     lastPlayerPos.z    = Mathf.FloorToInt(player.position.z / loadRegionDistance) * loadRegionDistance + loadRegionDistance / 2;
     initRegion(Mathf.FloorToInt(player.position.x / loadRegionDistance), Mathf.FloorToInt(player.position.z / loadRegionDistance));
 }
    // Start is called before the first frame update
    void Start()
    {
        //nm = GetComponent<NoiseManager>();
        nm = GameObject.Find("NoiseManager").GetComponent <NoiseManager>();


        //nm.UpdateNoise(noiseIncrement);
        Debug.Log("YEYEY: " + nm.noiseLevel);
        //player = GameObject.FindGameObjectWithTag("Player");
    }
Example #10
0
 protected override void OnDisable()
 {
     base.OnDisable();
     AIManager.Get().OnDisableAI(this);
     NoiseManager.UnregisterReceiver(this);
     if (this.IsCat())
     {
         EnemyAISpawnManager.Get().OnDeactivatePredator(this);
     }
 }
    /// <summary>
    /// Method that is comprised of the acceleration methods
    /// </summary>
    private void Movement()
    {
        float input = PlayerInputs.GetAxisRaw("Button0");

        if (input > 0.01f && _lastInput <= 0.01f)
        {
            _onMovementStart?.Invoke();
            if (input > 0.01f && !MatchManager.Started)
            {
                NoiseManager.PlaySound(this.gameObject, "car_accelerate3", true, false, true);
            }
        }

        if (input > 0.1f && _carEffects.MoveParticles.isStopped && IsGrounded)
        {
            _carEffects.MoveParticles.Play();
            if (MatchManager.Started)
            {
                NoiseManager.PlaySound(this.gameObject, "car_motor1", true, true);
            }
        }

        if (input < 0.1f && !_carEffects.MoveParticles.isStopped)
        {
            _carEffects.MoveParticles.Stop();
            NoiseManager.StopSound(this.gameObject);
        }

        if (!IsGrounded && !_carEffects.MoveParticles.isStopped)
        {
            print("Stop particles");
            _carEffects.MoveParticles.Stop();
            NoiseManager.StopSound(this.gameObject);
        }

        if (!MatchManager.Started)
        {
            return;
        }

        if (IsGrounded)
        {
            VroomVroom();
            Skrrrrt();

            _lastInput = input;
        }
        else
        {
            _moveVector   = transform.forward * _velocity;
            _moveVector.y = _rb.velocity.y * 1.03f;
            _moveVector  += (Vector3.forward * -StripMovement.StripSpeed);
            _rb.velocity  = _moveVector;
        }
    }
Example #12
0
    /// <summary>
    /// Awake is called when the script instance is being loaded.
    /// </summary>
    private void Awake()
    {
        if (_instance == null)
        {
            _instance = this;
        }

        DontDestroyOnLoad(_instance);
        CreateSoundCollection();
        _mixerGroup = _sfxMixer;
    }
 public void StartDeath()
 {
     _deathParticles.Play();
     NoiseManager.PlaySound(this.gameObject, "car_fall" + Random.Range(1, 4));
     StartCoroutine(CallAfterTime(.7f, onCarExplosion));
     StartCoroutine(CallAfterTime(.7f, () =>
     {
         _music.Explosion();
         NoiseManager.PlaySound(this.gameObject, "car_explosion" + Random.Range(1, 3));
     }));
 }
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }

        else if (instance != null)
        {
            Destroy(gameObject);
        }
    }
Example #15
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(gameObject);
         return;
     }
 }
 // Function executed each time user interact with the inspector
 public override void OnInspectorGUI()
 {
     //base.OnInspectorGUI();
     if (DrawDefaultInspector() && Application.isPlaying)//If we changue some value in the  NoiseManager and there is a NoiseTerrainViewer we update the terrain
     {
         NoiseManager       obj         = (NoiseManager)target;
         NoiseTerrainViewer noiseViewer = obj.gameObject.GetComponent <NoiseTerrainViewer>();
         if (noiseViewer != null)
         {
             noiseViewer.GenerateTerrain();
         }
     }
 }
Example #17
0
 protected override void OnEnable()
 {
     if (!this.m_StartExecuted)
     {
         return;
     }
     base.OnEnable();
     AIManager.Get().OnEnableAI(this);
     NoiseManager.RegisterReceiver(this);
     if (!this.IsHuman() && !this.IsCat() && !this.IsCaiman() && !this.IsStringray())
     {
         Physics.IgnoreCollision(Player.Get().m_Collider, this.m_BoxCollider);
     }
 }
Example #18
0
 protected override void OnEnable()
 {
     if (!this.m_StartExecuted)
     {
         return;
     }
     base.OnEnable();
     AIManager.Get().OnEnableAI(this);
     NoiseManager.RegisterReceiver(this);
     if (!this.IsHuman() && this.m_ID != AI.AIID.Jaguar)
     {
         Physics.IgnoreCollision(Player.Get().GetComponent <Collider>(), this.m_BoxCollider);
         this.m_BoxCollider.isTrigger = true;
     }
 }
 //Load on initialize the game
 private void Start()
 {
     noiseManager = NoiseManager.Instance;
     if (useCameraPosition)
     {
         player = Camera.main.transform;//Use the Camera.main as player pos
     }
     else
     {
         player = GameObject.FindGameObjectWithTag("Player").transform;//Search gameobject with tag Player
     }
     loadRegionDistance = Constants.CHUNK_SIDE * Constants.REGION_SIZE * Constants.VOXEL_SIDE * 0.9f;
     lastPlayerPos.x    = Mathf.FloorToInt(player.position.x / loadRegionDistance) * loadRegionDistance + loadRegionDistance / 2;
     lastPlayerPos.z    = Mathf.FloorToInt(player.position.z / loadRegionDistance) * loadRegionDistance + loadRegionDistance / 2;
     initRegion(Mathf.FloorToInt(player.position.x / loadRegionDistance), Mathf.FloorToInt(player.position.z / loadRegionDistance));
 }
Example #20
0
    public override byte[] GenerateChunkData(Vector2Int vecPos, float[] biomeMerge)
    {
        byte[]  chunkData = new byte[Constants.CHUNK_BYTES];
        float[] noise     = NoiseManager.GenerateNoiseMap(scale, octaves, persistance, lacunarity, vecPos);
        for (int z = 0; z < Constants.CHUNK_VERTEX_SIZE; z++)
        {
            for (int x = 0; x < Constants.CHUNK_VERTEX_SIZE; x++)
            {
                // Get surface height of the x,z position
                float height = Mathf.Lerp(
                    NoiseManager.Instance.surfaceLevel,                                                                                                               //Biome merge height
                    (((terrainHeightCurve.Evaluate(noise[x + z * Constants.CHUNK_VERTEX_SIZE]) * 2 - 1) * maxHeightDifference) + NoiseManager.Instance.surfaceLevel), //Desired biome height
                    biomeMerge[x + z * Constants.CHUNK_VERTEX_SIZE]);                                                                                                 //Merge value,0 = full merge, 1 = no merge

                int heightY         = Mathf.CeilToInt(height);                                                                                                        //Vertex Y where surface start
                int lastVertexWeigh = (int)((255 - isoLevel) * (height % 1) + isoLevel);                                                                              //Weigh of the last vertex

                for (int y = 0; y < Constants.CHUNK_VERTEX_HEIGHT; y++)
                {
                    int index = (x + z * Constants.CHUNK_VERTEX_SIZE + y * Constants.CHUNK_VERTEX_AREA) * Constants.CHUNK_POINT_BYTE;
                    if (y < heightY - 5)
                    {
                        chunkData[index]     = 255;
                        chunkData[index + 1] = 4;                        //Rock
                    }
                    else if (y < heightY)
                    {
                        chunkData[index]     = 255;
                        chunkData[index + 1] = 1;                        //dirt
                    }
                    else if (y == heightY)
                    {
                        chunkData[index]     = (byte)lastVertexWeigh;
                        chunkData[index + 1] = 0;                        //grass
                    }
                    else
                    {
                        chunkData[index]     = 0;
                        chunkData[index + 1] = Constants.NUMBER_MATERIALS;
                    }
                }
            }
        }
        return(chunkData);
    }
Example #21
0
 //Load on initialize the game
 private void Start()
 {
     //Debug.Log("ChunkManager Started");
     noiseManager       = NoiseManager.Instance;
     player             = GameObject.FindGameObjectWithTag("Player").transform;
     loadRegionDistance = Constants.CHUNK_SIDE * Constants.REGION_SIZE * Constants.VOXEL_SIDE * 0.9f;
     lastPlayerPos.x    = Mathf.FloorToInt(player.position.x / loadRegionDistance) * loadRegionDistance + loadRegionDistance / 2;
     lastPlayerPos.z    = Mathf.FloorToInt(player.position.z / loadRegionDistance) * loadRegionDistance + loadRegionDistance / 2;
     initRegion(Mathf.FloorToInt(player.position.x / loadRegionDistance), Mathf.FloorToInt(player.position.z / loadRegionDistance));
     if (loadedScene)
     {
         HiddeRemoveChunk();
         CheckNewChunks();
         LoadChunkFromList();
         CheckRegion();
     }
     startingChunksToLoad = chunkLoadList.Count;
 }
Example #22
0
    float[] getNoise(float x, float y, Vector3 chunkOrigin)
    {
        float[] generatedNoiseValues = new float[m_vectorNoiseGens.Length];
        for (int i = 0; i < m_vectorNoiseGens.Length; i++)
        {
            if (m_vectorNoiseGens[i] != null)
            {
                NoiseManager p = m_vectorNoiseGens[i];
                generatedNoiseValues[i] = p.getNoise(x + chunkOrigin.x, y + chunkOrigin.z, ref m_elevationNoise);
            }
        }
        string str = "";

        foreach (var a in generatedNoiseValues)
        {
            str += a + " ";
        }
        //Debug.Log(str);
        return(generatedNoiseValues);
    }
    private IEnumerator MatchCountdown(int time)
    {
        CountdownTimerUI countdown = FindObjectOfType <CountdownTimerUI>();

        // Wait 1 second before the match actually starts
        yield return(_countDownWait);

        NoiseManager.PlaySound(this.gameObject, "321GO");
        for (int i = time; i > 0; i--)
        {
            onMatchStartTimer?.Invoke(i);
            yield return(_countDownWait);
        }

        countdown.Disable();
        yield return(_countDownWait);

        Started = true;
        onMatchStart?.Invoke();
    }
Example #24
0
    void FixedUpdate()
    {
        float horizontal = player.GetAxis("Horizontal");
        float vertical   = player.GetAxis("Vertical");
        bool  running    = player.GetButton("Run");

        Vector2 dir        = new Vector2(horizontal, vertical);
        float   speed      = running ? runSpeed : walkSpeed;
        float   noiseLevel = rb.velocity.magnitude * volumeMultiplier;

        rb.AddForce(dir * speed);

        if (noiseLevel > 0)
        {
            NoiseManager.MakeNoise(transform.position, noiseLevel);
        }

        // DEBUG
        noiseCircle.localScale = Vector2.one * noiseLevel * 2;
    }
    private void Update()
    {
        PlayerMovement();


        if (movementHistory.Count > 10)
        {
            movementHistory.RemoveAt(0);
        }
        movementHistory.Add(new Vector3(transform.position.x, 0, transform.position.z));

        float deltaMovement = 0;

        for (int i = 0; i < movementHistory.Count - 1; i++)
        {
            deltaMovement += Vector3.Distance(movementHistory[i], movementHistory[i + 1]);
        }

        NoiseManager.SendNoise(transform.position, deltaMovement * 10);

        Jump();
    }
Example #26
0
 // Use this for initialization
 void Start()
 {
     NoiseManager.MakeNoise(transform.position, noiseAmount);
     Destroy(this.gameObject);
 }
Example #27
0
 void Awake()
 {
     instance    = this;
     OnNoiseMade = new NoiseEvent();
 }
Example #28
0
    public override byte[] GenerateChunkData(Vector2Int vecPos, float[] biomeMerge)
    {
        int surfaceStart = NoiseManager.Instance.surfaceLevel;         //Avoid too high value that generate bad mesh

        byte[]  chunkData = new byte[Constants.CHUNK_BYTES];
        float[] noise     = NoiseManager.GenerateExtendedNoiseMap(scale, octaves, persistance, lacunarity, vecPos);
        for (int z = 0; z < Constants.CHUNK_VERTEX_SIZE; z++)        //start a 1 because the noise start at -1 of the chunk vertex
        {
            for (int x = 0; x < Constants.CHUNK_VERTEX_SIZE; x++)    //start a 1 because the noise start at -1 of the chunk vertex
            {
                // Get surface height of the x,z position 1276120704
                float height = Mathf.Lerp(
                    NoiseManager.Instance.surfaceLevel,                                                                                                             //Biome merge height
                    (terrainHeightCurve.Evaluate(noise[(x + 1) + (z + 1) * (Constants.CHUNK_VERTEX_SIZE + 2)]) * (maxSurfaceheight - surfaceStart) + surfaceStart), //Desired biome height
                    biomeMerge[x + z * Constants.CHUNK_VERTEX_SIZE]);                                                                                               //Merge value,0 = full merge, 1 = no merge

                //557164096
                int   heightY         = Mathf.CeilToInt(height);                           //Vertex Y where surface start
                int   lastVertexWeigh = (int)((255 - isoLevel) * (height % 1) + isoLevel); //Weigh of the last vertex
                float slope           = CalculateSlope((x + 1), (z + 1), noise);

                for (int y = 0; y < Constants.CHUNK_VERTEX_HEIGHT; y++)
                {
                    int index = (x + z * Constants.CHUNK_VERTEX_SIZE + y * Constants.CHUNK_VERTEX_AREA) * Constants.CHUNK_POINT_BYTE;                    //apply x-1 and z-1 for get the correct index
                    if (y < heightY - 5)
                    {
                        chunkData[index]     = 255;
                        chunkData[index + 1] = 4;                        //Rock
                    }
                    else if (y < heightY)
                    {
                        chunkData[index] = 255;
                        if (slope > rockLevel)
                        {
                            chunkData[index + 1] = 4;                            //Rock
                        }
                        else if (slope < dirtLevel && y > snowHeight)            //Avoid dirt in snow areas
                        {
                            chunkData[index + 1] = 3;
                        }
                        else
                        {
                            chunkData[index + 1] = 1;                            //dirt
                        }
                    }
                    else if (y == heightY)
                    {
                        chunkData[index] = (byte)lastVertexWeigh;                        //
                        if (slope > rockLevel)
                        {
                            chunkData[index + 1] = 4;                            //Mountain Rock
                        }
                        else if (slope > dirtLevel)
                        {
                            chunkData[index + 1] = 1;                            //dirt
                        }
                        else
                        {
                            if (y > snowHeight)
                            {
                                chunkData[index + 1] = 3;                                //snow
                            }
                            else
                            {
                                chunkData[index + 1] = 0;                                //grass
                            }
                        }
                    }
                    else
                    {
                        chunkData[index]     = 0;
                        chunkData[index + 1] = Constants.NUMBER_MATERIALS;
                    }
                }
            }
        }
        return(chunkData);
    }
 void Start()
 {
     //Debug.Log("Make Noise SuperClass");
     noiseM = GameObject.Find("NoiseManager").GetComponent <NoiseManager>();
     //Debug.Log("YEYEY: " + noiseM.noiseLevel);
 }
Example #30
0
    IEnumerator Shoot()
    {
        while (App.Instance.isPlaying)
        {
            if (weapon != null && !dead && fire)
            {
                if (weapon.melee)
                {
                    float elapsedTime = 0;
                    if (weapon.swingRotate.magnitude != 0)
                    {
                        Quaternion startRot = gun.transform.rotation;

                        while (elapsedTime <= weapon.swingTime)
                        {
                            elapsedTime           += Time.deltaTime;
                            gun.transform.rotation = Quaternion.Lerp(startRot, Quaternion.Euler(weapon.swingRotate), elapsedTime / weapon.swingTime);
                            yield return(null);
                        }

                        elapsedTime = 0;
                        while (elapsedTime <= weapon.swingTime * 1.5f)
                        {
                            elapsedTime += Time.deltaTime;

                            gun.transform.rotation = Quaternion.Lerp(Quaternion.Euler(weapon.swingRotate), startRot, elapsedTime / (weapon.swingTime * 1.5f));
                            yield return(null);
                        }

                        if (GetComponentInChildren <MeleeWeapon>())
                        {
                            GetComponentInChildren <MeleeWeapon>().senderTag = gameObject.tag;
                        }
                    }
                    else
                    {
                        Vector3 startPos = gunPos.position;
                        Vector3 moveTo   = startPos + (gun.transform.right);

                        while (elapsedTime <= weapon.swingTime / 2)
                        {
                            elapsedTime           += Time.deltaTime;
                            gun.transform.position = Vector3.Lerp(startPos, moveTo, elapsedTime / (weapon.swingTime / 2));
                            yield return(null);
                        }


                        elapsedTime = 0;
                        while (elapsedTime <= weapon.swingTime / 2)
                        {
                            elapsedTime           += Time.deltaTime;
                            gun.transform.position = Vector3.Lerp(moveTo, gunPos.position, elapsedTime / (weapon.swingTime / 2));
                            yield return(null);
                        }
                    }

                    weapon.durability--;

                    if (weapon.durability <= 0)
                    {
                        Destroy(gun);
                        weapon = null;
                    }

                    yield return(null);
                }
                else if (ammo > 0)
                {
                    //create bullet
                    foreach (Transform t in shootPos)
                    {
                        Vector3 pos = new Vector3(t.position.x, t.position.y, -1);
                        Bullet  b   = Instantiate(weapon.bullet, pos, t.rotation).GetComponent <Bullet>();
                        b.speed    += rig.velocity.normalized.magnitude;
                        b.senderTag = gameObject.tag;
                    }

                    StartCoroutine(MuzzleFlash());
                    NoiseManager.MakeNoise(transform.position, 0.2f, 12.5f, "gun");

                    if (gameObject.CompareTag("Player"))
                    {
                        App.Instance.cameraController.Shake(weapon.shakeTime);
                    }

                    // Instantiate(weapon.muzzle, shootPos.position, shootPos.rotation);

                    AudioController.PlaySound(weapon.GetRandomClip());
                    ammo--;

                    if (ammo <= 0)
                    {
                        if (weapon.destroyAfterThrow)
                        {
                            Destroy(gun);
                        }
                        else
                        {
                            ThrowGun();
                        }

                        if (charAnim != null)
                        {
                            charAnim.SetInteger("weapon", 0);
                        }
                        weapon = null;
                    }

                    if (weapon != null)
                    {
                        yield return(new WaitForSeconds(weapon.fireRate));
                    }
                }
            }


            yield return(null);
        }

        yield return(null);
    }