Example #1
0
        public override void behaviorOnCollisionWithPlayer
            (GameLocation location, Farmer player)
        {
            int oldHealth = player.health;

            player.takeDamage(damageToFarmer.Value, overrideParry: false,
                              new FakeDamager());

            // If parried, maybe give the catch.
            if (player.health == oldHealth)
            {
                if (parryCatchIndex.Value == -1 && spriteFromObjectSheet.Value)
                {
                    parryCatchIndex.Value = currentTileSheetIndex.Value;
                }

                if (Game1.random.NextDouble() < parryCatchChance.Value &&
                    parryCatchIndex.Value != -1)
                {
                    DelayedAction.playSoundAfterDelay("dwoop", 100, location);
                    player.addItemByMenuIfNecessary
                        (new SObject(parryCatchIndex.Value, 1));
                }
            }
            // Otherwise, notify the firer and explode.
            else
            {
                Cropbeast beast = theOneWhoFiredMe.Get(location) as Cropbeast;
                beast?.onDealProjectileDamage(player, oldHealth - player.health);

                explode(location);
            }
        }
Example #2
0
        public override void behaviorOnCollisionWithOther(GameLocation location)
        {
            Cropbeast beast = theOneWhoFiredMe.Get(location) as Cropbeast;

            beast?.onProjectileSpoiled();
            explode(location);
        }
Example #3
0
        public override void behaviorOnCollisionWithTerrainFeature
            (TerrainFeature _t, Vector2 _tileLocation, GameLocation location)
        {
            Cropbeast beast = theOneWhoFiredMe.Get(location) as Cropbeast;

            beast?.onProjectileSpoiled();
            explode(location);
        }
Example #4
0
        public virtual void fire(Cropbeast firer, GameLocation location,
                                 Vector2 startingPosition, Vector2 velocity,
                                 float rotationVelocity = 0f)
        {
            theOneWhoFiredMe.Set(location, firer);
            position.Value              = startingPosition;
            this.xVelocity.Value        = velocity.X;
            this.yVelocity.Value        = velocity.Y;
            this.rotationVelocity.Value = rotationVelocity;

            if ((firingSound.Value ?? "") != "")
            {
                location.playSound(firingSound.Value);
            }

            location.projectiles.Add(this);
        }