public override void Interact(PlayerShip p)
        {
            if (miningPlatform == null && FactionManager.CanBuildMiningPlatform(p.FactionNumber))
            {
                Vector3 P3 = new Vector3(Position.X(), 0, Position.Y());
                for (int i = 0; i < 40; i++)
                {
                    LineParticleSystem.AddParticle(P3, P3 + Rand.V3() * 1000, TeamInfo.GetColor(p.GetTeam()));
                }

                MiningPlatform m = FactionManager.GetMiningPlatform(p.FactionNumber);
                ParentLevel.AddObject(m);
                m.Position.set(Position.get());
                setPlatform(m);

                SoundManager.Play3DSound("PlayerBuildMiningRing",
                                         new Vector3(m.Position.X(), Y, m.Position.Y()), 0.25f, 500, 1);

                if (p.PlacedStartingMineralRock)
                {
                    FactionManager.AddCells(p.FactionNumber, -FactionManager.GetMiningPlatformCost(p.FactionNumber));
                    FactionManager.SetBuildingPlatform(p.FactionNumber, m);
                }
                else
                {
                    FactionManager.GetFaction(p.FactionNumber).MiningPlatformCounter = 0;
                    m.HullToughness *= 2;
                    m.SetAsStarting();
                    p.PlacedStartingMineralRock = true;
                    p.StartingMineralRock       = this;
                }

                p.LastPlacedPlatform.AddFirst(m);
                PathFindingManager.AddMineralRock(m);
            }
            base.Interact(p);
        }
        public override void BlowUp()
        {
            if (Dead || Lives < 1)
            {
                return;
            }

            Vector3 P3 = new Vector3(Position.X(), 0, Position.Y());

            for (int i = 0; i < 10; i++)
            {
                LineParticleSystem.AddParticle(P3, P3 + Rand.V3() * MaxEngagementDistance, TeamInfo.GetColor(GetTeam()));
            }

            foreach (Faction f in FactionManager.Factions)
            {
                if (MyCard == null)
                {
                    MyCard = (TurretCard)FactionCard.FactionTurretDeck[0];
                }

                if (f.Team != GetTeam())
                {
                    f.roundReport.TurretsKilled++;
                    f.AddEvent(MyCard.Name + " Destroyed", new Color(1, 0.5f, 0.5f), FactionEvent.KillTexture);
                }
                else
                {
                    f.roundReport.TurretsLost++;
                    f.AddEvent(MyCard.Name + " Lost", new Color(1, 0.5f, 0.5f), FactionEvent.LossTexture);
                }
            }

            if (ShouldDeathSound)
            {
                SoundManager.Play3DSound(DeathSound, new Vector3(Position.X(), Y, Position.Y()), DeathVolume, 1000, 1);
                ShouldDeathSound = false;
            }


            FreezeMult = 0;
            VirusTime  = 0;
            DeathParticles();
            Lives--;

            Dead = true;
            if (MyBustedTurret == null)
            {
                MyBustedTurret = new BustedTurret(this);
                ParentLevel.AddObject(MyBustedTurret);
                MyBustedTurret.SetPosition(getPosition());
            }

            MyBustedTurret.WorldMatrix = WorldMatrix;
            MyBustedTurret.Activate();
            InstanceManager.RemoveChild(this);
            RemoveTag(GameObjectTag._2DSolid);
            RemoveTag(GameObjectTag._2DForward);

            LinkedList <GameObject> GList = Parent2DScene.GetList(GameObjectTag._2DSolid);

            if (GList.Contains(this))
            {
                GList.Remove(this);
            }

            BuildTimer = 0;

            float    BulletExplosionDistance = 200;
            float    BulletExplosionDamage   = 1f;
            QuadGrid grid = Parent2DScene.quadGrids.First.Value;


            for (int i = 0; i < 2; i++)
            {
                bool ActivateDeathSound = true;

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

                        if (dist < BulletExplosionDistance && GetTeam() != s.GetTeam() && s.CanBeTargeted())
                        {
                            float DistMult = 1;
                            if (dist > 0)
                            {
                                DistMult = (BulletExplosionDistance - dist) / BulletExplosionDistance;
                            }

                            if (s.GetType().IsSubclassOf(typeof(UnitShip)))
                            {
                                UnitShip ship = (UnitShip)s;
                                ship.CanDeathSound = ActivateDeathSound;
                            }
                            s.Damage(DistMult * BulletExplosionDamage, DistMult, Vector2.Normalize(s.Position.get() - Position.get()), this, AttackType.Explosion);

                            if (s.Dead)
                            {
                                ActivateDeathSound = false;
                            }
                            else if (s.GetType().IsSubclassOf(typeof(UnitShip)))
                            {
                                UnitShip ship = (UnitShip)s;
                                ship.CanDeathSound = true;
                            }
                        }
                    }
                }
            }

            if (ShieldAlpha > 0)
            {
                ShieldInstancer.Remove(this);
                ShieldAlpha = -1;
            }
        }
        public override void Draw2D(GameObjectTag DrawTag)
        {
#if EDITOR && WINDOWS
            if (ParentLevel.LevelForEditing)
            {
                Render.DrawSprite(PlaceholderRockTexture, Position, Size, Rotation);
            }
            else
#endif

            if (miningPlatform == null)
            {
                Vector3 Position3 = Game1.graphicsDevice.Viewport.Project(
                    new Vector3(this.Position.X(), Y, this.Position.Y()), StarshipScene.CurrentCamera.ProjectionMatrix,
                    StarshipScene.CurrentCamera.ViewMatrix, Matrix.Identity);

                Vector3 Size3 = Game1.graphicsDevice.Viewport.Project(
                    new Vector3(this.Position.X() + this.Size.X(), Y, this.Position.Y()), StarshipScene.CurrentCamera.ProjectionMatrix,
                    StarshipScene.CurrentCamera.ViewMatrix, Matrix.Identity);

                Vector2 Position = new Vector2(Position3.X, Position3.Y) - Render.CurrentView.Position;
                float   Size     = Vector2.Distance(Position, new Vector2(Size3.X, Size3.Y) - Render.CurrentView.Position) / 1.6f;
                Position.Y -= Size;

                Render.DrawSprite(MiningPlatform.MRockPointer, Position, new Vector2(Size), 0, TeamInfo.GetColor(GetTeam()));
                base.Draw2D(DrawTag);
            }
        }
