Exemplo n.º 1
1
 // Use this for initialization
 void Start()
 {
     if (instance == null) {
                     instance = this;
                     audioSources = GetComponents<AudioSource> ();
             }
 }
Exemplo n.º 2
0
 // Use this for initialization
 void Awake()
 {
     if (!instance) {
                     instance = this;
             }
             audioSources = GetComponents<AudioSource> ();
 }
Exemplo n.º 3
0
    public void PlaySFX(SFX sfx)
    {
        if(!SfxSource1.isPlaying)
        {
            SfxSource1.clip = sfx.Clip;

            if(sfx.Loop)
                SfxSource1.loop = true;
            else
                SfxSource1.loop = false;

            if(sfx.RandomisePitch)
                SfxSource1.pitch = 1.0f + Random.Range(-sfx.PitchRange, sfx.PitchRange);
            else
                SfxSource1.pitch = 1.0f;

            SfxSource1.Play();
        }
        else
        {
            SfxSource2.clip = sfx.Clip;

            if(sfx.Loop)
                SfxSource2.loop = true;
            else
                SfxSource2.loop = false;

            if(sfx.RandomisePitch)
                SfxSource2.pitch = 1.0f + Random.Range(-sfx.PitchRange, sfx.PitchRange);
            else
                SfxSource2.pitch = 1.0f;

            SfxSource2.Play();
        }
    }
Exemplo n.º 4
0
 public static void Play(SFX sfx)
 {
     try
       {
     SFXList[sfx].Play();
       }
       catch
       {
       }
 }
Exemplo n.º 5
0
        public void playAudio(AudioSource AS, SFX sfxIdx, audioMode aM)
        {

            AS.clip = sfx[(int) sfxIdx - 1];
            AS.volume = 100;
            AS.loop = true;
            if (aM == audioMode.Once) AS.loop = false;
            
            AS.dopplerLevel = 1;
            AS.Play();
        }
Exemplo n.º 6
0
    void Start()
    {
		log = gameObject.AddComponent<SuccessfulActionLog>();
        agent = GetComponent<NavMeshAgent>();

        targetIndicator = transform.Find("Target").gameObject;
        targetIndicator.SetActive(false);

        sfx = transform.Find("SFX").GetComponent<SFX>();

        textBox = GameObject.Find("textbox");
		t = GameObject.Find("report").GetComponent<Text>();
		textBox.SetActive(false);
	}
Exemplo n.º 7
0
	// Use this for initialization
	void Start () {

		/*
		if (sound) {
			
			DestroyImmediate (gameObject);
			
		} else {
			
			DontDestroyOnLoad (gameObject);
			sound = this.gameObject;
			
		}*/
		if (sound) {
			
			DestroyImmediate (this);
			
		} else {
			
			DontDestroyOnLoad (gameObject);
			sound = this;
			
		}
	}
Exemplo n.º 8
0
 private void playSound(SFX which, bool unique)
 {
     //TODO there have got to be half a dozen cases where this doesn't work right...
     if (unique)
     {
         SoundEffectInstance cur;
         if (playing.TryGetValue(which, out cur))
         {
             cur.Stop();
             cur.Play();
             return;
         }
         SoundEffectInstance sei = getSound(which).CreateInstance();
         playing.Add(which, sei);
         sei.Play();
     }
     else
     {
         SoundEffect s = getSound(which);
         if (s != null)
         {
             s.Play();
         }
     }
 }
Exemplo n.º 9
0
        public override void Update()
        {
            base.Update();

            //Animations
            if (ammo >= 3)
            {
                sprite.SetAnimation("3");
            }
            else if (ammo == 2)
            {
                sprite.SetAnimation("2");
            }
            else if (ammo == 1)
            {
                sprite.SetAnimation("1");
            }
            else
            {
                sprite.SetAnimation("0");
            }


            if (tempX != 0f && tempY != 0f)
            {
                d = new DuckPlaceHolder(tempX, tempY);
                Level.Add(new DuckPlaceHolder(tempX, tempY));
            }

            if (g != null && g._timer <= 0.1f && teleported == false)
            {
                tempX      = g.position.x;
                tempY      = g.position.y - 10f;
                teleported = true;
            }

            if (duck != null)
            {
                if (g != null && teleported == false && duck != null)
                {
                    if (g._timer <= 0.1f)
                    {
                        tempX      = g.position.x;
                        tempY      = g.position.y - 10f;
                        teleported = true;
                    }
                }

                if (g != null && tempX != 0f && tempY != 0f && teleported == true)
                {
                    if (g._destroyed == true)
                    {
                        teleTimer = teleTimer - 0.01f;
                        if (teleTimer <= 0.03f)
                        {
                            Level.Add(SmallSmoke.New(duck.position.x, duck.position.y));
                            if (duck.ragdoll != null)
                            {
                                duck.ragdoll.position.x = tempX;
                                duck.ragdoll.position.y = tempY;
                            }
                            else
                            {
                                duck.position.x = tempX;
                                duck.position.y = tempY;
                            }
                            Level.Add(SmallSmoke.New(duck.position.x, duck.position.y));
                            duck.vSpeed = -0.5f;

                            g          = null;
                            teleported = false;
                            tempX      = 0f;
                            tempY      = 0f;
                            teleTimer  = 0.06f;
                            SFX.Play(GetPath("/sfx/teleport"), 1f, 0f, 0f, false);
                            Level.Remove(d);
                            level.RemoveThing(d);
                            d = null;
                        }
                    }
                }
            }



            if (_aiming && _aimWait <= 0f && _fireAngle < 80f)
            {
                _ammoType.bulletSpeed += 0.3f;
                _fireAngle            += 7f;
            }
            if (_aimWait > 0.0)
            {
                _aimWait -= 0.9f;
            }
            if (_cooldown > 0.0)
            {
                _cooldown -= 0.1f;
            }
            else
            {
                _cooldown = 0f;
            }
            if (owner != null)
            {
                _aimAngle = -Maths.DegToRad(_fireAngle);
                if (offDir < 0)
                {
                    _aimAngle = -_aimAngle;
                }
            }
            else
            {
                _aimWait   = 0f;
                _aiming    = false;
                _aimAngle  = 0f;
                _fireAngle = 0f;
            }
            if (!_raised)
            {
                return;
            }
            _aimAngle = 0.0f;
        }
Exemplo n.º 10
0
 private void Reset()
 {
     SFX.PlaySound(SFX.losePowerUpAlt);
     level.player.canPoop = true;
 }
Exemplo n.º 11
0
 private void Reset()
 {
     SFX.PlaySound(SFX.losePowerUp);
     Difficulty.SetScoreModifier(Difficulty.GetScoreModifier() / 2);
 }
Exemplo n.º 12
0
 public static void Play(SFX sfx)
 {
     try
       {
     SFXInstances[sfx].Play();
       }
       catch
       {
       }
 }
 public void PlaySFX(AudioClip SFXClip)
 {
     SFX.PlayOneShot(SFXClip);
 }
Exemplo n.º 14
0
 public static void Play(SFX sfx, float volumeLevel)
 {
     volumeLevel = Mathf.Clamp(volumeLevel, 0.0f, 1.0f);
     sources[(int)sfx].volume = volumeLevel * Mathf.Min(sfxVolume, masterVolume);
     sources[(int)sfx].Play();
 }
