コード例 #1
0
        public static int ComputeBeamProjectileDamage(Projectile projectile)
        {
            var config = DestructibleTilesConfig.Instance;
            int damage = DestructibleTilesProjectile.ComputeProjectileDamage(projectile);

            return((int)((float)damage * config.BeamDamageScale));
        }
        ////////////////

        public void BehaviorAsKinetic(Projectile projectile, Vector2 oldVelocity)
        {
            var config = DestructibleTilesConfig.Instance;

            var rect = new Rectangle(
                (int)projectile.position.X + (int)oldVelocity.X,
                (int)projectile.position.Y + (int)oldVelocity.Y,
                projectile.width,
                projectile.height
                );

            bool onlySometimesRespects;
            bool respectsPlatforms = ProjectileAttributeHelpers.DoesVanillaProjectileHitPlatforms(
                projectile,
                out onlySometimesRespects
                ) && !onlySometimesRespects;

            int damage = DestructibleTilesProjectile.ComputeProjectileDamage(projectile);

            IList <(ushort, ushort)> hits = DestructibleTilesProjectile.FindNearbyHittableTiles(
                projectile.Center,
                rect,
                respectsPlatforms
                );

            if (config.DebugModeInfo)
            {
                this.OutputKineticProjectileDebugInfo(projectile, oldVelocity, hits);
            }

            foreach ((ushort x, ushort y) in hits)
            {
                DestructibleTilesProjectile.HitTile(damage, x, y, hits.Count);
            }
        }
コード例 #3
0
        public void BehaviorAsAoE(Projectile projectile)
        {
            var config  = DestructibleTilesConfig.Instance;
            var projDef = new ProjectileDefinition(projectile.type);

            ProjectileStateDefinition projExploDef = config.ProjectilesAsAoE[projDef];

            if (!projExploDef.IsProjectileMatch(projectile))
            {
                return;
            }

            int tileX  = (int)projectile.position.X >> 4;
            int tileY  = (int)projectile.position.Y >> 4;
            int damage = DestructibleTilesProjectile.ComputeProjectileDamage(projectile);

            if (config.DebugModeInfo)
            {
                Main.NewText("RADIUS - " + projDef.ToString() + ", radius:" + projExploDef.Amount + ", damage:" + damage);
            }

            DestructibleTilesProjectile.HitTilesInRadius(tileX, tileY, projExploDef.Amount, damage);
        }