コード例 #1
0
        public BulletInstancer()
        {
            self        = this;
            BulletModel = AssetManager.Load <Model>("Models/ShipGame/World/Spark");
            ShipEffect  = AssetManager.Load <Effect>("Effects/WhiteEffect");

            WorldParam                = ShipEffect.Parameters["World"];
            ViewParam                 = ShipEffect.Parameters["View"];
            ProjectionParam           = ShipEffect.Parameters["Projection"];
            ForwardInstancedTechnique = ShipEffect.Techniques["ForwardInstancedTechnique"];
        }
コード例 #2
0
        public override void Create()
        {
            if (ShouldDodge)
            {
                DodgeBullets.AddLast(this);
            }

            AddTag(GameObjectTag.Update);
            if (!Commited && !NoInstanceCommit)
            {
                Commited = true;
                BulletInstancer.AddChild(this);
            }
            base.Create();
        }
コード例 #3
0
        public override void Destroy()
        {
            if (ShouldDodge && DodgeBullets.Contains(this))
            {
                DodgeBullets.Remove(this);
            }

            if (Commited && !NoInstanceCommit)
            {
                Commited = false;
                BulletInstancer.RemoveChild(this);
            }

            Destroyed = true;
            if (Armed && BulletExplosionDamage > 0 && BulletExplosionDistance > 0)
            {
                QuadGrid grid = Parent2DScene.quadGrids.First.Value;

                foreach (Basic2DObject o in grid.Enumerate(Position.get(), new Vector2(BulletExplosionDistance)))
                {
                    if (o.GetType().IsSubclassOf(typeof(BasicShipGameObject)))
                    {
                        BasicShipGameObject s = (BasicShipGameObject)o;
                        float dist            = Vector2.Distance(s.Position.get(), Position.get()) - o.Size.X() / 2;

                        if (dist < BulletExplosionDistance && !ParentUnit.IsAlly(s))
                        {
                            float DistMult = 1;
                            if (dist > 0)
                            {
                                DistMult = (BulletExplosionDistance - dist) / BulletExplosionDistance;
                            }
                            s.Damage(DistMult * BulletExplosionDamage, DistMult * PushTime, Vector2.Normalize(s.Position.get() - Position.get()) * PushVelocityMult * DistMult, ParentUnit, attackType);
                        }
                    }
                }
            }

            SoundManager.Play3DSound(ImpactString, new Vector3(Position.X(), Y, Position.Y()),
                                     ImpactVolume, ImpactDistance, ImpactExponent);

            base.Destroy();
        }
コード例 #4
0
 static InstanceManager()
 {
     bulletInstancer = new BulletInstancer();
     shieldInstancer = new ShieldInstancer();
 }