Exemplo n.º 15
0
    public void Alteration(Vector3 position, Vector3 scale, OBJ obj, SFX sfx, Color color)
    {
        // Get point in terrain location
        Matrix4x4 matrix = transform.worldToLocalMatrix;
        position = matrix.MultiplyPoint(position);
        scale = matrix.MultiplyVector(scale);
        Bounds bounds = new Bounds(position, scale);

        int sX = (int)scale.x/2+1,
            sY = (int)scale.y/2+1,
            sZ = (int)scale.z/2+1,
            bX = Mathf.Max((int)position.x-sX, 1),
            bY = Mathf.Max((int)position.y-sY, 1),
            bZ = Mathf.Max((int)position.z-sZ, 1),
            eX = Mathf.Min((int)position.x+sX+2, width-2),
            eY = Mathf.Min((int)position.y+sY+2, height-2),
            eZ = Mathf.Min((int)position.z+sZ+2, depth-2);

        // inverse effect for subtraction or erosion
        if(sfx==SFX.SUB || sfx==SFX.EROSION)
            for(int x=bX; x<eX; x++)
            for(int y=bY; y<eY; y++)
            for(int z=bZ; z<eZ; z++)
                _map[x,y,z] = (byte)(255-_map[x,y,z]);

        // Begin of effect

        switch(sfx)
        {
        case SFX.ADD :
        case SFX.SUB :
            switch(obj)
            {
            case OBJ.CUBE   : AddCube  (bounds, bX, bY, bZ, eX, eY, eZ, color);	break;
            case OBJ.SPHERE : AddSphere(bounds, bX, bY, bZ, eX, eY, eZ, color);	break;
            case OBJ.RANDOM : AddRandom(bounds, bX, bY, bZ, eX, eY, eZ, color);	break;
            }
            break;
        case SFX.DILATION :
        case SFX.EROSION :
            switch(obj)
            {
            case OBJ.CUBE   : DilationCube  (bounds, bX, bY, bZ, eX, eY, eZ, color);	break;
            case OBJ.SPHERE : DilationSphere(bounds, bX, bY, bZ, eX, eY, eZ, color);	break;
            case OBJ.RANDOM : DilationRandom(bounds, bX, bY, bZ, eX, eY, eZ, color);	break;
            }
            break;
        case SFX.PAINT :
            switch(obj)
            {
            case OBJ.CUBE   : PaintCube  (bounds, bX, bY, bZ, eX, eY, eZ, color);	break;
            case OBJ.SPHERE : PaintSphere(bounds, bX, bY, bZ, eX, eY, eZ, color);	break;
            case OBJ.RANDOM : PaintRandom(bounds, bX, bY, bZ, eX, eY, eZ, color);	break;
            }
            break;
        }

        // End effect

        // inverse effect for subtraction or erosion
        if(sfx==SFX.SUB || sfx==SFX.EROSION)
            for(int x=bX; x<eX; x++)
            for(int y=bY; y<eY; y++)
            for(int z=bZ; z<eZ; z++)
                _map[x,y,z] = (byte)(255-_map[x,y,z]);

        // rebuild map in this bounds
        bounds.SetMinMax(new Vector3(bX, bY, bZ), new Vector3(eX, eY, eZ));
        ReBuild(bounds);
    }
Exemplo n.º 16
0
        public void playSound(SFX inSFX, float inPan)
        {
            switch (inSFX)
            {
                case SFX.menuMove:
                    soundEffectVolume[(int)inSFX] = 1f;
                    break;
                case SFX.menuSelect:
                    soundEffectVolume[(int)inSFX] = 1f;
                    break;
                case SFX.playerShot:
                    soundEffectVolume[(int)inSFX] = 0.25f;
                    break;
                case SFX.enemyIsHit:
                    if (soundEffectVolume[(int)inSFX] == 0)
                        soundEffectVolume[(int)inSFX] = 0.4f;
                    else
                        soundEffectVolume[(int)inSFX] += 0.1f;
                    break;
                case SFX.enemyDead:
                    soundEffectVolume[(int)inSFX] = 0.4f;
                    break;
                case SFX.rocket:
                    soundEffectVolume[(int)inSFX] = 0.15f;
                    break;
                case SFX.playerHit:
                    soundEffectVolume[(int)inSFX] = 0.25f;
                    break;
                case SFX.MissileHit:
                    soundEffectVolume[(int)inSFX] = 0.4f;
                    break;
                case SFX.SlowMoEnd:
                    soundEffectVolume[(int)inSFX] = 0.4f;
                    break;
                case SFX.SlowMoStart:
                    soundEffectVolume[(int)inSFX] = 0.4f;
                    break;
            }

            soundEffectPan[(int)inSFX] = inPan;
        }
Exemplo n.º 17
0
 public static void PlaySfx(SFX effect, bool loop)
 {
     if (instance) instance.playSfx(effect, loop);
     else Debug.LogError("No instance of SoundManager was found.");
 }
Exemplo n.º 18
0
 public void playSfx(SFX effect)
 {
     playSfx(effect, false);
 }
Exemplo n.º 19
0
    //Instance functions

    public void playSfx(SFX effect, bool loop)
    {
        Debug.Log("Playing sfx: " + effect.ToString());
        AudioClip clip = null;

        switch (effect)
        {
            //Player
            case SFX.Jump:
                clip = jumpSFX;
                break;
            case SFX.GroundHit:
                clip = groundHitSFX;
                break;
            case SFX.Crouch:
                clip = crouchSFX;
                break;
            case SFX.Hit:
                clip = hitSFX;
                break;
            case SFX.Death:
                clip = deathSFX;
                break;
            //Runner
            case SFX.ScorePickup:
                clip = scorePickupSFX;
                break;
            case SFX.HealthPickup:
                clip = healthPickupSFX;
                break;
            case SFX.DeliverPickups:
                clip = deliverPickupsSFX;
                break;
            //UI
            case SFX.ButtonClick:
                clip = buttonClickSFX;
                break;
            case SFX.ButtonHover:
                clip = buttonHoverSFX;
                break;
            default:
                clip = null;
                break;
        }

        if (sfxSource && clip)
        {
            if (loop)
            {
                sfxSource.loop = true;
                sfxSource.Stop();
                sfxSource.clip = clip;
                sfxSource.Play();
            }
            else
            {
                sfxSource.clip = null;
                sfxSource.PlayOneShot(clip);
            }
        }
    }
Exemplo n.º 20
0
 void Start()
 {
     sfx         = this;
     audioSource = GetComponent <AudioSource>();
 }
Exemplo n.º 21
0
        /// <summary>
        /// The code to show the at the given coordiantes.
        /// The colour of the circle is different based on the type we are working with
        /// </summary>
        /// <param name="coor">The coordinates the circle is to be shown at</param>
        private void showBrush(SFX.YATT.Tools.Vector<float> coor)
        {
            Color col;

            if (data.mode == paintmode.paint) {
                col = Color.Black;
            } else if (data.mode == paintmode.eyedrop) {
                col = Color.Blue;
            } else {
                col = Color.Red;
            }

            Vector3 vec = new Vector3(coor[0], coor[1], coor[2]);

            NWN2NetDisplayManager.Instance.TerrainBrush(this.electronPanel.NDWindow.Scene,
                                                        1,
                                                        1,
                                                        vec,
                                                        (float)newInner,
                                                        (float)newOuter,
                                                        NWN2ToolsetMainForm.App.TerrainEditor.TerrainValue,
                                                        NWN2ToolsetMainForm.App.TerrainEditor.TerrainValue2,
                                                        NWN2ToolsetMainForm.App.TerrainEditor.TerrainBrushColor,
                                                        col.ToArgb(),
                                                        NWN2ToolsetMainForm.App.TerrainEditor.TerrainBrushTexture,
                                                        NWN2ToolsetMainForm.App.TerrainEditor.TerrainMode);
            byte[] buffer2 = null;
            bool bCancel = false;
            if ((NWN2ToolsetMainForm.App.TerrainEditor.TerrainMode != TerrainModificationType.Water) && (NWN2ToolsetMainForm.App.TerrainEditor.TerrainMode != TerrainModificationType.NoWater))
            {
                NWN2NetDisplayManager.Instance.BeginSynchronizedOperation();
                int num6 = NWN2NetDisplayManager.Instance.TerrainSelection(this.electronPanel.NDWindow.Scene, vec);
                NWN2NetDisplayManager.Instance.WaitForMessageSynchronous(NetDisplayMessageType.TerrainSelectResults, out buffer2, num6);
                NWN2NetDisplayManager.Instance.EndSynchronizedOperation();
                if (buffer2 != null)
                {
                    NWN2ToolsetMainForm.App.TerrainEditor.HandleSelectTerrain(buffer2, ref bCancel);
                }
            }
        }
