示例#1
0
    static public List <Card> RunFinalEffects(List <Card> BeforeList, List <Card> AfterList, Action <List <Card> > CardEffect)
    {
        EffectEventArgs beforeAfter = new EffectEventArgs(BeforeList, AfterList, CardEffect);

        runFinalEffects(1, beforeAfter);
        return(AfterList);
    }
示例#2
0
    static public List <Card> RunWheneverEffects(List <Card> AffectedList, Action <List <Card> > CardEffect)
    {
        // Makes copies of AffectedList to signal what is going to happen.
        List <Card> Becoming = SetBefore(AffectedList);

        // Apply the effect.
        CardEffect(Becoming);

        EffectEventArgs BeforeAfter = new EffectEventArgs(AffectedList, Becoming, CardEffect);

        runWheneverEffects(1, BeforeAfter);


        foreach (Card card in Becoming)
        {
            Destroy(card.gameObject);
        }
        // Returns the modified list if it exists.
        if (ChangedAffectedList != null)
        {
            return(ChangedAffectedList);
        }
        else
        {
            return(AffectedList);
        }
    }
示例#3
0
        /// <summary>
        /// Invokes the EffectAdded event
        /// </summary>
        /// <param name="args">The event args</param>
        protected virtual void OnEffectAdded(EffectEventArgs args)
        {
            var handler = EffectAdded;

            if (handler != null)
            {
                handler.Invoke(this, args);
            }
        }
 private static void Communication_StaticOnEffectEvent(object sender, EffectEventArgs e)
 {
     Console.WriteLine();
     Console.WriteLine();
     Console.WriteLine($"{e.IP}: EffectEvent: EventsCount:{e.EffectEvents.Events.Count()}");
     foreach (var _event in e.EffectEvents.Events)
     {
         Console.WriteLine(_event.ToString());
     }
 }
示例#5
0
 public override void AfterCardEffect(object sender, EffectEventArgs e)
 {
     for (int i = 0; i < e.AfterList.Count; i++)
     {
         if (e.BeforeList[i].status != Status.BeingPlayed && e.AfterList[i].status == Status.BeingPlayed && e.AfterList[i] == this)
         {
             Debug.Log(name + " was played!");
         }
     }
 }
 public override void AfterCardEffect(object sender, EffectEventArgs e)
 {
     // When a card is played.
     for (int i = 0; i < e.AfterList.Count; i++)
     {
         if (e.BeforeList[i].status != Status.BeingPlayed && e.AfterList[i].status == Status.BeingPlayed &&
             e.AfterList[i] == this)
         {
             Debug.Log("BattleCry triggered");
             EffectTargeting.SetInfo(this, DamageTarget);
         }
     }
 }
 public void FinalEffect(object sender, EffectEventArgs e)
 {
     for (int i = 0; i < e.AfterList.Count; i++)
     {
         if (
             e.BeforeList[i].stats != null && e.AfterList[i].stats != null &&
             e.BeforeList[i].stats.currentHealth > 0 && e.AfterList[i].stats.currentHealth <= 0)
         {
             RunEffects(new List <Card> {
                 e.AfterList[i]
             }, Die);
         }
     }
 }
示例#8
0
 private void AnimatorFinishedHandler(object source, EventArgs e)
 {
     if (--_animatorsRunning <= 0)
     {
         // All animators have finished
         if (Finished != null)
         {
             // Signal to listeners (if any).
             EffectEventArgs eventArgs = new EffectEventArgs();
             eventArgs.name = _name;
             eventArgs.tag  = _tag;
             Finished.Invoke(this, eventArgs);
         }
     }
 }
示例#9
0
    static public List <Card> RunAfterEffects(List <Card> BeforeList, List <Card> AfterList, Action <List <Card> > CardEffect)
    {
        /*
         * for (int i = 0; i < AfterList.Count; i++)
         * {
         *  Debug.Log($"BeforeList[{i}]: {BeforeList[i]}");
         *  Debug.Log($"AfterList[{i}]: {AfterList[i]}");
         *
         * }
         */
        EffectEventArgs beforeAfter = new EffectEventArgs(BeforeList, AfterList, CardEffect);

        runAfterEffects(1, beforeAfter);
        return(AfterList);
    }