Ejemplo n.º 4
0
        public override void Draw2D(GameObjectTag DrawTag)
        {
            if (SizeBonus == 0)
            {
                return;
            }

            Render.DrawSolidRect(InterpolatedPositionL, InterpolatedPositionR, new Color(0, 0, 0, 0.5f));

            int i;

            for (i = 0; i < CurrentCards.Count; i++)
            {
                CurrentCards[i].Draw(InterpolatedPositionL + new Vector2(InterpolatedDifference.X * ((0.1f + (float)i) / CurrentCards.Count), InterpolatedDifference.Y * 0.1f),
                                     InterpolatedPositionL + new Vector2(InterpolatedDifference.X * ((0.9f + (float)i) / CurrentCards.Count), InterpolatedDifference.Y * 0.9f), i == SelectedSlot ? 1 : OtherAlpha);
            }


            if (SinglePlayer || WaveManager.CurrentWave < PickEnemyState.RandomRounds + 1)
            {
                Render.DrawSprite(WaveCard.UnitPicker, InterpolatedPositionL + new Vector2((SingleSelectedNode + 0.5f) * InterpolatedDifference.X / CurrentCards.Count, InterpolatedDifference.Y + i * 15),
                                  new Vector2(InterpolatedDifference.X / CurrentCards.Count * 1.5f, 90), 0, new Color(1, 0.5f, 0.5f));
            }
            else
            {
                i = 0;
                foreach (int key in TeamFloatingSelection.Keys)
                {
                    Render.DrawSprite(WaveCard.UnitPicker, InterpolatedPositionL + new Vector2((TeamFloatingSelection[key] + 0.5f) * InterpolatedDifference.X / CurrentCards.Count, InterpolatedDifference.Y + i * 15)
                                      , new Vector2(InterpolatedDifference.X / CurrentCards.Count * 1.5f, 90), 0, TeamInfo.GetColor(key));
                }
            }

            base.Draw2D(DrawTag);
        }
        protected override void DrawHealthBar(float HealthMult, Vector2 Position, float Size)
        {
            Vector2 Offset = new Vector2(Size, 2.5f);

            Render.DrawSolidRect(Position - Offset, Position + Offset, HealthBackgroundColor);
            Render.DrawSolidRect(Position - Offset + Vector2.One, Position - Offset + new Vector2((Size * 2 - 2) * HealthMult, 4), TeamInfo.GetColor(GetTeam()));
        }
        protected override void DrawHealthBar(float HealthMult, Vector2 Position, float Size)
        {
            if (WaveManager.ActiveTeam != GetTeam())
            {
                return;
            }

            if (StarshipScene.DrawingShip == null || StarshipScene.DrawingShip.GetTeam() != GetTeam())
            {
                base.DrawHealthBar(HealthMult, Position, Size);
            }
            else
            {
                Position.Y -= Size;
                float SizeMult2 = (1f + SizeMult) * (1.75f - HealthMult);
                if (Vector2.Distance(Render.CurrentView.Size / 2, Position) > Render.CurrentView.Size.Y * 0.4f)
                {
                    Vector2 NewPosition = Vector2.Normalize(Position - Render.CurrentView.Size / 2) * (Render.CurrentView.Size.Y * 0.4f) + Render.CurrentView.Size / 2;
                    Render.DrawSprite(MRockPointer, NewPosition, new Vector2(Size) * SizeMult2, DrawRotation, TeamInfo.GetColor(GetTeam()));
                    base.DrawHealthBar(HealthMult, NewPosition, Size);
                    TargetDrawRotation = -Logic.ToAngle((Position - NewPosition));
                }
                else
                {
                    TargetDrawRotation = 0;
                    Render.DrawSprite(MRockPointer, Position, new Vector2(Size) * SizeMult2, DrawRotation, TeamInfo.GetColor(GetTeam()));
                    base.DrawHealthBar(HealthMult, Position, Size);
                }
            }
        }
        public override void DrawFromMiniMap(Vector2 Position, float Size, Vector2 Min, Vector2 Max)
        {
            if (this.Position.X() > Max.X || this.Position.Y() > Max.Y || this.Position.X() < Min.X || this.Position.Y() < Min.Y)
            {
                return;
            }

            Vector2 MapPosition = (this.Position.get() - Min) /
                                  (Max - Min) * Size + Position;

            if (SizeMult > 0)
            {
                Render.DrawOutlineRect(MapPosition - new Vector2(SizeMult * 4) - new Vector2(3), MapPosition + new Vector2(SizeMult * 4) - new Vector2(3), 2, TeamInfo.GetColor(GetTeam()));
            }
            Render.DrawSprite(Render.BlankTexture, MapPosition - new Vector2(2), new Vector2(4), 0, TeamInfo.GetColor(GetTeam()));
        }
        public virtual void DrawFromMiniMap(Vector2 Position, float Size, Vector2 Min, Vector2 Max)
        {
            if (this.Position.X() > Max.X || this.Position.Y() > Max.Y || this.Position.X() < Min.X || this.Position.Y() < Min.Y)
            {
                return;
            }

            Vector2 MapPosition = (this.Position.get() - Min) /
                                  (Max - Min) * Size + Position;

            Render.DrawSprite(Render.BlankTexture, MapPosition - new Vector2(1), new Vector2(2), 0, TeamInfo.GetColor(GetTeam()));
        }