Exemplo n.º 22
0
        public override void Update()
        {
            _timer = 99f;
            base.Update();

            PinUpdate();

            if (_realTimer <= 0f && _detonationTrigger == 0)
            {
                //Shockwave();

                Explosion();
                _detonationTrigger++;
                _destroyed = true;

                //_detonationTrigger = -1;
            }
            else if (_detonationTrigger > 0)
            {
                _detonationTrigger++;
                if (_detonationTrigger == 9)
                {
                    Layer.Game.colorMul                              =
                        Layer.Glow.colorMul                          =
                            Layer.Parallax.colorMul                  =
                                Layer.Background.colorMul            =
                                    Layer.Blocks.colorMul            =
                                        Layer.Lighting.colorMul      =
                                            Layer.Lighting2.colorMul = new Vec3(255f, 249f, 201f) / 255f;

                    /*Layer.Game.darken =
                     * Layer.Glow.darken =
                     * Layer.Parallax.darken =
                     * Layer.Background.darken =
                     * Layer.Blocks.darken =
                     * Layer.Lighting.darken =
                     * Layer.Lighting2.darken = 1f / 8f;*/
                }
                if (_detonationTrigger == 10)
                {
                    SFX.KillAllSounds();
                    Thread.Sleep(4000);
                    Layer.Game.colorMul                              =
                        Layer.Glow.colorMul                          =
                            Layer.Parallax.colorMul                  =
                                Layer.Background.colorMul            =
                                    Layer.Blocks.colorMul            =
                                        Layer.Lighting.colorMul      =
                                            Layer.Lighting2.colorMul = new Vec3(0f);;
                    if (Level.current is GameLevel)
                    {
                        (Level.current as GameLevel).SkipMatch();
                    }
                    Music.Resume();
                    //DelayCallback();
                    Level.Remove(this);
                }
            }

            sprite.frame = _pin ? 0 : 1;

            if (_triggered)
            {
                Graphics.Draw(_snap, 0, 0);
            }
        }
Exemplo n.º 23
0
        public override void LoadContent()
        {
            base.LoadContent();
            MediaPlayer.Stop();

            camera      = new Camera2D(Vector2.Zero);
            camera.Zoom = (float)Graphics.PreferredBackBufferHeight * 2.45f / 600f;   // the ideal zoom is 2.45 at 600px of screen height

            font           = content.Load <SpriteFont>("Font");
            tilemapTexture = this.content.Load <Texture2D>("spritesheet-jn");

            /*
             * Player Health & Energy
             */
            texturePlayerHealth = this.content.Load <Texture2D>("HeartDraft");
            texturePlayerEnergy = this.content.Load <Texture2D>("EnergyBar");

            /*
             * A single pixel to draw lines and stuff
             */
            pixel = new Texture2D(Graphics.GraphicsDevice, 1, 1);
            DrawMe.Fill(pixel, Color.White);

            /*
             * Load sfx
             */
            SFX.Add("bubble", content.Load <SoundEffect>("sfx_bubble"));
            SFX.Add("bubble_noise_single", content.Load <SoundEffect>("BubbleNoisesSingle"));
            SFX.Add("anchor", content.Load <SoundEffect>("Anchor3"));
            SFX.Add("fall", content.Load <SoundEffect>("Falling"));
            SFX.Add("enemyDeath", content.Load <SoundEffect>("EnemyDeath"));

            /*
             * Player init
             */
            player = new Player(this, tilemapTexture, Vector2.Zero, 32, 32, true);
            player.Animations.CurrentFrame = new Frame(96, 176, 16, 32); // woman
            player.Animations.CurrentFrame = new Frame(0, 144, 32, 32);  // actual player
            //player.Animations.Add("robot-idle", new int[] { 177, 178, 179, 180, 181, 182 }, 6, false, true);
            //player.Animations.Add("woman-run", new int[] { 183, 184, 185, 186, 187, 188 }, 12, true);
            player.Body.X = 16 * 7;
            player.Body.Y = 16 * 5;
            player.Body.SetSize(16, 32, 0, 0);  // woman
            player.Body.SetSize(10, 26, 11, 3); // actual player
            Karma.maxKarma          = 0;
            Karma.playerShotsFired  = 0;
            Karma.playerTotalDamage = 0f;
            Karma.playerCollect     = 0;

            //player.Animations.Play("woman-run");

            /*
             * Level init
             */
            XMLLevelLoader XMLloader = new XMLLevelLoader();

            level = XMLloader.LoadLevel(this, @"Content\featureTestMap.tmx", tilemapTexture);
            level.SetCollisionTiles(new int[] { 1, 2, 17, 18, 33, 34 });


            /*
             * parse objects
             */
            foreach (TiledObject obj in level.Objects)
            {
                Console.WriteLine("parsing " + obj.Name);

                if (obj.Name.ToLower() == "jellyfish")
                {
                    Vector2 center = new Vector2(obj.X + obj.Width / 2, obj.Y + obj.Height / 2);
                    Vector2 radius = new Vector2(obj.Width / 2, obj.Height / 2);

                    float speed = float.Parse(obj.GetProperty("speed"));

                    JellyFish j = new JellyFish(this, tilemapTexture, Vector2.Zero, 16, 32, center, radius, speed);
                    j.Animations.CurrentFrame = new Frame(48, 112, 16, 32);

                    enemies.Add(j);
                    Karma.maxKarma = Karma.DefineMaxKarma(Karma.maxKarma, j.Health);

                    Console.WriteLine("added jelly");
                }
                else if (obj.Name.ToLower() == "pufferfish")
                {
                    Vector2 position = new Vector2(obj.X, obj.Y);

                    float speed = float.Parse(obj.GetProperty("speed"));

                    PufferFish p = new PufferFish(this, tilemapTexture, position, 32, 32, obj.Width, speed);
                    p.Animations.CurrentFrame = new Frame(0, 112, 32, 32);

                    enemies.Add(p);
                    Karma.maxKarma = Karma.DefineMaxKarma(Karma.maxKarma, p.Health);

                    Console.WriteLine("added puffer");
                }
                else if (obj.Name.ToLower() == "turtlex")
                {
                    Vector2 position = new Vector2(obj.X, obj.Y);

                    float speed = float.Parse(obj.GetProperty("speed"));

                    TurtleX p = new TurtleX(this, tilemapTexture, position, 32, 32, 64, obj.Width, speed);
                    p.Animations.CurrentFrame = new Frame(96, 112, 32, 32);

                    enemies.Add(p);
                    Karma.maxKarma = Karma.DefineMaxKarma(Karma.maxKarma, p.Health);

                    Console.WriteLine("added turtlex");
                }
                else if (obj.Name.ToLower() == "goldfish")
                {
                    goldenFishs.Add(new GoldFish(this, tilemapTexture, new Vector2(obj.X, obj.Y), 16, 16));
                }
                else if (obj.Name.ToLower() == "particles")
                {
                    ParticleEmitter particleEmitter = new ParticleEmitter(this, obj.X, obj.Y, 256);
                    particleEmitter.EmitterBox.Resize(obj.Width, obj.Height);
                    particleEmitter.MakeParticles(tilemapTexture, 16, 16);
                    particleEmitter.ParticleVelocity = new Vector2(0, -0.01f);
                    particleEmitter.SetAcceleration(0, -0.005f);
                    particleEmitter.XVelocityVariationRange = new Vector2(-20f, 20f);
                    particleEmitter.YVelocityVariationRange = new Vector2(-20f, 0f);
                    particleEmitter.SetTextureCropRectangle(new Rectangle(3 * 16, 6 * 16, 16, 16));
                    particleEmitter.SpawnRate = 250f;
                    particleEmitter.ParticleLifespanMilliseconds          = 5000f;
                    particleEmitter.ParticleLifespanVariationMilliseconds = 1000f;
                    particleEmitter.InitialScale = 0.1f;
                    particleEmitter.FinalScale   = 1.5f;

                    particleEmitter.ForEachParticle(ChangeSpriteTintBlue);

                    backgroundParticles.Add(particleEmitter);



                    Console.WriteLine("added particles");
                }
                else if (obj.Name.ToLower() == "player_spawn")
                {
                    player.Body.X = obj.X;
                    player.Body.Y = obj.Y;
                }
                else if (obj.Name.ToLower() == "change_state_trigger")
                {
                    triggers.Add(new Trigger(obj.X, obj.Y, obj.Width, obj.Height, obj.GetProperty("value")));
                }
            }

            // build spikes tiles list
            spikesPointingDown = level.GetTilesListByID(new int[] { 97 });
            spikesPointingUp   = level.GetTilesListByID(new int[] { 98 });

            foreach (Tile spike in spikesPointingDown)
            {
                spike.Body.SetSize(12, 6, 2, 0);
            }
            foreach (Tile spike in spikesPointingUp)
            {
                spike.Body.SetSize(12, 6, 2, 10);
            }

            topWaterTiles = level.GetTilesListByID(new int[] { 49, 50, 51 });

            /*
             * UI Elements init
             */
            energyBar   = new EnergyBar(Graphics, new Vector2(16, 32 + 4), 64, 8, new Color(255, 0, 0));
            Karma.karma = Karma.maxKarma;

            /*
             * Build Background Gradient
             */
            backgroundWaterGradientStrip = new Texture2D(Graphics.GraphicsDevice, 1, level.Height * level.TileHeight);

            Color startColor  = new Color(57, 92, 181);
            Color finishColor = new Color(17, 43, 104);
            Color currentColor;

            for (int i = 0; i < backgroundWaterGradientStrip.Height; i++)
            {
                float ratio = Math2.Map(i, 0f, backgroundWaterGradientStrip.Height, 0f, 1.0f);

                currentColor = Color.Lerp(startColor, finishColor, ratio);
                DrawMe.Pixel(backgroundWaterGradientStrip, 0, i, currentColor);
            }

            /*
             * Build Background Gradient
             */
            backgroundSkyGradientStrip = new Texture2D(Graphics.GraphicsDevice, 1, Graphics.PreferredBackBufferHeight / 2);

            startColor  = new Color(61, 28, 111);
            finishColor = new Color(158, 98, 123);
            for (int i = 0; i < backgroundSkyGradientStrip.Height; i++)
            {
                float ratio = Math2.Map(i, 0f, backgroundSkyGradientStrip.Height, 0f, 1.0f);

                currentColor = Color.Lerp(startColor, finishColor, ratio);
                DrawMe.Pixel(backgroundSkyGradientStrip, 0, i, currentColor);
            }

            ContentLoaded = true;
        }