示例#10
0
 public override void AfterCardEffect(object sender, EffectEventArgs e)
 {
     // When this card is played.
     for (int i = 0; i < e.AfterList.Count; i++)
     {
         if (e.BeforeList[i].status != Status.BeingPlayed && e.AfterList[i].status == Status.BeingPlayed &&
             e.AfterList[i] == this &&
             target != null)
         {
             RunEffects(new List <Card> {
                 target
             }, BattleCry);
         }
     }
 }
        private void ExternalControlEndpoint_StaticOnEffectEvent(object sender, EffectEventArgs e)
        {
            if (!NanoleafPlugin.getClient(this.SerialNumber).IP.Equals(e.IP))
            {
                return;
            }

            EffectEvents events = e.EffectEvents;

            if (events == null)
            {
                return;
            }

            this.CurrentValue = events.Events.First().Value;
        }
 public override void OnEffectPostProcess(EffectEventArgs e)
 {
     if (this.damageInfo != null)
     {
         foreach (WuxiaUnit unit in this.summonUnits)
         {
             e.Target = new List <GameObject>();
             if (this.damageInfo.FloorEffect != null)
             {
                 e.Target.Add(unit.gameObject);
             }
             if (e.IsShowSumon)
             {
                 unit.gameObject.SetActive(true);
                 unit.Actor.PlayAnimation("be0101_stand00_await02", null, WrapMode.Once);
             }
         }
     }
 }
    public override void WheneverCardEffect(object sender, EffectEventArgs e)
    {
        // When a card is played.
        for (int i = 0; i < e.AfterList.Count; i++)
        {
            if (e.BeforeList[i].status != Status.BeingPlayed && e.AfterList[i].status == Status.BeingPlayed)
            {
                Debug.Log("Whenever effect: " + e.AfterList[i].name + " played.");

                Transform newMinion = Instantiate(Collections.Minions["Minion"].transform);
                newMinion.name = "I'm new!";

                List <Card> AffectedList = RunEffects(new List <Card> {
                    newMinion.GetComponent <Card>()
                }, Summon);


                //   RunEffects(new List<Card> { })
            }
        }
    }
    public override void WheneverCardEffect(object sender, EffectEventArgs e)
    {
        // When a card is played.
        for (int i = 0; i < e.AfterList.Count; i++)
        {
            if (e.BeforeList[i].target == null && e.AfterList[i].target != null)
            {
                Card Target = e.BeforeList[i].target;
                ChangedAffectedList = e.BeforeList;

                ChangedAffectedList[ChangedAffectedList.Count - 1] = Target.transform.parent.GetChild(Target.transform.GetSiblingIndex() + 1).GetComponent <Card>();



                List <Card> AffectedList = RunEffects(e.BeforeList, ChangeTarget);


                //   RunEffects(new List<Card> { })
            }
        }
    }
        void contactListener_SmallPoof(object sender, EffectEventArgs e)
        {
            int smokeID = 15;
            Vector2 originOffset = new Vector2(30,30);
            float alpha = 0.33f;

            Sprite smoke = new Sprite(smokeID, 0, e.location - originOffset, true);
            smoke.AnimationFPS = 12;
            smoke.Scale = 1.0f;
            smoke.TintColor *= alpha;
            smoke.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
            EffectSprites.Add(smoke);
        }
 void contactListener_ShotFired(object sender, EffectEventArgs e)
 {
     Sprite smoke = new Sprite(1, 0, e.location, true);
     smoke.AnimationFPS = 12;
     smoke.TotalRotation = e.spriteA.TotalRotation + MathHelper.ToRadians(-90);
     smoke.SpriteRectangle = new Rectangle((int)e.location.X-62, (int)e.location.Y-62, 124, 124);
     smoke.Scale = e.spriteA.Scale;
     smoke.TintColor *= 0.33f;
     EffectSprites.Add(smoke);
     smoke = new Sprite(16, 0, e.location, true);
     smoke.AnimationFPS = 12;
     smoke.TotalRotation = e.spriteA.TotalRotation + MathHelper.ToRadians(0);
     smoke.SpriteRectangle = new Rectangle((int)e.location.X-62, (int)e.location.Y-62, 124, 124);
     smoke.Scale = e.spriteA.Scale;
     smoke.TintColor *= 0.4f;
     EffectSprites.Add(smoke);
 }
        void contactListener_Poof(object sender, EffectEventArgs e)
        {
            int smokeID = 15;
            Vector2 originOffset = new Vector2(30,30);
            float AlphaOffset = 0.33f;
            Sprite smoke;

            #region Block poof
            if (e.spriteA.SpriteType == Sprite.Type.Block)
            {
                if (e.spriteA.SpriteRectHeight == e.spriteA.SpriteRectWidth)
                {
                    smokeID = 14;
                    originOffset = new Vector2(62, 62);
                    float scale = e.spriteA.SpriteRectHeight *0.02f;
                    smoke = new Sprite(smokeID, 0, e.spriteA.Location + e.spriteA.SpriteOrigin - originOffset, true);
                    smoke.AnimationFPS = LevelDataManager.rand.Next(8, 13);
                    smoke.Scale = scale;
                    smoke.TintColor *= AlphaOffset;
                    smoke.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
                    EffectSprites.Add(smoke);
                    smoke = new Sprite(smokeID, 0, e.spriteA.Location + e.spriteA.SpriteOrigin - originOffset - (new Vector2(16,0)*scale), true);
                    smoke.AnimationFPS = LevelDataManager.rand.Next(8, 13);
                    smoke.Scale = scale;
                    smoke.TintColor *= AlphaOffset;
                    smoke.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
                    EffectSprites.Add(smoke);
                    smoke = new Sprite(smokeID, 0, e.spriteA.Location + e.spriteA.SpriteOrigin - originOffset - (new Vector2(-16, 0)*scale), true);
                    smoke.AnimationFPS = LevelDataManager.rand.Next(8, 13);
                    smoke.Scale = scale;
                    smoke.TintColor *= AlphaOffset;
                    smoke.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
                    EffectSprites.Add(smoke);
                    smoke = new Sprite(smokeID, 0, e.spriteA.Location + e.spriteA.SpriteOrigin - originOffset - (new Vector2(0, 16)*scale), true);
                    smoke.AnimationFPS = LevelDataManager.rand.Next(8, 13);
                    smoke.Scale = scale;
                    smoke.TintColor *= AlphaOffset;
                    smoke.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
                    EffectSprites.Add(smoke);
                    smoke = new Sprite(smokeID, 0, e.spriteA.Location + e.spriteA.SpriteOrigin - originOffset - (new Vector2(0,-16)*scale), true);
                    smoke.AnimationFPS = LevelDataManager.rand.Next(8, 13);
                    smoke.Scale = scale;
                    smoke.TintColor *= AlphaOffset;
                    smoke.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
                    EffectSprites.Add(smoke);
                    return;
                }
                else
                {
                    smokeID = 14;
                    originOffset = new Vector2(62, 62);
                    float scale = ((e.spriteA.SpriteRectWidth *0.25f) + (e.spriteA.SpriteRectHeight*0.75f)) *0.02f;
                    Vector2 rotationOffset = new Vector2((float)Math.Cos(e.spriteA.TotalRotation), (float)Math.Sin(e.spriteA.TotalRotation)) * e.spriteA.SpriteRectWidth*0.5f;
                    smoke = new Sprite(smokeID, 0, e.spriteA.Location + e.spriteA.SpriteOrigin - originOffset, true);
                    smoke.AnimationFPS = LevelDataManager.rand.Next(8, 13);
                    smoke.Scale = scale;
                    smoke.TintColor *= AlphaOffset;
                    smoke.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
                    EffectSprites.Add(smoke);
                    smoke = new Sprite(smokeID, 0, e.spriteA.Location + e.spriteA.SpriteOrigin - originOffset - (rotationOffset), true);
                    smoke.AnimationFPS = LevelDataManager.rand.Next(8, 13);
                    smoke.Scale = scale;
                    smoke.TintColor *= AlphaOffset;
                    smoke.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
                    EffectSprites.Add(smoke);
                    smoke = new Sprite(smokeID, 0, e.spriteA.Location + e.spriteA.SpriteOrigin - originOffset - (rotationOffset*0.66f), true);
                    smoke.AnimationFPS = LevelDataManager.rand.Next(8, 13);
                    smoke.Scale = scale;
                    smoke.TintColor *= AlphaOffset;
                    smoke.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
                    EffectSprites.Add(smoke);
                    smoke = new Sprite(smokeID, 0, e.spriteA.Location + e.spriteA.SpriteOrigin - originOffset - (rotationOffset * 0.33f), true);
                    smoke.AnimationFPS = LevelDataManager.rand.Next(8, 13);
                    smoke.Scale = scale;
                    smoke.TintColor *= AlphaOffset;
                    smoke.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
                    EffectSprites.Add(smoke);
                    smoke = new Sprite(smokeID, 0, e.spriteA.Location + e.spriteA.SpriteOrigin - originOffset + (rotationOffset), true);
                    smoke.AnimationFPS = LevelDataManager.rand.Next(8, 13);
                    smoke.Scale = scale;
                    smoke.TintColor *= AlphaOffset;
                    smoke.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
                    EffectSprites.Add(smoke);
                    smoke = new Sprite(smokeID, 0, e.spriteA.Location + e.spriteA.SpriteOrigin - originOffset + (rotationOffset*0.66f), true);
                    smoke.AnimationFPS = LevelDataManager.rand.Next(8, 13);
                    smoke.Scale = scale;
                    smoke.TintColor *= AlphaOffset;
                    smoke.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
                    EffectSprites.Add(smoke);
                    smoke = new Sprite(smokeID, 0, e.spriteA.Location + e.spriteA.SpriteOrigin - originOffset + (rotationOffset * 0.33f), true);
                    smoke.AnimationFPS = LevelDataManager.rand.Next(8, 13);
                    smoke.Scale = scale;
                    smoke.TintColor *= AlphaOffset;
                    smoke.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
                    EffectSprites.Add(smoke);
                    return;
                }
            }
            #endregion

            if (e.spriteA.SpriteType == Sprite.Type.SawShot || e.spriteA.SpriteType == Sprite.Type.CannonballShot || e.spriteA.SpriteType == Sprite.Type.Veggie)
            {
                smokeID = 14;
                originOffset = new Vector2(62, 62);
            }
            if (e.spriteA.SpriteType == Sprite.Type.PowerUp)
            {
                smokeID = 13;
                originOffset = new Vector2(126, 126);
            }
            if (e.spriteA.SpriteType == Sprite.Type.FireballShot)
            {
                smokeID = 13;
                originOffset = new Vector2(126, 126);
                AlphaOffset = 0.2f;
            }
            if (e.spriteA.SpriteType == Sprite.Type.FireBoo)
            {
                AlphaOffset = 0.15f;
            }

            smoke = new Sprite(smokeID, 0, e.spriteA.Location + e.spriteA.SpriteOrigin - originOffset - new Vector2(-16, 0), true);
            smoke.AnimationFPS = LevelDataManager.rand.Next(8, 13);
            smoke.Scale = 1.0f;
            smoke.TintColor *= AlphaOffset;
            smoke.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
            EffectSprites.Add(smoke);
            smoke = new Sprite(smokeID, 0, e.spriteA.Location + e.spriteA.SpriteOrigin - originOffset - new Vector2(16, 0), true);
            smoke.AnimationFPS = LevelDataManager.rand.Next(8, 13);
            smoke.Scale = 1.0f;
            smoke.TintColor *= AlphaOffset;
            smoke.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
            EffectSprites.Add(smoke);
            smoke = new Sprite(smokeID, 0, e.spriteA.Location + e.spriteA.SpriteOrigin - originOffset - new Vector2(0, 16), true);
            smoke.AnimationFPS = LevelDataManager.rand.Next(8, 13);
            smoke.Scale = 1.0f;
            smoke.TintColor *= AlphaOffset;
            smoke.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
            EffectSprites.Add(smoke);
            smoke = new Sprite(smokeID, 0, e.spriteA.Location + e.spriteA.SpriteOrigin - originOffset - new Vector2(0, -16), true);
            smoke.AnimationFPS = LevelDataManager.rand.Next(8, 13);
            smoke.Scale = 1.0f;
            smoke.TintColor *= AlphaOffset;
            smoke.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
            smoke = new Sprite(smokeID, 0, e.spriteA.Location + e.spriteA.SpriteOrigin - originOffset, true);
            smoke.AnimationFPS = LevelDataManager.rand.Next(8, 13);
            smoke.Scale = 1.2f;
            smoke.TintColor *= AlphaOffset;
            smoke.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
            EffectSprites.Add(smoke);
            return;
        }
 static void contactListener_SpringDeflection(object sender, EffectEventArgs e)
 {
     Play(Sound.Spring, false, true);
 }
        void contactListener_WindParticleCreated(object sender, EffectEventArgs e)
        {
            if (LevelDataManager.rand.Next(0, 2) != 0) return;
            int windPlacementRangeX = (int)MathHelper.Max(1, e.spriteA.SpriteRectWidth / 2);
            float cos = (float)Math.Cos(e.spriteA.TotalRotation);
            float sin = (float)Math.Sin(e.spriteA.TotalRotation);
            Sprite wind = new Sprite(29, 0, e.spriteA.SpriteCenterInWorld, true);
            wind.HitPoints = 400; //ms timer
            wind.IsAwake = true;
            wind.Scale = (float)LevelDataManager.rand.Next(250, 501) * 0.01f * e.spriteA.Scale;
            wind.RotationSpeed = LevelDataManager.rand.Next(-800, 800);
            //chunk origin centered on origin of destructing sprite, add random offset so chunk can appear from anywhere inside the sprite
            Vector2 randomOffset = new Vector2(LevelDataManager.rand.Next(-windPlacementRangeX, windPlacementRangeX + 1),-e.spriteA.SpriteRectHeight/2);

            //add rotation offset factor to account for fan rotation
            wind.Location += new Vector2((randomOffset.X * cos) - (randomOffset.Y * sin), (randomOffset.X * sin) + (randomOffset.Y * cos));
            wind.TintColor = Color.White * ((float)LevelDataManager.rand.Next(25,36) * 0.01f);
            wind.Direction = new Vector2((float)Math.Cos(e.spriteA.TotalRotation + MathHelper.ToRadians(-90)), (float)Math.Sin(e.spriteA.TotalRotation + MathHelper.ToRadians(-90)));
            wind.Velocity = 500;

            EffectSprites.Add(wind);
        }
        void contactListener_VeggieExploded(object sender, EffectEventArgs e)
        {
            int splatTextureIndex = 0;
            int chunkTextureIndex = 0;
            int totalChunks = 32;
            if (e.spriteA.Scale == 1.5f) totalChunks = 64;
            switch (e.spriteA.TextureIndex)
            {
                case 0:
                    {
                        splatTextureIndex = 0;
                        chunkTextureIndex = 0;
                        break;
                    }
                case 7:
                    {
                        splatTextureIndex = 6;
                        chunkTextureIndex = 3;
                        break;
                    }
                case 14:
                    {
                        splatTextureIndex = 12;
                        chunkTextureIndex = 6;
                        break;
                    }
                case 21:
                    {
                        splatTextureIndex = 18;
                        chunkTextureIndex = 9;
                        break;
                    }
                case 28:
                    {
                        splatTextureIndex = 24;
                        chunkTextureIndex = 12;
                        break;
                    }
                case 35:
                    {
                        splatTextureIndex = 30;
                        chunkTextureIndex = 15;
                        break;
                    }
                case 42:
                    {
                        splatTextureIndex = 36;
                        chunkTextureIndex = 18;
                        break;
                    }
                case 49:
                    {
                        splatTextureIndex = 42;
                        chunkTextureIndex = 21;
                        break;
                    }
                case 56:
                    {
                        splatTextureIndex = 42;
                        chunkTextureIndex = 21;
                        break;
                    }
                case 63:
                    {
                        splatTextureIndex = 48;
                        chunkTextureIndex = 24;
                        break;
                    }
                case 70:
                    {
                        splatTextureIndex = 30;
                        chunkTextureIndex = 27;
                        break;
                    }
                case 77:
                    {
                        splatTextureIndex = 36;
                        chunkTextureIndex = 30;
                        break;
                    }
                case 84: //patch thing
                    {
                        splatTextureIndex = 24;
                        chunkTextureIndex = 33;
                        break;
                    }
                case 91: //pea
                    {
                        splatTextureIndex = 42;
                        chunkTextureIndex = 21;
                        totalChunks = 8;
                        break;
                    }
                case 98: //washer
                    {
                        contactListener.DoPoof(e.spriteA);
                        return;   //no chunks for washer
                        break;
                    }
                default:
                    break;
            }

            //create chunky effects
            for (int i = 0; i < totalChunks; i++)
            {
                Sprite chunk = new Sprite(18, chunkTextureIndex + LevelDataManager.rand.Next(0, 3), e.spriteA.Location + e.spriteA.SpriteOrigin - new Vector2(8, 8),true); //create a chunk matching to the origin
                chunk.HitPoints = 2000; //ms timer
                chunk.IsAwake = true;
                chunk.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
                chunk.Scale = (float)LevelDataManager.rand.Next(50, 151) *0.01f * e.spriteA.Scale;

                //setup manual physics calculation variables
                chunk.RotationSpeed = LevelDataManager.rand.Next(-800, 800);
                Vector2 velocity = ConvertUnits.ToDisplayUnits(e.spriteA.spriteBody.LinearVelocity) + new Vector2(LevelDataManager.rand.Next(-300, 301), LevelDataManager.rand.Next(-400, 201));
                chunk.Velocity = Math.Min(2000, velocity.Length());
                velocity.Normalize();
                chunk.Direction = velocity;

                EffectSprites.Add(chunk);
            }

            Sprite splat = new Sprite(19, splatTextureIndex, e.spriteA.Location, true);
            splat.AnimationFPS = 14;
            splat.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
            splat.Scale = 1.4f * e.spriteA.Scale;
            splat.SpriteRectangle = new Rectangle((int)e.spriteA.SpriteRectangle.X - 68, (int)e.spriteA.SpriteRectangle.Y - 68, 200, 200);
            EffectSprites.Add(splat);
            splat = new Sprite(19, splatTextureIndex, e.spriteA.Location, true);
            splat.AnimationFPS = 12;
            splat.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
            splat.Scale = 1.2f * e.spriteA.Scale;
            splat.SpriteRectangle = new Rectangle((int)e.spriteA.SpriteRectangle.X - 68, (int)e.spriteA.SpriteRectangle.Y - 68, 200, 200);
            EffectSprites.Add(splat);
            splat = new Sprite(19, splatTextureIndex, e.spriteA.Location, true);
            splat.AnimationFPS = 10;
            splat.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
            splat.Scale = 1.0f * e.spriteA.Scale;
            splat.SpriteRectangle = new Rectangle((int)e.spriteA.SpriteRectangle.X - 68, (int)e.spriteA.SpriteRectangle.Y - 68, 200, 200);
            EffectSprites.Add(splat);
            splat = new Sprite(19, splatTextureIndex, e.spriteA.Location, true);
            splat.AnimationFPS = 12;
            splat.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
            splat.Scale = 0.8f * e.spriteA.Scale;
            splat.SpriteRectangle = new Rectangle((int)e.spriteA.SpriteRectangle.X - 68, (int)e.spriteA.SpriteRectangle.Y - 68, 200, 200);
            EffectSprites.Add(splat);
            splat = new Sprite(19, splatTextureIndex, e.spriteA.Location, true);
            splat.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
            splat.AnimationFPS = 14;
            splat.Scale = 0.6f * e.spriteA.Scale;
            splat.SpriteRectangle = new Rectangle((int)e.spriteA.SpriteRectangle.X - 68, (int)e.spriteA.SpriteRectangle.Y - 68, 200, 200);
            EffectSprites.Add(splat);
            return;
        }
        void contactListener_FireShotExploded(object sender, EffectEventArgs e)
        {
            Sprite smoke = new Sprite(13, 0, e.spriteA.Location, true);
            smoke.AnimationFPS = LevelDataManager.rand.Next(6, 12);
            smoke.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
            smoke.Scale = 1.4f * e.spriteA.Scale;
            smoke.TintColor *= 0.33f;
            smoke.SpriteRectangle = new Rectangle((int)e.spriteA.SpriteCenterInWorld.X - 126, (int)e.spriteA.SpriteCenterInWorld.Y - 126, 252, 252);
            EffectSprites.Add(smoke);
            smoke = new Sprite(13, 0, e.spriteA.Location, true);
            smoke.AnimationFPS = LevelDataManager.rand.Next(6, 12);
            smoke.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
            smoke.Scale = 1.2f * e.spriteA.Scale;
            smoke.TintColor *= 0.33f;
            smoke.SpriteRectangle = new Rectangle((int)e.spriteA.SpriteCenterInWorld.X - 126, (int)e.spriteA.SpriteCenterInWorld.Y - 126, 252, 252);
            EffectSprites.Add(smoke);
            smoke = new Sprite(13, 0, e.spriteA.Location, true);
            smoke.AnimationFPS = LevelDataManager.rand.Next(6, 12);
            smoke.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
            smoke.Scale = 1.0f * e.spriteA.Scale;
            smoke.TintColor *= 0.33f;
            smoke.SpriteRectangle = new Rectangle((int)e.spriteA.SpriteCenterInWorld.X - 126, (int)e.spriteA.SpriteCenterInWorld.Y - 126, 252, 252);
            EffectSprites.Add(smoke);

            Sprite fireblast = new Sprite(4, 0, e.spriteA.Location, true); ;
            fireblast.AnimationFPS = 12;
            fireblast.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(1, 360));
            fireblast.Scale = 1.2f * e.spriteA.Scale;
            fireblast.SpriteRectangle = new Rectangle((int)e.spriteA.SpriteCenterInWorld.X - 126, (int)e.spriteA.SpriteCenterInWorld.Y - 126, 252, 252);
            EffectSprites.Add(fireblast);

            fireblast = new Sprite(4, 0, e.spriteA.Location, true);
            fireblast.AnimationFPS = 10;
            fireblast.TotalRotation = e.spriteA.TotalRotation;
            fireblast.Scale = 1.0f * e.spriteA.Scale;
            fireblast.SpriteRectangle = new Rectangle((int)e.spriteA.SpriteCenterInWorld.X - 126, (int)e.spriteA.SpriteCenterInWorld.Y - 126, 252, 252);
            fireblast.HitPoints = 30;
            Vector2 position = ConvertUnits.ToSimUnits(fireblast.SpriteCenterInWorld);
            float explosionRadius = ConvertUnits.ToSimUnits(e.spriteA.SpriteRectWidth * fireblast.Scale *0.5f);
            fireblast.spriteBody = BodyFactory.CreateCircle(physicsWorld, explosionRadius, 1.0f, position, fireblast);
            fireblast.spriteBody.BodyType = BodyType.Dynamic;
            fireblast.spriteBody.ResetDynamics();
            fireblast.spriteBody.IsSensor = true;
            fireblast.spriteBody.IgnoreGravity = true;
            fireblast.SpriteType = Sprite.Type.FireballBlast;
            EffectSprites.Add(fireblast);

            fireblast = new Sprite(4, 0, e.spriteA.Location, true);
            fireblast.AnimationFPS = 12;
            fireblast.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(1, 360));
            fireblast.Scale = 0.8f * e.spriteA.Scale;
            fireblast.SpriteRectangle = new Rectangle((int)e.spriteA.SpriteCenterInWorld.X - 126, (int)e.spriteA.SpriteCenterInWorld.Y - 126, 252, 252);
            EffectSprites.Add(fireblast);

            return;
        }
 void contactListener_EmberCreated(object sender, EffectEventArgs e)
 {
     Sprite ember = new Sprite(2, 4, e.spriteA.SpriteCenterInWorld - new Vector2(16, 16), true); //create bottom center of the sprite
     //range to create anywher inside the sprite area
     ember.Location += new Vector2(LevelDataManager.rand.Next((int)(-e.spriteA.SpriteRectWidth * 0.5f), (int)(e.spriteA.SpriteRectWidth * 0.5f)),
                                   LevelDataManager.rand.Next((int)(-e.spriteA.SpriteRectHeight * 0.5f), (int)(e.spriteA.SpriteRectHeight * 0.5f)));
     ember.HitPoints = 0; //ms timer
     ember.IsAwake = true;
     ember.Scale = (float)LevelDataManager.rand.Next(20, 41) * 0.01f * e.spriteA.Scale;
     EffectSprites.Add(ember);
 }
        void contactListener_CreatureExploded(object sender, EffectEventArgs e)
        {
            int splatTextureIndex = 0;
            int chunkTextureIndex = 24;
            if (e.spriteA.SpriteType == Sprite.Type.Beehive)
            {
                splatTextureIndex = 18;
                chunkTextureIndex = 21;
            }
            if (e.spriteA.SpriteType == Sprite.Type.FireBoo)
            {
                contactListener.ExplodeFireShot(e.spriteA);
                return;
            }

            int totalChunks = 36;
            //create chunky effects

            if (e.spriteA.Scale == 1.5f) totalChunks = 72;

            for (int i = 0; i < totalChunks; i++)
            {
                Sprite chunk = new Sprite(6, chunkTextureIndex + LevelDataManager.rand.Next(0, 3), e.spriteA.Location + e.spriteA.SpriteOrigin - new Vector2(8, 8), true); //create a chunk matching to the veggie origin
                chunk.HitPoints = 2000; //ms timer
                chunk.IsAwake = true;
                chunk.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
                chunk.Scale = (float)LevelDataManager.rand.Next(50, 151) / 100f * e.spriteA.Scale;

                //setup manual physics calculation variables
                chunk.RotationSpeed = LevelDataManager.rand.Next(-800, 801);
                Vector2 velocity = ConvertUnits.ToDisplayUnits(e.spriteA.spriteBody.LinearVelocity) + new Vector2(LevelDataManager.rand.Next(-400, 401), LevelDataManager.rand.Next(-400, 401));
                chunk.Velocity = velocity.Length();
                velocity.Normalize();
                chunk.Direction = velocity;

                EffectSprites.Add(chunk);
            }

            if (e.spriteA.SpriteType == Sprite.Type.Bird)
            {
                for (int i = 0; i < 10; i++)
                {
                    Sprite chunk = new Sprite(2, 2, e.spriteA.SpriteCenterInWorld - new Vector2(16, 16), true); //create a chunk bottom center of the sprite
                    chunk.HitPoints = 2000; //ms timer
                    chunk.IsAwake = true;
                    chunk.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
                    chunk.Scale = (float)LevelDataManager.rand.Next(50, 101) * 0.01f * e.spriteA.Scale;

                    //setup manual physics calculation variables
                    chunk.RotationSpeed = LevelDataManager.rand.Next(-400, 401);
                    Vector2 velocity = ConvertUnits.ToDisplayUnits(e.spriteA.spriteBody.LinearVelocity) + new Vector2(LevelDataManager.rand.Next(-400, 401), LevelDataManager.rand.Next(-400,400));
                    chunk.Velocity = velocity.Length();
                    velocity.Normalize();
                    chunk.Direction = velocity;

                    EffectSprites.Add(chunk);
                }
            }

            Sprite splat = new Sprite(7, splatTextureIndex, e.spriteA.Location, true);
            splat.AnimationFPS = 14;
            splat.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
            splat.Scale = 1.4f * e.spriteA.Scale;
            splat.SpriteRectangle = new Rectangle((int)e.spriteA.SpriteRectangle.X - 68, (int)e.spriteA.SpriteRectangle.Y - 68, 200, 200);
            EffectSprites.Add(splat);
            splat = new Sprite(7, splatTextureIndex, e.spriteA.Location, true);
            splat.AnimationFPS = 12;
            splat.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
            splat.Scale = 1.2f * e.spriteA.Scale;
            splat.SpriteRectangle = new Rectangle((int)e.spriteA.SpriteRectangle.X - 68, (int)e.spriteA.SpriteRectangle.Y - 68, 200, 200);
            EffectSprites.Add(splat);
            splat = new Sprite(7, splatTextureIndex, e.spriteA.Location, true);
            splat.AnimationFPS = 10;
            splat.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
            splat.Scale = 1.0f * e.spriteA.Scale;
            splat.SpriteRectangle = new Rectangle((int)e.spriteA.SpriteRectangle.X - 68, (int)e.spriteA.SpriteRectangle.Y - 68, 200, 200);
            EffectSprites.Add(splat);
            splat = new Sprite(7, splatTextureIndex, e.spriteA.Location, true);
            splat.AnimationFPS = 12;
            splat.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
            splat.Scale = 0.8f * e.spriteA.Scale;
            splat.SpriteRectangle = new Rectangle((int)e.spriteA.SpriteRectangle.X - 68, (int)e.spriteA.SpriteRectangle.Y - 68, 200, 200);
            EffectSprites.Add(splat);
            splat = new Sprite(7, splatTextureIndex, e.spriteA.Location, true);
            splat.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
            splat.AnimationFPS = 14;
            splat.Scale = 0.6f * e.spriteA.Scale;
            splat.SpriteRectangle = new Rectangle((int)e.spriteA.SpriteRectangle.X - 68, (int)e.spriteA.SpriteRectangle.Y - 68, 200, 200);
            EffectSprites.Add(splat);
            return;
        }
        void contactListener_BombExploded(object sender, EffectEventArgs e)
        {
            explosion = new Explosion(physicsWorld);
            Vector2 explosionLocation = e.spriteA.spriteBody.Position;
            float explosionRadius = 0f;
            float explosionForce = 0f;
            if (e.spriteA.TextureID == 48)
            {
                explosionRadius = ConvertUnits.ToSimUnits(GameSettings.ExplosiveForceRadiusMultiplier * 9f);
                explosionForce = GameSettings.ExplosivePower * 9f;  //large tnt
            }
            if (e.spriteA.TextureID == 49)
            {
                explosionRadius = ConvertUnits.ToSimUnits(GameSettings.ExplosiveForceRadiusMultiplier * 3f);
                explosionForce = GameSettings.ExplosivePower * 3f; //medium tnt
            }
            if (e.spriteA.TextureID == 50 || e.spriteA.SpriteType == Sprite.Type.Veggie)
            {
                explosionRadius = ConvertUnits.ToSimUnits(GameSettings.ExplosiveForceRadiusMultiplier);
                explosionForce = GameSettings.ExplosivePower; //small tnt
            }
            if (e.spriteA.TextureID == 20)
            {
                explosionRadius = ConvertUnits.ToSimUnits(GameSettings.ExplosiveForceRadiusMultiplier * e.spriteA.Scale);
                explosionForce = GameSettings.ExplosivePower * 0.5f * e.spriteA.Scale; //cherry
            }

            if (GameSettings.CheatFunsplosions)
            {
                explosionRadius *= 2f;
                explosionForce *= 2f;
            }

            explosion.Activate(explosionLocation, explosionRadius, explosionForce);

            contactListener.DoPoof(e.spriteA);
            Sprite smoke = new Sprite(13, 0, e.spriteA.Location + e.spriteA.SpriteOrigin - new Vector2(126,126) ,true);
            smoke.AnimationFPS = 12;
            smoke.Scale = (float)e.spriteA.SpriteRectWidth / 64f;
            smoke.TintColor *= 0.33f;
            EffectSprites.Add(smoke);
            smoke = new Sprite(14, 0, e.spriteA.Location + e.spriteA.SpriteOrigin - new Vector2(62, 62), true);
            smoke.AnimationFPS = LevelDataManager.rand.Next(6, 12);
            smoke.Scale = (float)e.spriteA.SpriteRectWidth / 64f;
            smoke.TotalRotation = (float)(LevelDataManager.rand.Next(0, 314)) / 100.0f;
            smoke.TintColor *= 0.33f;
            EffectSprites.Add(smoke);
            smoke = new Sprite(14, 0, e.spriteA.Location + e.spriteA.SpriteOrigin - new Vector2(62, 62), true);
            smoke.AnimationFPS = LevelDataManager.rand.Next(6, 12);
            smoke.Scale = (float)e.spriteA.SpriteRectWidth / 64f;
            smoke.TotalRotation = (float)(LevelDataManager.rand.Next(0, 314)) / 100.0f;
            smoke.TintColor *= 0.33f;
            EffectSprites.Add(smoke);
            smoke = new Sprite(15, 0, e.spriteA.Location + e.spriteA.SpriteOrigin - new Vector2(30, 30), true);
            smoke.AnimationFPS = LevelDataManager.rand.Next(6, 12);
            smoke.Scale = (float)e.spriteA.SpriteRectWidth / 64f;
            smoke.TotalRotation = (float)(LevelDataManager.rand.Next(0, 314)) / 100.0f;
            smoke.TintColor *= 0.33f;
            EffectSprites.Add(smoke);
            smoke = new Sprite(15, 0, e.spriteA.Location + e.spriteA.SpriteOrigin - new Vector2(30, 30), true);
            smoke.AnimationFPS = LevelDataManager.rand.Next(6, 12);
            smoke.Scale = (float)e.spriteA.SpriteRectWidth / 64f;
            smoke.TotalRotation = (float)(LevelDataManager.rand.Next(0, 314)) / 100.0f;
            smoke.TintColor *= 0.33f;
            EffectSprites.Add(smoke);
            Sprite bomb = new Sprite(0, 0, e.spriteA.Location + e.spriteA.SpriteOrigin - new Vector2(64, 64), true);
            bomb.HitPoints = 12;
            bomb.TotalRotation = 0.0001f;
            bomb.Scale = (float)e.spriteA.SpriteRectWidth / 64f;
            Vector2 position = ConvertUnits.ToSimUnits(bomb.SpriteCenterInWorld);
            float bombRadius = ConvertUnits.ToSimUnits(e.spriteA.SpriteRectWidth);
            if (e.spriteA.TextureID == 20)
            {
                bombRadius *= 0.5f *e.spriteA.Scale;
                bomb.Scale *= 0.5f *e.spriteA.Scale;
            }
            bomb.spriteBody = BodyFactory.CreateCircle(physicsWorld,bombRadius,1.0f,position, bomb);
            bomb.spriteBody.BodyType = BodyType.Dynamic;
            bomb.spriteBody.ResetDynamics();
            bomb.spriteBody.IsSensor = true;
            bomb.spriteBody.IgnoreGravity = true;
            bomb.SpriteType = Sprite.Type.Explosion;
            EffectSprites.Add(bomb);
            return;
        }