Exemplo n.º 24
0
 public override void Init()
 {
     SFX[] sounds = new SFX[] { SFX.Malaria1, SFX.PiranhaAttack1, SFX.RaiseDead1, SFX.FireBreath1 };
     playables = new IPlayable[sounds.Length];
     for (int i = 0; i < sounds.Length; i++)
         playables[i] = SoundManager.GetSFX(sounds[i]);
 }
Exemplo n.º 25
0
 private void Reset()
 {
     SFX.PlaySound(SFX.losePowerUp);
     level.player.poopCost = level.player.startingPoopCost;
 }
Exemplo n.º 26
0
    //balence state reappears here
    // Updates the character's animation while they're on the ground
    // 3D-Ready: NO
    void UpdateGroundAnim(float deltaTime)
    {
        bool ignoreFlipX = false;

        character.spriteAnimatorSpeed = 1;

        // Check if we are transitioning to a rolling air state. If so, set the speed of it
        if (character.InStateGroup("rolling") && character.InStateGroup("air"))
        {
            character.spriteAnimatorSpeed = 1 + (
                (
                    Mathf.Abs(character.groundSpeed) /
                    character.stats.Get("topSpeedNormal")
                ) * 2F
                );
        }
        else
        {
            // Turning
            // ======================
            if (character.pressingLeft && (character.groundSpeed < 0))
            {
                character.facingRight = false;
            }
            else if (character.pressingRight && (character.groundSpeed > 0))
            {
                character.facingRight = true;
            }

            // Skidding
            // ======================
            var skidding = (
                (character.pressingRight && character.groundSpeed < 0) ||
                (character.pressingLeft && character.groundSpeed > 0)
                );

            // You can only trigger a skid state if:
            // - Your angle (a) is <= 45d or >= 270d and your absolute speed is above the threshhold
            // - OR you're already skidding
            var canSkid = (
                (
                    (
                        (character.forwardAngle <= 45F) ||
                        (character.forwardAngle >= 270F)
                    ) && (
                        Mathf.Abs(character.groundSpeed) >= character.stats.Get("skidThreshold")
                        )
                ) || character.spriteAnimator.GetCurrentAnimatorStateInfo(0).IsName("Skid")
                );

            // Standing still, looking up/down, idle animation
            // ======================
            if (character.groundSpeed == 0)
            {
                if (character.input.GetAxisNegative("Vertical"))
                {
                    character.AnimatorPlay("Look Down");
                }
                else if (character.input.GetAxisPositive("Vertical"))
                {
                    character.AnimatorPlay("Look Up");
                }
                //seen specificly here (weirdly enough it looks somewhat like our own code just with less transations)
                else if (character.balanceState != Character.BalanceState.None)
                {
                    ignoreFlipX     = true;
                    character.flipX = character.balanceState == Character.BalanceState.Right;
                    character.AnimatorPlay("Balancing");
                }
                else
                {
                    if (
                        !character.spriteAnimator.GetCurrentAnimatorStateInfo(0).IsName("Tap") &&
                        !character.spriteAnimator.GetCurrentAnimatorStateInfo(0).IsName("Idle")
                        )
                    {
                        character.AnimatorPlay("Idle");
                    }
                }
                // Pushing anim
                // ======================
            }
            else if (pushing)
            {
                character.AnimatorPlay("Push");
                character.spriteAnimatorSpeed = 1 + (Mathf.Abs(character.groundSpeed) / character.stats.Get("topSpeedNormal"));
                // Skidding, again
                // ======================
            }
            else if (skidding && canSkid)
            {
                if (!character.spriteAnimator.GetCurrentAnimatorStateInfo(0).IsName("Skid"))
                {
                    SFX.Play(character.audioSource, "sfxSkid");
                }

                character.AnimatorPlay("Skid");
                // Walking
                // ======================
            }
            else if (Mathf.Abs(character.groundSpeed) < character.stats.Get("topSpeedNormal"))
            {
                character.AnimatorPlay("Walk");
                character.spriteAnimatorSpeed = 1 + (Mathf.Abs(character.groundSpeed) / character.stats.Get("topSpeedNormal"));
                // Running Fast
                // ======================
            }
            else if (
                (Mathf.Abs(character.groundSpeed) >= 10F * character.physicsScale) &&
                GlobalOptions.GetBool("peelOut")
                )
            {
                character.AnimatorPlay("Fast");
                character.spriteAnimatorSpeed = Mathf.Abs(character.groundSpeed) / character.stats.Get("topSpeedNormal");
            }
            else
            {
                // Running
                // ======================
                character.AnimatorPlay("Run");
                character.spriteAnimatorSpeed = Mathf.Abs(character.groundSpeed) / character.stats.Get("topSpeedNormal");
            }
        }

        // Final value application
        // ======================
        character.spriteContainer.transform.eulerAngles = character.GetSpriteRotation(deltaTime);
        if (!ignoreFlipX)
        {
            character.flipX = !character.facingRight;
        }

        pushing = false;
    }
Exemplo n.º 27
0
            public override void Init()
            {
                //SFX[] effects = new SFX[] { SFX.BulletHitFlesh1, SFX.BulletHitFlesh2, SFX.SwordHitFlesh1, SFX.SwordHitFlesh2 };
                SFX[] effects = new SFX[] { SFX.BulletHitFlesh1 };
                IEnumerable<IPlayable> playables = effects.Select<SFX, IPlayable>(SoundManager.GetSFX);
                var srg = SoundManager.GetSoundResourceGroup(playables.ToArray<IPlayable>());

                Vector3 pos = new Vector3(0, 0, 0);

                testUnit = InsertUnit2(pos, srg, true);
                testUnit.Play(true);

                testUnit.Channel.PlaybackStopped += (o, e) => { System.Windows.Forms.MessageBox.Show("asdf"); };
            }
Exemplo n.º 28
0
 public static void PlaySound(SFX which, bool unique)
 {
     if (Preferences.GetBoolean("Sound"))
         Instance.playSound(which, unique);
 }
 public IPlayable GetSFX(SFX sfx)
 {
     return soundEffects[sfx];
 }
Exemplo n.º 30
0
 public override void Removed()
 {
     SFX.PlaySynchronized("laserBlast", 1, 1);
     base.Removed();
 }
 public void LoadSound(SFX sfx, string filename, SoundResource soundResource)
 {
     soundResource.Name = "SFX/" + filename;
     LoadAnySound(soundResource);
     soundEffects[sfx] = soundResource;
 }
Exemplo n.º 32
0
 private void Reset()
 {
     SFX.PlaySound(SFX.losePowerUp);
     level.player.speed -= _speedUp;
 }
 public void SetSoundEffectBaseVolume(SFX sfx, float volume)
 {
     if (!oldVolumes.ContainsKey(sfx))
         oldVolumes[sfx] = soundEffects[sfx].Volume;
     soundEffects[sfx].Volume = volume;
 }
Exemplo n.º 34
0
 private void Reset()
 {
     SFX.PlaySound(SFX.losePowerUp);
     level.player.canKill = false;
 }
Exemplo n.º 35
0
 public IPlayable GetSFX(SFX sfx)
 {
     return new DummyPlayable();
 }
Exemplo n.º 36
0
 void Awake()
 {
     sfx = GameObject.FindGameObjectWithTag("SFX").GetComponent <SFX>();
 }
Exemplo n.º 37
0
 public override void Update()
 {
     if (this.finished)
     {
         return;
     }
     this.yOffset = Lerp.FloatSmooth(this.yOffset, this.down ? 150f : 0.0f, 0.3f, 1.1f);
     if (this.down)
     {
         this._downWait -= 0.06f;
         if ((double)this._downWait <= 0.0)
         {
             if (this._doneDown)
             {
                 this.finished = true;
                 this.Close();
                 return;
             }
             this._openWait = 1f;
             this._wrapped  = true;
             this._downWait = 1f;
             this.down      = false;
             SFX.Play("pause", 0.6f);
         }
     }
     else
     {
         this._openWait -= 0.06f;
         if ((double)this._openWait <= 0.0 && this._wrapped && !this._flash)
         {
             this._flash = true;
         }
         if (this._flash)
         {
             Graphics.flashAdd = Lerp.Float(Graphics.flashAdd, 1f, 0.2f);
             if ((double)Graphics.flashAdd > 0.990000009536743)
             {
                 this._wrapped = !this._wrapped;
                 if (!this._wrapped)
                 {
                     this._oldSong = Music.currentSong;
                     Profiles.experienceProfile.SetNumFurnitures((int)this._furni.index, Profiles.experienceProfile.GetNumFurnitures((int)this._furni.index) + 1);
                     SFX.Play("harp");
                     HUD.AddCornerControl(HUDCorner.BottomRight, "@SELECT@CONTINUE");
                 }
                 this._flash = false;
             }
         }
         else
         {
             Graphics.flashAdd = Lerp.Float(Graphics.flashAdd, 0.0f, 0.2f);
         }
         if (!this._wrapped && Input.Pressed("SELECT"))
         {
             HUD.CloseAllCorners();
             SFX.Play("resume", 0.6f);
             this.down      = true;
             this._doneDown = true;
         }
     }
     base.Update();
 }
Exemplo n.º 38
0
 public void Open(string text, string startingText = "")
 {
     this.opened = true;
     this._text  = text;
     SFX.Play("openClick", 0.4f);
 }
Exemplo n.º 39
0
        private SoundEffect getSound(SFX which)
        {
            SoundEffect s;
            if (!instance.sounds.TryGetValue(which, out s)) //haven't loaded the sounds yet
            {
                try
                {
                    string name = names[which];
                    s = instance.Content.Load<SoundEffect>(PREFIX + name);
                }
                catch (Exception  ex)
                {
                    trace("Couldn't load " + which.ToString() + ": " + ex);
                }

                sounds.Add(which, s);
            }

            return s;
        }
Exemplo n.º 40
0
 void playAudio(AudioSource AS, SFX[] sfxIdx, audioMode aM)
 {
     aMode = aM;
     int rng;
     qued = sfxIdx;
     switch (aMode)
     {
         case audioMode.Once:
             am.playAudio(AS, sfxIdx[0], audioMode.Once);
             currentAudio = 0;
             break;
         case audioMode.FirstLoop:
             am.playAudio(AS, sfxIdx[0], audioMode.Once);
             currentAudio = 0;
             break;
         case audioMode.FirstThenNextLoop:
             am.playAudio(AS, sfxIdx[0], audioMode.Once);
             currentAudio = 0;
             break;
         case audioMode.CycleThroughAll:
             am.playAudio(AS, sfxIdx[0], audioMode.Once);
             currentAudio = 0;
             break;
         case audioMode.FirstThenCycleThroughAllLoop:
             am.playAudio(AS, sfxIdx[0], audioMode.Once);
             currentAudio = 0;
             break;
         case audioMode.RandomAll:
             rng = Random.Range(0, sfxIdx.Length);
             am.playAudio(AS, sfxIdx[rng], audioMode.Once);
             currentAudio = rng;
             break;
         case audioMode.FirstThenRandom:
             rng = Random.Range(1, sfxIdx.Length);
             am.playAudio(AS, sfxIdx[0], audioMode.Once);
             currentAudio = 0;
             break;
     }
 }