示例#25
0
        private void DoChanged(IPersonCondition effect)
        {
            var args = new EffectEventArgs(effect);

            Changed?.Invoke(this, args);
        }
 static void contactListener_VeggieExploded(object sender, EffectEventArgs e)
 {
     if (GameSettings.CheatGoodToBeBad) return;
     else
     {
         if (e.spriteA.TextureIndex != 98) Play(Sound.FruitHit1, Sound.FruitHit2, Sound.FruitHit3, false, true);
         else Play(Sound.CannonBallHit1, Sound.CannonBallHit2, false, true);
     }
 }
 void contactListener_VeggieExploded(object sender, EffectEventArgs e)
 {
     if (GameSettings.CheatGoodToBeBad) contactListener.ExplodeBomb(e.spriteA);
     e.spriteA.IsExpired = true;
     physicsWorld.RemoveBody(e.spriteA.spriteBody);
     VeggieSprites.Remove(e.spriteA);
 }
        void contactListener_SnowballThrown(object sender, EffectEventArgs e)
        {
            e.spriteA.spriteBody.Enabled = false;
            Sprite snowball = new Sprite(17, 0, e.spriteA.SpriteCenterInWorld - new Vector2(8,8), true);
            if (e.spriteA.IsFlippedHorizontally)
                snowball.Location += new Vector2(30, 10);
            else
                snowball.Location += new Vector2(-30, 10);
            snowball.SpriteType = Sprite.Type.Snowball;
            snowball.HitPoints = 1;
            snowball.AnimationFramePrecise = 5000; //timer to fade out in ms
            snowball.IsCollidable = true;
            snowball.IsAwake = true;
            snowball.spriteBody = BodyFactory.CreateEllipse(physicsWorld, ConvertUnits.ToSimUnits(8),ConvertUnits.ToSimUnits(8), 8, 1.0f, ConvertUnits.ToSimUnits(snowball.SpriteCenterInWorld), snowball);
            snowball.spriteBody.BodyType = BodyType.Dynamic;
            snowball.spriteBody.Mass = 2f;
            snowball.spriteBody.IgnoreCollisionWith(e.spriteA.spriteBody);
            if (e.spriteA.IsFlippedHorizontally) snowball.spriteBody.LinearVelocity = new Vector2(-8, -6);
            else snowball.spriteBody.LinearVelocity = new Vector2(8, -6);
            EffectSprites.Add(snowball);

            e.spriteA.spriteBody.Enabled = true;
        }
        void contactListener_TowerSawShot(object sender, EffectEventArgs e)
        {
            Sprite sprite = new Sprite(46, 0, e.spriteA.Location, false);
            sprite.SpriteType = Sprite.Type.Saw;
            sprite.IsCollidable = true;
            sprite.IsAwake = true;
            sprite.IsRotating = true;
            sprite.IsVisible = true;
            EffectSprites.Add(sprite);
            Vector2 position = ConvertUnits.ToSimUnits(sprite.Location + sprite.SpriteOrigin);
            sprite.spriteBody = BodyFactory.CreateEllipse(physicsWorld, ConvertUnits.ToSimUnits(sprite.SpriteRectWidth / 2.0f), ConvertUnits.ToSimUnits(sprite.SpriteRectHeight / 2.0f), 10, 0.9f, position, sprite);
            sprite.spriteBody.Rotation = 0;
            sprite.spriteBody.BodyType = BodyType.Kinematic;
            sprite.spriteBody.IgnoreGravity = true;
            sprite.spriteBody.IsSensor = true;
            sprite.spriteBody.LinearVelocity = new Vector2(towerSawSpeed, 0);
            if (!e.spriteA.IsFlippedHorizontally) sprite.spriteBody.LinearVelocity *= -1f;
            sprite.HitPoints = -10000;

            Sprite tower = new Sprite(10, 0, e.spriteA.Location, false);
            tower.SpriteType = Sprite.Type.Tower;
            tower.HitPoints = -500;
            tower.IsFlippedHorizontally = e.spriteA.IsFlippedHorizontally;
            EffectSprites.Add(tower);
        }
 static void contactListener_StarCollected(object sender, EffectEventArgs e)
 {
     Play(Sound.StarCollect, false, false);
 }
 void contactListener_WaterSplash(object sender, EffectEventArgs e)
 {
     int totalChunks = 12;
     for (int i = 0; i < totalChunks; i++)
     {
         Sprite chunk = new Sprite(2, 0, e.spriteA.SpriteCenterInWorld - new Vector2(16, 16), true); //create a chunk bottom center of the sprite
         chunk.Location += new Vector2(LevelDataManager.rand.Next((int)(-e.spriteA.SpriteRectWidth *0.5f), (int)(e.spriteA.SpriteRectWidth *0.5f)),0);
         chunk.HitPoints = 1000; //ms timer
         chunk.IsAwake = true;
         chunk.Scale = (float)LevelDataManager.rand.Next(20, 51) * 0.01f * e.spriteA.Scale;
         Vector2 velocity = new Vector2(LevelDataManager.rand.Next(-150, 151), LevelDataManager.rand.Next(-300,-100));
         chunk.Velocity = velocity.Length();
         velocity.Normalize();
         chunk.Direction = velocity;
         chunk.TintColor = tint;
         EffectSprites.Add(chunk);
     }
 }
        void contactListener_SpringDeflection(object sender, EffectEventArgs e)
        {
            if (e.spriteA.spriteBody.IsBullet) return;
            if (e.spriteA.IsAnimated) return;

            Vector2 springDirectionVector = new Vector2((float)Math.Sin(e.spriteA.TotalRotation),(float)-Math.Cos(e.spriteA.TotalRotation));

            e.spriteA.TotalRotation = (float)NormalizeRotation(e.spriteA.TotalRotation);
            Vector2 directionVector = e.spriteB.spriteBody.LinearVelocity;
            directionVector.Normalize();
            float velocity = e.spriteB.spriteBody.LinearVelocity.Length();

            //calc angle from vertical
            double thetaAngle = Math.Asin(directionVector.X);
            if (directionVector.Y < 0 && directionVector.X > 0) thetaAngle = Math.PI - thetaAngle;
            if (directionVector.Y < 0 && directionVector.X < 0) thetaAngle = -Math.PI - thetaAngle;

            //subtract springrotation
            thetaAngle = thetaAngle + e.spriteA.TotalRotation;
            thetaAngle = NormalizeRotation(thetaAngle);

            //final angle calc
            double finalAngle = 0.0;
            double piOverTwo = Math.PI * 0.5;
            if (thetaAngle < -piOverTwo) finalAngle = thetaAngle + Math.PI;
            if (thetaAngle >= -piOverTwo && thetaAngle <= piOverTwo) finalAngle = -thetaAngle;
            if (thetaAngle > piOverTwo) finalAngle = thetaAngle - Math.PI;

            //addspring rotation
            finalAngle = finalAngle - e.spriteA.TotalRotation;
            //finalAngle = -finalAngle; //reverse the invert for calcs

            //calc final direction vector
            directionVector = new Vector2(-(float)Math.Sin(finalAngle), -(float)Math.Cos(finalAngle));

            //apply magnitude
            e.spriteB.spriteBody.LinearVelocity = directionVector * (velocity* springEnergyReflect); //some energy loss with the factor
            e.spriteB.spriteBody.LinearVelocity += springDirectionVector * springDirectionEnergy; //spring bump
            e.spriteB.spriteBody.AngularVelocity += ((float)LevelDataManager.rand.Next(-200, 200) / 100.0f);

            e.spriteA.IsAnimated = true;
            e.spriteA.IsAnimationDirectionForward = true;
            return;
        }
        void contactListener_BlockExploded(object sender, EffectEventArgs e)
        {
            int chunkTextureIndex = 0;
            int totalChunks = (int)MathHelper.Max(4,(e.spriteA.SpriteRectWidth * e.spriteA.SpriteRectHeight/64)); //should generate 4 chunks per 16x16 area

            //create chunky effects

            if (e.spriteA.TextureIndex == 0) chunkTextureIndex = 0;
            if (e.spriteA.TextureIndex == 1) chunkTextureIndex = 2;
            if (e.spriteA.TextureIndex == 2) chunkTextureIndex = 6;
            if (e.spriteA.TextureIndex == 3) chunkTextureIndex = 4;

            int chunkPlacementRangeX = (int)MathHelper.Max(1,(e.spriteA.SpriteRectWidth - 16)/2);
            int chunkPlacementRangeY = (int)MathHelper.Max(1,(e.spriteA.SpriteRectHeight - 16)/2);

            float cos = (float)Math.Cos(e.spriteA.TotalRotation);
            float sin = (float)Math.Sin(e.spriteA.TotalRotation);

            for (int i = 0; i < totalChunks; i++)
            {
                Sprite chunk = new Sprite(12, chunkTextureIndex + LevelDataManager.rand.Next(0, 2), e.spriteA.SpriteCenterInWorld - new Vector2(8,8), true); //create a chunk matching to the veggie origin

                chunk.HitPoints = 2000; //ms timer
                chunk.IsAwake = true;
                chunk.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
                chunk.Scale = (float)LevelDataManager.rand.Next(50,151) *0.01f * e.spriteA.Scale;

                //chunk origin centered on origin of destructing sprite, add random offset so chunk can appear from anywhere inside the sprite
                Vector2 randomOffset = new Vector2(LevelDataManager.rand.Next(-chunkPlacementRangeX, chunkPlacementRangeX + 1), LevelDataManager.rand.Next(-chunkPlacementRangeY, chunkPlacementRangeY + 1));

                //add rotation offset factor to account for block rotation
                chunk.Location += new Vector2((randomOffset.X * cos) - (randomOffset.Y * sin), (randomOffset.X * sin) + (randomOffset.Y * cos));

                //setup manual physics calculation variables
                chunk.RotationSpeed = LevelDataManager.rand.Next(-800, 800);
                Vector2 velocity = ConvertUnits.ToDisplayUnits(e.spriteA.spriteBody.LinearVelocity) + new Vector2(LevelDataManager.rand.Next(-300, 301), LevelDataManager.rand.Next(-400, 201));
                chunk.Velocity = Math.Min(2000, velocity.Length());
                velocity.Normalize();
                chunk.Direction = velocity;

                EffectSprites.Add(chunk);
            }

            contactListener.DoPoof(e.spriteA);
            return;
        }
 static void contactListener_WaterSplash(object sender, EffectEventArgs e)
 {
     SoundManager.Play(SoundManager.Sound.DecoWater, false, true);
 }
        void contactListener_CreateTNTBarrel(object sender, EffectEventArgs e)
        {
            Sprite sprite = new Sprite(52, 4, e.spriteA.Location + new Vector2(16,16), false);
            sprite.SpriteType = Sprite.Type.PowerUp;
            sprite.IsCollidable = true;
            sprite.IsAwake = true;
            Vector2 position = ConvertUnits.ToSimUnits(sprite.Location + sprite.SpriteOrigin);
            sprite.spriteBody = BodyFactory.CreateRectangle(physicsWorld, ConvertUnits.ToSimUnits(24f), ConvertUnits.ToSimUnits(36f), 0.9f, position, sprite);
            sprite.spriteBody.Rotation = sprite.TotalRotation;
            sprite.spriteBody.BodyType = BodyType.Kinematic;
            sprite.spriteBody.IsSensor = true;
            sprite.spriteBody.LinearVelocity = new Vector2(-5, 0);
            sprite.HitPoints = 10000;
            EffectSprites.Add(sprite);
            contactListener.AddThisPowerBarrel(sprite);

            Sprite tower = new Sprite(12, 0, e.spriteA.Location, false);
            tower.SpriteType = Sprite.Type.Tower;
            tower.HitPoints = -500;
            EffectSprites.Add(tower);
        }
 private void Effects_CollectionChanged(object sender, EffectEventArgs e)
 {
     CalcSurvivalStats();
 }
 void contactListener_DropCreated(object sender, EffectEventArgs e)
 {
     Sprite drop = new Sprite(2, 0, e.spriteA.SpriteCenterInWorld - new Vector2(16, 16), true); //create bottom center of the sprite
     //range to create anywher inside the sprite area
     drop.Location += new Vector2(LevelDataManager.rand.Next((int)(-e.spriteA.SpriteRectWidth * 0.5f), (int)(e.spriteA.SpriteRectWidth * 0.5f)),
                                   LevelDataManager.rand.Next((int)(-e.spriteA.SpriteRectHeight * 0.5f), (int)(e.spriteA.SpriteRectHeight * 0.5f)));
     drop.HitPoints = 1000; //ms timer
     drop.IsAwake = true;
     drop.Scale = (float)LevelDataManager.rand.Next(20, 41) * 0.01f * e.spriteA.Scale;
     drop.TintColor = tint * 0.5f ;
     EffectSprites.Add(drop);
 }
 void contactListener_FruitMotionBlur(object sender, EffectEventArgs e)
 {
     Sprite blur = new Sprite(e.spriteA.TextureID, e.spriteA.TextureIndex, e.spriteA.Location, false);
     blur.SpriteType = Sprite.Type.None;
     blur.TintColor = Color.White * 0.12f;
     blur.Scale = e.spriteA.Scale;
     EffectSprites.Add(blur);
 }
 void contactListener_FanActivated(object sender, EffectEventArgs e)
 {
     //for fan wind, is bounce animated is the on off signal
     Sprite wind = (Sprite)e.spriteA.spriteBody.FixtureList[1].UserData;
     if (wind == null)
     {
         wind = new Sprite(21, 0, e.spriteA.Location, true);
         wind.TotalRotation = e.spriteA.TotalRotation;
         Vector2 windForce = new Vector2((float)Math.Cos(e.spriteA.TotalRotation + MathHelper.ToRadians(-90)), (float)Math.Sin(e.spriteA.TotalRotation + MathHelper.ToRadians(-90)));
         Vector2 windLocationCenter = new Vector2(e.spriteA.SpriteCenterInWorld.X + (windForce.X * 172), e.spriteA.SpriteCenterInWorld.Y + (windForce.Y * 172));
         wind.HitPoints = (int)e.spriteA.Velocity;
         wind.SpriteRectangle = new Rectangle((int)windLocationCenter.X - 32, (int)windLocationCenter.Y - 160, 64, 320);
         wind.SpriteType = Sprite.Type.FanWind;
         wind.IsAwake = true;
         wind.IsAnimated = true;
         wind.IsAnimatedWhileStopped = true;
         wind.IsBounceAnimated = true;
         wind.IsVisible = false;
         wind.IsCollidable = false;
         wind.AnimationFPS = 6;
         wind.TintColor = new Color(0.2f, 0.2f, 0.2f, 0.2f);
         wind.Direction = windForce;
         wind.spriteBody = e.spriteA.spriteBody;
         wind.spriteBody.FixtureList[1].UserData = wind;
         EffectSprites.Add(wind);
     }
     else
     {
         wind.TotalRotation = e.spriteA.TotalRotation;
         Vector2 windForce = new Vector2((float)Math.Cos(wind.TotalRotation + MathHelper.ToRadians(-90)), (float)Math.Sin(wind.TotalRotation + MathHelper.ToRadians(-90)));
         Vector2 windLocationCenter = new Vector2(ConvertUnits.ToDisplayUnits(wind.spriteBody.Position.X) + (windForce.X * 172),
                                                  ConvertUnits.ToDisplayUnits(wind.spriteBody.Position.Y) + (windForce.Y * 172));
         wind.SpriteRectangle = new Rectangle((int)windLocationCenter.X - 32, (int)windLocationCenter.Y - 160, 64, 320);
         wind.Direction = windForce;
         wind.IsBounceAnimated = true;
         wind.IsVisible = false;
         wind.HitPoints = (int)e.spriteA.Velocity;
     }
     return;
 }
        void contactListener_IceShotExploded(object sender, EffectEventArgs e)
        {
            Color iceblastColor = new Color(100, 100, 255);

            Sprite iceblast = new Sprite(4, 0, e.spriteA.Location, true); ;
            iceblast.TintColor = iceblastColor;
            iceblast.AnimationFPS = 12;
            iceblast.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(1, 360));
            iceblast.Scale = 1.2f * e.spriteA.Scale;
            iceblast.SpriteRectangle = new Rectangle((int)e.spriteA.SpriteCenterInWorld.X - 126, (int)e.spriteA.SpriteCenterInWorld.Y - 126, 252, 252);
            EffectSprites.Add(iceblast);

            iceblast = new Sprite(4, 0, e.spriteA.Location, true);
            iceblast.TintColor = iceblastColor;
            iceblast.AnimationFPS = 10;
            iceblast.TotalRotation = e.spriteA.TotalRotation;
            iceblast.Scale = 1.0f * e.spriteA.Scale;
            iceblast.SpriteRectangle = new Rectangle((int)e.spriteA.SpriteCenterInWorld.X - 126, (int)e.spriteA.SpriteCenterInWorld.Y - 126, 252, 252);
            iceblast.HitPoints = 30;
            Vector2 position = ConvertUnits.ToSimUnits(iceblast.SpriteCenterInWorld);
            float explosionRadius = ConvertUnits.ToSimUnits(e.spriteA.SpriteRectWidth * iceblast.Scale * 0.5f);
            iceblast.spriteBody = BodyFactory.CreateCircle(physicsWorld, explosionRadius, 1.0f, position, iceblast);
            iceblast.spriteBody.BodyType = BodyType.Dynamic;
            iceblast.spriteBody.ResetDynamics();
            iceblast.spriteBody.IsSensor = true;
            iceblast.spriteBody.IgnoreGravity = true;
            iceblast.SpriteType = Sprite.Type.IceBlast;
            EffectSprites.Add(iceblast);

            iceblast = new Sprite(4, 0, e.spriteA.Location, true);
            iceblast.TintColor = iceblastColor;
            iceblast.AnimationFPS = 12;
            iceblast.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(1, 360));
            iceblast.Scale = 0.8f * e.spriteA.Scale;
            iceblast.SpriteRectangle = new Rectangle((int)e.spriteA.SpriteCenterInWorld.X - 126, (int)e.spriteA.SpriteCenterInWorld.Y - 126, 252, 252);
            EffectSprites.Add(iceblast);
        }
        void contactListener_ImpactPoofs(object sender, EffectEventArgs e)
        {
            int smokeID = 14;
            Vector2 originOffset = new Vector2(62, 62);
            float alpha = 0.33f;

            Sprite smoke = new Sprite(smokeID, 0, e.location - originOffset, true);
            smoke.AnimationFPS = 12;
            smoke.Scale = 1.0f;
            smoke.TintColor *= alpha;
            smoke.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
            smoke.Velocity = -300;
            smoke.Direction = Vector2.UnitX;
            EffectSprites.Add(smoke);
            smoke = new Sprite(smokeID, 0, e.location - originOffset, true);
            smoke.AnimationFPS = 12;
            smoke.Scale = 1.0f;
            smoke.TintColor *= alpha;
            smoke.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
            smoke.Velocity = -200;
            smoke.Direction = Vector2.UnitX;
            EffectSprites.Add(smoke);
            smoke = new Sprite(smokeID, 0, e.location - originOffset, true);
            smoke.AnimationFPS = 12;
            smoke.Scale = 1.0f;
            smoke.TintColor *= alpha;
            smoke.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
            smoke.Velocity = -100;
            smoke.Direction = Vector2.UnitX;
            EffectSprites.Add(smoke);
            smoke = new Sprite(smokeID, 0, e.location - originOffset, true);
            smoke.AnimationFPS = 12;
            smoke.Scale = 1.0f;
            smoke.TintColor *= alpha;
            smoke.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
            smoke.Velocity = 100;
            smoke.Direction = Vector2.UnitX;
            EffectSprites.Add(smoke);
            smoke = new Sprite(smokeID, 0, e.location - originOffset, true);
            smoke.AnimationFPS = 12;
            smoke.Scale = 1.0f;
            smoke.TintColor *= alpha;
            smoke.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
            smoke.Velocity = 200;
            smoke.Direction = Vector2.UnitX;
            EffectSprites.Add(smoke);
            smoke = new Sprite(smokeID, 0, e.location - originOffset, true);
            smoke.AnimationFPS = 12;
            smoke.Scale = 1.0f;
            smoke.TintColor *= alpha;
            smoke.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
            smoke.Velocity = 300;
            smoke.Direction = Vector2.UnitX;
            EffectSprites.Add(smoke);
        }
 void contactListener_LemonActivated(object sender, EffectEventArgs e)
 {
     Sprite acid = new Sprite(13, 0, e.spriteA.Location + e.spriteA.SpriteOrigin - new Vector2(126, 126), true);
     acid.SpriteType = Sprite.Type.Acid;
     acid.AnimationFPS = 10;
     acid.Scale = 1.8f*e.spriteA.Scale;
     acid.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
     acid.TintColor = new Color(30, 30, 0, 10);
     acid.IsCollidable = true;
     acid.spriteBody = BodyFactory.CreateCircle(physicsWorld, ConvertUnits.ToSimUnits(acid.SpriteRectangle.Width * 0.66f * e.spriteA.Scale), 1.0f, ConvertUnits.ToSimUnits(acid.SpriteCenterInWorld), acid);
     acid.spriteBody.BodyType = BodyType.Dynamic;
     acid.spriteBody.IsSensor = true;
     acid.spriteBody.IgnoreGravity = true;
     EffectSprites.Add(acid);
     Sprite smoke = new Sprite(13, 0, e.spriteA.Location + e.spriteA.SpriteOrigin - new Vector2(126, 126) - new Vector2(-32, 0), true);
     smoke.SpriteType = Sprite.Type.Acid;
     smoke.AnimationFPS = LevelDataManager.rand.Next(8, 13);
     smoke.Scale = 1.4f * e.spriteA.Scale;
     smoke.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
     smoke.TintColor = new Color(30, 30, 0, 10);
     EffectSprites.Add(smoke);
     smoke = new Sprite(13, 0, e.spriteA.Location + e.spriteA.SpriteOrigin - new Vector2(126, 126) - new Vector2(32, 0), true);
     smoke.SpriteType = Sprite.Type.Acid;
     smoke.AnimationFPS = LevelDataManager.rand.Next(8, 13);
     smoke.Scale = 1.4f * e.spriteA.Scale;
     smoke.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
     smoke.TintColor = new Color(30, 30, 0, 10);
     EffectSprites.Add(smoke);
     smoke = new Sprite(13, 0, e.spriteA.Location + e.spriteA.SpriteOrigin - new Vector2(126, 126) - new Vector2(0, 32), true);
     smoke.SpriteType = Sprite.Type.Acid;
     smoke.AnimationFPS = LevelDataManager.rand.Next(8, 13);
     smoke.Scale = 1.4f * e.spriteA.Scale;
     smoke.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
     smoke.TintColor = new Color(30, 30, 0, 10);
     EffectSprites.Add(smoke);
     smoke = new Sprite(13, 0, e.spriteA.Location + e.spriteA.SpriteOrigin - new Vector2(126, 126) - new Vector2(0, -32), true);
     smoke.SpriteType = Sprite.Type.Acid;
     smoke.AnimationFPS = LevelDataManager.rand.Next(8, 13);
     smoke.Scale = 1.4f * e.spriteA.Scale;
     smoke.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
     smoke.TintColor = new Color(30, 30, 0, 10);
     EffectSprites.Add(smoke);
     smoke = new Sprite(13, 0, e.spriteA.Location + e.spriteA.SpriteOrigin - new Vector2(126, 126) - new Vector2(32, 32), true);
     smoke.SpriteType = Sprite.Type.Acid;
     smoke.AnimationFPS = LevelDataManager.rand.Next(8, 13);
     smoke.Scale = 1.0f * e.spriteA.Scale;
     smoke.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
     smoke.TintColor = new Color(30, 30, 0, 10);
     EffectSprites.Add(smoke);
     smoke = new Sprite(13, 0, e.spriteA.Location + e.spriteA.SpriteOrigin - new Vector2(126, 126) - new Vector2(32, -32), true);
     smoke.SpriteType = Sprite.Type.Acid;
     smoke.AnimationFPS = LevelDataManager.rand.Next(8, 13);
     smoke.Scale = 1.0f * e.spriteA.Scale;
     smoke.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
     smoke.TintColor = new Color(30, 30, 0, 10);
     EffectSprites.Add(smoke);
     smoke = new Sprite(13, 0, e.spriteA.Location + e.spriteA.SpriteOrigin - new Vector2(126, 126) - new Vector2(-32, 32), true);
     smoke.SpriteType = Sprite.Type.Acid;
     smoke.AnimationFPS = LevelDataManager.rand.Next(8, 13);
     smoke.Scale = 1.0f * e.spriteA.Scale;
     smoke.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
     smoke.TintColor = new Color(30, 30, 0, 10);
     EffectSprites.Add(smoke);
     smoke = new Sprite(13, 0, e.spriteA.Location + e.spriteA.SpriteOrigin - new Vector2(126, 126) - new Vector2(-32, -32), true);
     smoke.SpriteType = Sprite.Type.Acid;
     smoke.AnimationFPS = LevelDataManager.rand.Next(8, 13);
     smoke.Scale = 1.0f * e.spriteA.Scale;
     smoke.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(0, 360));
     smoke.TintColor = new Color(30, 30, 0, 10);
     EffectSprites.Add(smoke);
     return;
 }