Exemplo n.º 41
0
 public void PlayFaithfull(SFX sfx)
 {
     sourceFaithfull.PlayOneShot(clips[(int)sfx]);
 }
Exemplo n.º 42
0
    private AudioClip GetSFX(SFX sfx)
    {
        if (sfx == SFX.IntroTankFiring)
        {
            return(singletonInstance.introTankFiring);
        }
        else if (sfx == SFX.IntroTankRolling)
        {
            return(singletonInstance.introTankRolling);
        }
        else if (sfx == SFX.MouseOnOption)
        {
            return(singletonInstance.mouseOnOption);
        }
        else if (sfx == SFX.PlayerFire)
        {
            return(singletonInstance.playerFire);
        }
        else if (sfx == SFX.ProjectileHitsBrick)
        {
            return(singletonInstance.projectileHitsBrick);
        }
        else if (sfx == SFX.ProjectileHitsWall)
        {
            return(singletonInstance.projectileHitsWall);
        }
        else if (sfx == SFX.ExplosionEnemyRegular)
        {
            return(singletonInstance.explosionEnemyRegular);
        }
        else if (sfx == SFX.ExplosionEnemyArmored)
        {
            return(singletonInstance.explosionEnemyArmored);
        }
        else if (sfx == SFX.ExplosionPlayer)
        {
            return(singletonInstance.explosionPlayer);
        }
        else if (sfx == SFX.ExplosionEagle)
        {
            return(singletonInstance.explosionEagle);
        }
        else if (sfx == SFX.SpawnPowerUp)
        {
            return(singletonInstance.spawnPowerUp);
        }
        else if (sfx == SFX.SpawnEnemy)
        {
            return(singletonInstance.spawnEnemy);
        }
        else if (sfx == SFX.Target)
        {
            return(singletonInstance.target);
        }
        else if (sfx == SFX.InteractUI)
        {
            return(singletonInstance.interactUI);
        }
        else if (sfx == SFX.PickUpPowerUp)
        {
            return(singletonInstance.pickupPowerUp);
        }
        else if (sfx == SFX.DamageArmor)
        {
            return(singletonInstance.damageArmor);
        }
        else if (sfx == SFX.MoneyPickUp)
        {
            return(singletonInstance.moneyPickUp);
        }
        else if (sfx == SFX.NoAmmo)
        {
            return(singletonInstance.noAmmo);
        }
        else if (sfx == SFX.Victory)
        {
            return(singletonInstance.victory);
        }

        else
        {
            throw new Exception("SFX not found");
        }
    }
Exemplo n.º 43
0
 public void Play(SFX sfx)
 {
     Play(sfx, 1f);
 }
Exemplo n.º 44
0
 protected virtual void Shockwave()
 {
     //if (isServerForObject)
     //    Level.Add(new GlobalPulse(x, y));
     SFX.Play("explode");
 }
Exemplo n.º 45
0
            internal override Region ReadEntry(BinaryReaderEx br)
            {
                RegionType type = br.GetEnum32 <RegionType>(br.Position + 8);

                switch (type)
                {
                case RegionType.InvasionPoint:
                    return(InvasionPoints.EchoAdd(new Region.InvasionPoint(br)));

                case RegionType.EnvironmentMapPoint:
                    return(EnvironmentMapPoints.EchoAdd(new Region.EnvironmentMapPoint(br)));

                case RegionType.Sound:
                    return(Sounds.EchoAdd(new Region.Sound(br)));

                case RegionType.SFX:
                    return(SFX.EchoAdd(new Region.SFX(br)));

                case RegionType.WindSFX:
                    return(WindSFX.EchoAdd(new Region.WindSFX(br)));

                case RegionType.SpawnPoint:
                    return(SpawnPoints.EchoAdd(new Region.SpawnPoint(br)));

                case RegionType.Message:
                    return(Messages.EchoAdd(new Region.Message(br)));

                case RegionType.PatrolRoute:
                    return(PatrolRoutes.EchoAdd(new Region.PatrolRoute(br)));

                case RegionType.MovementPoint:
                    return(MovementPoints.EchoAdd(new Region.MovementPoint(br)));

                case RegionType.WarpPoint:
                    return(WarpPoints.EchoAdd(new Region.WarpPoint(br)));

                case RegionType.ActivationArea:
                    return(ActivationAreas.EchoAdd(new Region.ActivationArea(br)));

                case RegionType.Event:
                    return(Events.EchoAdd(new Region.Event(br)));

                case RegionType.Logic:
                    return(Logic.EchoAdd(new Region.Logic(br)));

                case RegionType.EnvironmentMapEffectBox:
                    return(EnvironmentMapEffectBoxes.EchoAdd(new Region.EnvironmentMapEffectBox(br)));

                case RegionType.WindArea:
                    return(WindAreas.EchoAdd(new Region.WindArea(br)));

                case RegionType.MufflingBox:
                    return(MufflingBoxes.EchoAdd(new Region.MufflingBox(br)));

                case RegionType.MufflingPortal:
                    return(MufflingPortals.EchoAdd(new Region.MufflingPortal(br)));

                case RegionType.Other:
                    return(Others.EchoAdd(new Region.Other(br)));

                default:
                    throw new NotImplementedException($"Unsupported region type: {type}");
                }
            }
Exemplo n.º 46
0
        public static bool onOSDraw(OS self, ref GameTime time)
        {
            var osStartDrawEvent = new Event.OSStartDrawEvent(self, time);

            Event.OSEndDrawEvent osEndDrawEvent = null;
            try
            {
                if (self.lastGameTime == null)
                {
                    self.lastGameTime = time;
                }
                switch (osStartDrawEvent.DrawType)
                {
                case Event.OSDrawEvent.Type.Standard:
                    PostProcessor.begin();
                    GuiData.startDraw();
                    osStartDrawEvent.CallEvent();
                    if (osStartDrawEvent.IsCancelled)
                    {
                        break;
                    }
                    try
                    {
                        if (!self.TraceDangerSequence.PreventOSRendering)
                        {
                            self.drawBackground();
                            if (self.terminalOnlyMode)
                            {
                                self.terminal.Draw((float)time.ElapsedGameTime.TotalSeconds);
                            }
                            else
                            {
                                self.drawModules(time);
                            }
                            SFX.Draw(GuiData.spriteBatch);
                        }
                        if (self.TraceDangerSequence.IsActive)
                        {
                            self.TraceDangerSequence.Draw();
                        }
                    }
                    catch (Exception ex)
                    {
                        self.drawErrorCount++;
                        if (self.drawErrorCount < 5)
                        {
                            Utils.AppendToErrorFile(Utils.GenerateReportFromException(ex) + "\r\n\r\n");
                        }
                    }
                    break;

                case Event.OSDrawEvent.Type.BootingSequence:
                    osStartDrawEvent.IgnoreScanlines = true;
                    goto case Event.OSDrawEvent.Type.EndingSequence;

                case Event.OSDrawEvent.Type.BootAssistance:
                case Event.OSDrawEvent.Type.EndingSequence:
                    PostProcessor.begin();
                    osStartDrawEvent.CallEvent();
                    if (osStartDrawEvent.IsCancelled)
                    {
                        break;
                    }
                    self.ScreenManager.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone);
                    switch (osStartDrawEvent.DrawType)
                    {
                    case Event.OSDrawEvent.Type.BootAssistance:
                        self.BootAssitanceModule.Draw((float)time.ElapsedGameTime.TotalSeconds);
                        break;

                    case Event.OSDrawEvent.Type.BootingSequence:
                        if (self.thisComputer.disabled)
                        {
                            self.RequestRemovalOfAllPopups();
                            if (self.TraceDangerSequence.IsActive)
                            {
                                self.TraceDangerSequence.CancelTraceDangerSequence();
                            }
                            self.crashModule.Draw((float)time.ElapsedGameTime.TotalSeconds);
                        }
                        else
                        {
                            self.introTextModule.Draw((float)time.ElapsedGameTime.TotalSeconds);
                        }
                        break;

                    case Event.OSDrawEvent.Type.EndingSequence:
                        self.endingSequence.Draw((float)time.ElapsedGameTime.TotalSeconds);
                        break;
                    }
                    if (!osStartDrawEvent.IgnoreScanlines)
                    {
                        self.drawScanlines();
                    }
                    break;

                case Event.OSDrawEvent.Type.Loading:
                    GuiData.startDraw();
                    osStartDrawEvent.CallEvent();
                    if (osStartDrawEvent.IsCancelled)
                    {
                        break;
                    }
                    TextItem.doSmallLabel(new Vector2(0f, 700f), LocaleTerms.Loc("Loading..."), null);
                    break;

                case Event.OSDrawEvent.Type.Custom:
                    osStartDrawEvent.CallEvent();
                    if (osStartDrawEvent.IsCancelled)
                    {
                        return(true);
                    }
                    break;
                }
                osEndDrawEvent = new Event.OSEndDrawEvent(self, time, osStartDrawEvent.DrawType);
                switch (osEndDrawEvent.DrawType)
                {
                case Event.OSDrawEvent.Type.Standard:
                    GuiData.endDraw();
                    PostProcessor.end();
                    if (!osStartDrawEvent.IgnorePostFXDraw)
                    {
                        GuiData.startDraw();
                        if (self.postFXDrawActions != null)
                        {
                            self.postFXDrawActions.Invoke();
                            self.postFXDrawActions = null;
                        }
                        if (!osStartDrawEvent.IgnoreScanlines)
                        {
                            self.drawScanlines();
                        }
                        GuiData.endDraw();
                    }
                    break;

                case Event.OSDrawEvent.Type.BootAssistance:
                case Event.OSDrawEvent.Type.BootingSequence:
                case Event.OSDrawEvent.Type.EndingSequence:
                    self.ScreenManager.SpriteBatch.End();
                    PostProcessor.end();
                    break;

                case Event.OSDrawEvent.Type.Loading:
                    GuiData.endDraw();
                    break;

                default:
                    osEndDrawEvent.CallEvent();
                    break;
                }
            }
            catch (Exception ex)
            {
                osEndDrawEvent = new Event.OSEndDrawEvent(self, time, Event.OSDrawEvent.Type.Error);
                osEndDrawEvent.CallEvent();
                if (osEndDrawEvent.IsCancelled)
                {
                    return(true);
                }
                self.drawErrorCount++;
                if (self.drawErrorCount >= 3)
                {
                    self.handleDrawError();
                }
                else
                {
                    Utils.AppendToErrorFile(Utils.GenerateReportFromException(ex));
                }
            }
            return(true);
        }
Exemplo n.º 47
0
 protected override IList <IEnumerator> GetHitSFX(Character caster, Character target)
 {
     return(new IEnumerator[] { SFX.PlaySound("healspell1") });
 }
Exemplo n.º 48
0
 public static void Play(SFX sfx, Transform transform, float volumeLevel)
 {
     volumeLevel = Mathf.Clamp(volumeLevel, 0.0f, 1.0f);
     sources[(int)sfx].volume = volumeLevel * Mathf.Min(sfxVolume, masterVolume);
     AudioSource.PlayClipAtPoint(sources[(int)sfx].clip, transform.position);
 }
Exemplo n.º 49
0
 public void Play(SFX soundIndex)
 {
     audioSource.PlayOneShot(clips[(int)soundIndex]);
 }
Exemplo n.º 50
0
 public void Start()
 {
     sfx = (SFX)GameObject.FindGameObjectWithTag("Sound").GetComponent("SFX");
     rigidbody2D.angularVelocity = maxIniRotation;        // Random.Range(-maxIniRotation, maxIniRotation);
 }
Exemplo n.º 51
0
    public override void UpdateGameMode()
    {
        switch (state)
        {
        case DokaponGameState.focus:
            if (currentPoring == null)
            {
                return;
            }
            float distance = Vector3.Distance(currentPoring.transform.position, currentCamera.transform.position);            //print(distance);
            if (distance < 11.2f)
            {
                state         = DokaponGameState.roll;
                m_timeForRoll = TimeForRoll;

                // panelRoll.SetRoll(6);
            }
            break;

        case DokaponGameState.roll:
            m_timeForRoll -= Time.deltaTime;

            if (m_timeForRoll < 0)
            {
                Roll();
            }
            break;

        case DokaponGameState.plan:
            if (Input.GetMouseButtonDown(0))
            {
                RaycastHit hit;
                Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray, out hit, 100.0f))
                {
                    Node node = hit.transform.parent.GetComponent <Node>();
                    if (node)
                    {
                        Debug.Log("You selected the " + node.nid);
                        SFX.PlayClip(resource.sound[0]).GetComponent <AudioSource>().time = 0.3f;
                        node.PointRenderer.SetPropertyBlock(MaterialPreset.GetMaterialPreset(EMaterialPreset.selected));

                        if (node.steps.Count > 0)
                        {
                            MagicCursor.Instance.MoveTo(node);
                            Route.Clear();
                            // PathToNode(node);
                            // foreach (Node n in PathToNode(node)) {
                            //  s += n.nid + ", ";
                            // }
                            RouteToNode(node);
                            // foreach (List)
                            //print(GetNodeString(PathToNode(node)));
                            // print(s);
                            foreach (List <Node> r in Route)
                            {
                                print(GetNodeString(r));
                            }
                        }
                    }
                }
            }
            break;
        }
    }
 public void PlaySFX(AudioClip SFXClip, float targetVol)
 {
     SFX.PlayOneShot(SFXClip, targetVol);
 }