示例#43
0
        private void DoRemoved(IPersonEffect effect)
        {
            var args = new EffectEventArgs(effect);

            Removed?.Invoke(this, args);
        }
        void contactListener_LitShotExploded(object sender, EffectEventArgs e)
        {
            Sprite litblast = new Sprite(8, 0, e.spriteA.Location, true); ;
            litblast.AnimationFPS = 12;
            litblast.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(1, 360));
            litblast.Scale = 1.2f * e.spriteA.Scale;
            litblast.SpriteRectangle = new Rectangle((int)e.spriteA.SpriteCenterInWorld.X - 254, (int)e.spriteA.SpriteCenterInWorld.Y - 254, 508, 508);
            EffectSprites.Add(litblast);

            litblast = new Sprite(8, 0, e.spriteA.Location, true); ;
            litblast.AnimationFPS = 11;
            litblast.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(1, 360));
            litblast.Scale = 1.1f * e.spriteA.Scale;
            litblast.SpriteRectangle = new Rectangle((int)e.spriteA.SpriteCenterInWorld.X - 254, (int)e.spriteA.SpriteCenterInWorld.Y - 254, 508, 508);
            EffectSprites.Add(litblast);

            litblast = new Sprite(8, 0, e.spriteA.Location, true);
            litblast.AnimationFPS = 10;
            litblast.TotalRotation = e.spriteA.TotalRotation;
            litblast.Scale = 1.0f * e.spriteA.Scale;
            litblast.SpriteRectangle = new Rectangle((int)e.spriteA.SpriteCenterInWorld.X - 254, (int)e.spriteA.SpriteCenterInWorld.Y - 254, 508, 508);
            litblast.HitPoints = 30;
            Vector2 position = ConvertUnits.ToSimUnits(litblast.SpriteCenterInWorld);
            float explosionRadius = ConvertUnits.ToSimUnits(litblast.SpriteRectWidth * litblast.Scale * 0.4f);
            litblast.spriteBody = BodyFactory.CreateCircle(physicsWorld, explosionRadius, 1.0f, position, litblast);
            litblast.spriteBody.BodyType = BodyType.Dynamic;
            litblast.spriteBody.ResetDynamics();
            litblast.spriteBody.IsSensor = true;
            litblast.spriteBody.IgnoreGravity = true;
            litblast.SpriteType = Sprite.Type.LightningBlast;
            EffectSprites.Add(litblast);

            litblast = new Sprite(8, 0, e.spriteA.Location, true); ;
            litblast.AnimationFPS = 11;
            litblast.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(1, 360));
            litblast.Scale = 0.9f * e.spriteA.Scale;
            litblast.SpriteRectangle = new Rectangle((int)e.spriteA.SpriteCenterInWorld.X - 254, (int)e.spriteA.SpriteCenterInWorld.Y - 254, 508, 508);
            EffectSprites.Add(litblast);

            litblast = new Sprite(8, 0, e.spriteA.Location, true);
            litblast.AnimationFPS = 12;
            litblast.TotalRotation = MathHelper.ToRadians(LevelDataManager.rand.Next(1, 360));
            litblast.Scale = 0.8f * e.spriteA.Scale;
            litblast.SpriteRectangle = new Rectangle((int)e.spriteA.SpriteCenterInWorld.X - 254, (int)e.spriteA.SpriteCenterInWorld.Y - 254, 508, 508);
            EffectSprites.Add(litblast);
        }
 void contactListener_BeeDeflection(object sender, EffectEventArgs e)
 {
     e.spriteB.spriteBody.LinearVelocity = new Vector2(e.spriteB.spriteBody.LinearVelocity.X + ConvertUnits.ToSimUnits(LevelDataManager.rand.Next(-200, 201)),
                                                         e.spriteB.spriteBody.LinearVelocity.Y + ConvertUnits.ToSimUnits(LevelDataManager.rand.Next(-200, 201)));
     e.spriteB.spriteBody.AngularVelocity += ((float)LevelDataManager.rand.Next(-200, 200) / 100.0f);
     return;
 }
 void contactListener_NewSpiderThread(object sender, EffectEventArgs e)
 {
     Sprite thread = new Sprite(20,0,e.spriteA.pathingPoints[0],true);
     thread.SpriteRectangle = new Rectangle((int)e.spriteA.pathingPoints[0].X + 32, (int)e.spriteA.pathingPoints[0].Y+6, 1, (int)(e.spriteA.Location.Y - e.spriteA.pathingPoints[0].Y));
     thread.TintColor *= 0.3f;
     EffectSprites.Add(thread);
     return;
 }
 void contactListener_WindDeflection(object sender, EffectEventArgs e)
 {
     if (e.spriteA.IsBounceAnimated)
     {
         Vector2 distanceVector = e.spriteA.spriteBody.Position - e.spriteB.spriteBody.Position;
         float windPowerFactor = 0.4f / distanceVector.LengthSquared();
         e.spriteB.spriteBody.LinearVelocity += e.spriteA.Direction * LevelDataManager.rand.Next(1, 11) * windPowerFactor;
         e.spriteB.spriteBody.AngularVelocity += ((float)LevelDataManager.rand.Next(-100, 100) *0.001f);
     }
     return;
 }
示例#48
0
 public virtual void WheneverCardEffect(object sender, EffectEventArgs e)
 {
 }