Exemplo n.º 53
0
 void Start()
 {
     sfx = this;
     audioSource = GetComponent<AudioSource>();
 }
    private void GolemGrab()
    {
        //Debug.Log("Casting Ray");
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        Debug.DrawLine(ray.origin, ray.direction, Color.green);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, 40))
        {
            //If a golem
            if (hit.transform.gameObject.CompareTag("Golem") && pickedupGolem == null)
            {
                //If not holding a pouch
                if (!hit.transform.gameObject.GetComponent <ShonkyWander>().IsHoldingPouch())
                {
                    GameManager.pickedUpGolem = true;
                    pickedupGolem             = hit.transform.gameObject;
                    HoldGolem(hit);
                }
                else
                {
                    //If room in the inventory, add the pouch
                    int pouchSlot = Inventory.Instance.InsertItem(pouch);
                    pickedupGolem = hit.transform.gameObject;
                    int golemIndex = GetGolemSlot();
                    if (pouchSlot > -1)
                    {
                        //Reset golem and set pouch to inventory
                        SFX.Play("Golem Exclaim Voices", 1f, 1f, 0f, false, 0f);
                        hit.transform.gameObject.GetComponent <ShonkyWander>().RemovePouch();
                        Slot insertedSlot;
                        if (!GameManager.Instance.InTutorial)
                        {
                            insertedSlot = inv.GetSlotAtIndex(pouchSlot);
                        }
                        else
                        {
                            insertedSlot = tutInv.GetSlotAtIndex(pouchSlot);
                        }

                        insertedSlot.SetItem(pouch);

                        //Get gemtype from golem and apply to pouch
                        ItemInstance instance;
                        if (ShonkyInventory.Instance.GetItem(golemIndex, out instance))
                        {
                            Item.GemType bagType = instance.pouchType;
                            ItemInstance inst;
                            if (Inventory.Instance.GetItem(pouchSlot, out inst))
                            {
                                inst.pouchType = bagType;
                            }
                        }

                        //Change pouch colour according to Gem
                        GameObject obj;
                        if (insertedSlot.GetPrefabInstance(out obj))
                        {
                            obj.GetComponent <SackHueChange>().UpdateCurrentColor(instance.pouchType);
                        }

                        if (GameManager.Instance.InTutorial && !GameManager.Instance.MineGoleminteractGolem)
                        {
                            if (GameManager.Instance.ReturnPouch)
                            {
                                tutManager.NextInstruction();
                                tutShonkyInv.RemoveSpecificRune(pickedupGolem);
                                GameManager.Instance.ReturnPouch            = false;
                                GameManager.Instance.MineGoleminteractGolem = true;
                                RemovePortalRune();
                                Camera.main.GetComponent <CameraTap>().HighlightButton();
                            }
                        }

                        //Move pouch to slot from golem position
                        GameObject newPouch = insertedSlot.prefabInstance;
                        newPouch.transform.position = pickedupGolem.transform.position;

                        Vector3 midwayPos = (Camera.main.transform.position + newPouch.transform.position) / 2;
                        newPouch.transform.DOMove(midwayPos, 1f, false).SetEase(Ease.OutBack).OnComplete(() =>
                                                                                                         newPouch.transform.DOMove(insertedSlot.transform.position, 2f, false)
                                                                                                         .SetEase(Ease.OutBack));
                        pickedupGolem = null;
                    }
                    else
                    {
                        HoldGolem(hit);
                    }
                }
            }
            else if (pickedupGolem != null)
            {
                //Debug.Log("Calling hold golem");
                HoldGolem();
            }
            else if (Mine.Instance.ReadyToCollect() && hit.transform.gameObject.CompareTag("PortalEntry") &&
                     pickedupGolem == null)
            {
                //Stop Sound
                SFX.StopSpecific("Mine_portal_fini");

                golems = null;
                golems = Mine.Instance.ReturnReadyGolems();
                foreach (int golem in golems)
                {
                    ReturnGolem(golem);
                }
            }
        }
        else if (pickedupGolem != null)
        {
            HoldGolem();
        }
    }
    // Update is called once per frame
    void Update()
    {
        //Debug.Log(overPortal + " is over portal");
        if (Input.GetMouseButton(0) && GameManager.Instance.canUseTools)
        {
            GolemGrab();
        }
        else if (overPortal)
        {
            Debug.Log("Sending to Mine");
            if (GameManager.Instance.BarterTutorial)
            {
                ResetGolem();
                return;
            }
            if (GameManager.Instance.InTutorial)
            {
                GameManager.Instance.WaitingForTimer = true;
                if (!GameManager.Instance.SendToMine)
                {
                    tutManager.NextInstruction();
                }

                RemovePortalRune();
            }
            SFX.StopSpecific("Golem Struggle Voices");
            SFX.Play("Portal_Suck", 1f, 1f, 0f, false, 0f);
            int index = GetGolemSlot();
            Mine.Instance.AddGolemAndTime(System.DateTime.Now, index);
            SetGolemInMine(index, true);
            SaveManager.SaveShonkyInventory();
            pickedupGolem.SetActive(false);
            pickedupGolem = null;
            overPortal    = false;
        }
        else if (overNPC)
        {
            Debug.Log("Sending to Barter");

            if (GameManager.Instance.BarterTutorial)
            {
                GameManager.Instance.BarterTutorial = false;
                GameManager.Instance.BarterNPC      = false;
                GameManager.Instance.introducedNPC  = false;
                PlayerPrefs.SetInt("TutorialDone", 1);
            }

            //SFX.Play("sound");
            int index = GetGolemSlot();
            Debug.Log(index + " is the index");
            if (index != -1)
            {
                GameManager.Instance.ShonkyIndexTransfer = index;
                pickedupGolem         = null;
                overNPC               = false;
                spawner.isInteracting = false;
                SaveManager.SaveShonkyInventory();
                ResetGolem();
                SceneManager.LoadScene("Barter");
            }
            else
            {
                ResetGolem();
            }
        }

        if (Input.GetMouseButtonUp(0) && pickedupGolem != null)
        {
            ResetGolem();
        }

        UpdateUITimer();
    }
Exemplo n.º 56
0
        /// <summary>
        /// The method that prepares to call the Method that does the actual paiting
        /// This include finding the coordinates that are to be painted, in what order, and the size of the outer and inner brush
        /// </summary>
        /// <param name="coor">The coordiantes we are going to start from</param>
        /// <param name="modType">The type of painting we are to do</param>
        /// <param name="localTexture">The texture we are going to paint</param>
        private void texturePreperation(SFX.YATT.Tools.Vector<float> coor, TerrainModificationType modType, textureData localTexture)
        {
            float valueX = coor[0];
            float valueY = coor[1];
            float valueZ = coor[2];

            int radius = (data.outerCircle + data.innerCircle) / 2;

            double roundModifier = 2 - (rounds / 11);

            float localOuter = (float)((newOuter / rounds) * roundModifier);
            float localInner = (float)((newInner / rounds) * roundModifier);

            opTexture.Checked = true;
            outerRadius.Value = Math.Min((int)localOuter, outerRadius.Maximum);
            innerRadius.Value = Math.Min((int)localInner, innerRadius.Maximum);

            float baseCoordinatesX = Math.Max(0, valueX - (radius / 2));
            float baseCoordinatesY = Math.Max(0, valueY - (radius / 2));

            float step = (radius / rounds);

            float coorX;
            float coorY;

            int ran = 0;

            // Make sure we have a new random number
            random = new Random(System.DateTime.Now.Millisecond);
            System.Collections.Generic.List<Pair<float, float>> coordinates = new System.Collections.Generic.List<Pair<float, float>>();

            for(int index1 = 1; index1 <= rounds; index1++ ) {
                coorX = baseCoordinatesX + (step * index1);

                for (int index2 = 1; index2 <= rounds; index2++) {
                    coorY = baseCoordinatesY + (step * index2);

                    coordinates.Add(new Pair<float, float>(coorX, coorY));
                }
            }

            int coverage = 0;
            string textureStr = localTexture.texture;
            int col = Color.White.ToArgb();

            if (modType == TerrainModificationType.Texture) {
                // CoverageChange must be bigger than 0 and less than 100
                coverage = localTexture.Coverage;

                // Set the presure of the current texture
                barPressure.Value = localTexture.Presure * 100;

            } else if (modType == TerrainModificationType.Grass) {
                coverage = data.grassCoverage;

            } else if (modType == TerrainModificationType.Color) {
                coverage = data.colourCoverage;
                col = data.col.ToArgb();

            } else {
                throw new Exception("Wrong Terrain Modification Type");
            }

            foreach (Pair<float, float> point in coordinates) {

                coorX = point.X;
                coorY = point.Y;

                ran = random.Next(1, 100);

                NWN2NetDisplayManager.Instance.BeginSynchronizedOperation();
                if (ran <= coverage) {
                    paintTexture(textureStr, modType, col, localInner, localOuter, coorX, coorY, valueZ);
                }
                NWN2NetDisplayManager.Instance.EndSynchronizedOperation();
            }
        }
Exemplo n.º 57
0
 public static SoundEffect GetSound(SFX which)
 {
     return Instance.getSound(which);
 }