public override void Interact(PlayerShip p)
        {
            IsUpdgraded = true;
            FactionManager.AddCells(p.FactionNumber, -UpgradeCost);

            HullDamage   = 0;
            ShieldDamage = 0;

            Upgrade();

            base.Interact(p);
        }
        public override void Damage(float damage, float pushTime, Vector2 pushSpeed, BasicShipGameObject Damager, AttackType attackType)
        {
            if ((InvTime < 1 && (FieldStateTime < 1 || fieldState != FieldState.Cloaked)) || attackType == AttackType.Explosion || attackType == AttackType.Melee)
            {
                if (CanCloak)
                {
                    SoundManager.Play3DSound("UnitCloak", new Vector3(Position.X(), Y, Position.Y()), 0.25f, 800, 2);

                    fieldState     = FieldState.Cloaked;
                    HasCloaked     = true;
                    CanCloak       = false;
                    FieldStateTime = GetCloakTime();
                }
                else
                {
                    if (attackType != AttackType.White)
                    {
                        SummonUnits();
                    }

                    NoShootTime = MaxNoShootTime;
                    if (attackType == AttackType.White)
                    {
                        ThreatLevel *= 1.5f;
                    }

                    if (!PathFindingManager.CollisionLine(Position.get(), Damager.Position.get()))
                    {
                        AngerTime           = MaxAngerTime;
                        CurrentAttackTarget = Damager;
                    }

                    base.Damage(damage, pushTime, pushSpeed, Damager, attackType);

                    if (HullDamage >= HullToughness && Damager.FactionNumber != NeutralManager.NeutralFaction && ScoreToGive > 0)
                    {
                        if (CanDeathSound)
                        {
                            SoundManager.Play3DSound(DeathSound, new Vector3(Position.X(), Y, Position.Y()), DeathVolume * 0.5f, DeathDistance, DeathExponenent * 2);
                        }

                        ScoreToGive = (int)(ScoreToGive * (0.75f + 0.25f * UnitLevel) * (IsHuge ? 1.25f : 1) *
                                            (HasCloaked || CanCloak ? 1.5f : 1) * (CanSummon || HasSummoned ? 4 : 1));
                        TextParticleSystem.AddParticle(new Vector3(Position.X(), Y, Position.Y()), ScoreToGive.ToString(), (byte)Damager.GetTeam());
                        FactionManager.AddScore(Damager.FactionNumber, ScoreToGive);
                        FactionManager.Factions[Damager.FactionNumber].roundReport.UnitKills++;
                        ScoreToGive = 0;
                    }
                }
            }
        }
示例#3
0
        private void Activate()
        {
            if (!WaveStepState.WeaponsFree)
            {
                return;
            }

            FactionManager.AddEnergy(ParentShip.FactionNumber, -150);

            Vector3 Position3 = new Vector3(ParentShip.Position.X(), 0, ParentShip.Position.Y());
            float   Theta     = 0;
            float   Offset    = ParentShip.Size.X() * 2;

            FactionManager.Factions[ParentShip.FactionNumber].roundReport.UnitsSpawned += MyCard.GhostCount;

            for (int i = 0; i < MyCard.GhostCount; i++)
            {
                UnitShip u = (UnitShip)MyCard.GetUnit(ParentShip.FactionNumber);
                ParentShip.ParentLevel.AddObject(u);

                while (!ParentShip.TestFree(ParentShip.Position.get(), Theta, Offset, ParentShip.Size.X()))
                {
                    Theta += (float)Math.PI / 10f;
                    if (Theta > Math.PI * 2)
                    {
                        Theta  -= (float)Math.PI * 2;
                        Offset += ParentShip.Size.X();
                    }
                }
                Vector2 BestPosition = Logic.ToVector2(Theta) * Offset + ParentShip.Position.get();

                u.SetForGhost();
                u.Position.set(BestPosition);
                u.SetLevel(WaveManager.CurrentWave / 5f * WaveCard.LevelMult, 1);

                Position3 = new Vector3(BestPosition.X, 0, BestPosition.Y);
                for (int j = 0; j < 30; j++)
                {
                    ParticleManager.CreateParticle(Position3, Rand.V3() * 200, new Color(1, 0.75f, 0.5f), 20, 5);
                }
            }


            ParticleManager.CreateParticle(Position3, Vector3.Zero, new Color(1, 0.75f, 0.5f), ParentShip.Size.X() * 5, 4);
            for (int i = 0; i < 30; i++)
            {
                ParticleManager.CreateParticle(Position3, Rand.V3() * 200, new Color(1, 0.75f, 0.5f), 20, 5);
            }
        }
        public override void Update(GameTime gameTime)
        {
            if (ParentFrame != null)
            {
                DistanceAlpha = (300 - Math.Abs(this.Position.Y() - ParentFrame.CameraPosition.Y)) / 300f *
                                (600 - Math.Abs(this.Position.X() - ParentFrame.CameraPosition.X)) / 600f;
            }

            if (Selected && FactionManager.GetFaction(ParentShip.FactionNumber).PickingCards)
            {
                SelectedAlpha += gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * AlphaChange;
                if (SelectedAlpha > 1)
                {
                    SelectedAlpha = 1;
                }
            }
            else
            {
                SelectedAlpha -= gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * AlphaChange;
                if (SelectedAlpha < 0)
                {
                    SelectedAlpha = 0;
                }
            }
            FlashAlpha -= gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * AlphaChange;
            ErrorAlpha -= gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * AlphaChange;

            if (Alpha > 0 && !FactionManager.GetFaction(ParentShip.FactionNumber).PickingCards&& MarkerCount > 0)
            {
                if (!ParentShip.CanPlaceTurret(MyCard.TurretSize))
                {
                    RingAlpha -= gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * AlphaChange;
                    if (RingAlpha < 0)
                    {
                        RingAlpha = 0;
                    }
                }
                else
                {
                    RingAlpha += gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * AlphaChange;
                    if (RingAlpha > 1)
                    {
                        RingAlpha = 1;
                    }
                }
            }

            base.Update(gameTime);
        }
        public override void Destroy()
        {
            DeathParticles();

            if (InstancerCommit())
            {
                InstanceManager.RemoveChild(this);
                ShieldInstancer.Remove(this);
            }
            if (UnitAdded)
            {
                FactionManager.RemoveUnit(this);
                UnitAdded = false;
            }

            base.Destroy();
        }
        public override void Update(GameTime gameTime)
        {
            MoveSpeed = 1f;

            if (Counter > FactionManager.GetFaction(ParentBox.ParentShip.FactionNumber).MiningPlatformCounter / 2)
            {
                GlowAlpha -= gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * GlowAlphaChange;
                FullAlpha -= gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * AlphaChange;
                if (FullAlpha < 0)
                {
                    FullAlpha = 0;
                }
                if (GlowAlpha < 0)
                {
                    GlowAlpha = 0;
                }
            }
            else
            {
                if (GlowAlpha == 0)
                {
                    ExtraGlowAlpha = 2;
                }

                GlowAlpha += gameTime.ElapsedGameTime.Milliseconds * 60 / 10000f * GlowAlphaChange;
                FullAlpha += gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * AlphaChange;
                if (FullAlpha > 1)
                {
                    FullAlpha = 1;
                }

                float MaxGlowAlpha = FactionManager.CanBuildMiningPlatform(ParentBox.ParentShip.FactionNumber) ? 2 : 1;
                if (GlowAlpha > MaxGlowAlpha)
                {
                    GlowAlpha = MaxGlowAlpha;
                }
            }

            ExtraGlowAlpha -= gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * AlphaChange;
            if (ExtraGlowAlpha < 0)
            {
                ExtraGlowAlpha = 0;
            }

            base.Update(gameTime);
        }
        public override void Update2(GameTime gameTime)
        {
            if (Alpha > 0 && !FactionManager.GetFaction(ParentShip.FactionNumber).PickingCards&& MarkerCount > 0)
            {
                Vector2 PlacePosition = ParentShip.GetPlacePosition(MyCard.TurretSize / 2);
                ParticleManager.CreateParticle(new Vector3(PlacePosition.X, 0, PlacePosition.Y), Vector3.Zero, MyColor * Alpha * RingAlpha * 0.25f, MyCard.TurretSize * (10 + Rand.r.Next(5)), 1);
                ParticleManager.CreateRing(new Vector3(PlacePosition.X, 0, PlacePosition.Y), MyCard.TurretSize * UnitBuilding.BuildingRingSizeMult * Alpha * RingAlpha, ParentShip.GetTeam());

                for (int i = 0; i < MyCard.CircleGlows; i++)
                {
                    float   R = (float)(((float)i / MyCard.CircleGlows * 2 * Math.PI) + (Level.Time % 2 / 2f * Math.PI));
                    Vector3 P = new Vector3((float)Math.Cos(R) * MyCard.Radius * Alpha * RingAlpha + PlacePosition.X, 0, (float)Math.Sin(R) * MyCard.Radius * Alpha * RingAlpha + PlacePosition.Y);
                    ParticleManager.CreateParticle(P, Vector3.Zero, MyColor, 64 * Alpha * RingAlpha, 1);
                }
            }

            base.Update2(gameTime);
        }
示例#8
0
        public override void Update(GameTime gameTime)
        {
            SoundManager.Update(gameTime);
            ParticleManager.Update(gameTime);
            InstanceManager.Update(gameTime);
            FactionManager.Update(gameTime);

#if DRAWQUAD
            DrawGridTimer += gameTime.ElapsedGameTime.Milliseconds;
            if (DrawGridTimer > MaxDrawGridTimer)
            {
                DrawGridTimer = 0;
                DrawQuadGrid.SetObjects(DrawChildren);
            }
#endif
            SolidQuadGrid.SetObjects(SolidChildren);

            base.Update(gameTime);
        }
        public bool TestFree(Vector2 Position, float Size, int FactionNumber)
        {
            Basic2DScene Parent2DScene = (Basic2DScene)GameManager.GetLevel().getCurrentScene();
            QuadGrid     quad          = Parent2DScene.quadGrids.First.Value;

            foreach (UnitBasic o in FactionManager.SortedUnits[FactionManager.GetTeam(FactionNumber)])
            {
                if (o.GetType().IsSubclassOf(typeof(UnitBuilding)))
                {
                    UnitBuilding s = (UnitBuilding)o;
                    if (Vector2.Distance(Position, o.Position.get()) < (Size + o.Size.X()))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
        public override void Destroy()
        {
            if (SoundInstance != null && !SoundInstance.IsDisposed)
            {
                SoundInstance.Dispose();
                SoundInstance = null;
            }

            if (UnitCommited)
            {
                UnitCommited = false;
                FactionManager.RemoveUnit(this);
            }

            base.Destroy();

            Dead = true;
            PathFindingManager.Rebuild();
        }
示例#11
0
        public override void Update(GameTime gameTime)
        {
            int c = FactionManager.GetFaction(ParentShip.FactionNumber).MaxMiningPlatformCounter / 2;

            if (c != CurrentMaxCounter)
            {
                CurrentMaxCounter = c;

                AddItem(new HudMineralCounter());

                int Counter = 0;
                foreach (HudMineralCounter m in Children)
                {
                    Counter++;
                    m.SetCounter(Counter, (-Children.Count / 2f + Counter - 0.5f) * 80);
                }
            }

            base.Update(gameTime);
        }
 public override void Update(GameTime gameTime)
 {
     if (ParentShip.Dead && ParentShip.Attacking && FactionManager.CanAfford(ParentShip.FactionNumber, 0, PlayerShip.GetRespawnCost()))
     {
         PayToRespawnAlpha += gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * AlphaChange;
         if (PayToRespawnAlpha > 1)
         {
             PayToRespawnAlpha = 1;
         }
     }
     else
     {
         PayToRespawnAlpha -= gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * AlphaChange;
         if (PayToRespawnAlpha < 0)
         {
             PayToRespawnAlpha = 0;
         }
     }
     base.Update(gameTime);
 }
示例#13
0
        public override void PlayerQuitEvent(PlayerProfile p)
        {
            int        FactionNumber = -1;
            PlayerShip playerShip    = null;

            foreach (PlayerShip s in Enumerate(typeof(PlayerShip)))
            {
                if (s.MyProfile == p)
                {
                    playerShip    = s;
                    FactionNumber = s.FactionNumber;
                }
            }

            if (playerShip != null)
            {
                playerShip.Destroy();

                LinkedList <BasicShipGameObject> toDestroy = new LinkedList <BasicShipGameObject>();

                foreach (BasicShipGameObject o in Enumerate(typeof(BasicShipGameObject)))
                {
                    if (o.FactionNumber == FactionNumber)
                    {
                        toDestroy.AddLast(o);
                    }
                }

                foreach (BasicShipGameObject o in toDestroy)
                {
                    o.Destroy();
                }

                ChooseStartState.RemovePlayer();
                FactionManager.Remove(FactionNumber);
            }

            base.PlayerQuitEvent(p);
        }
        public override void Update(GameTime gameTime)
        {
            float TargetAlpha = FactionManager.GetFaction(ParentBox.ParentShip.FactionNumber).Cells > 0? 1 : 0.2f;

            if (Alpha < TargetAlpha)
            {
                Alpha += gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * AlphaChange;
                if (Alpha > TargetAlpha)
                {
                    Alpha = TargetAlpha;
                }
            }
            else
            {
                Alpha -= gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * AlphaChange;
                if (Alpha < TargetAlpha)
                {
                    Alpha = TargetAlpha;
                }
            }
            base.Update(gameTime);
        }
示例#15
0
        public override void Create()
        {
            SoundLibrary.Load();
            InstanceManager.Clear();
            ParticleManager.Load();
            Load();

            OverDrawChildren2D    = AddTag(GameObjectTag._2DOverDraw);
            OverDrawViewsChildren = AddTag(GameObjectTag.OverDrawViews);
            Draw2DChildren        = AddTag(GameObjectTag._2DForward);

#if EDITOR && WINDOWS
            if (ParentLevel.LevelForEditing)
            {
                PreDrawChildren = AddTag(GameObjectTag._2DPreDraw);
            }
            else
#endif
            {
                ForwardChildren    = AddTag(GameObjectTag._3DForward);
                BackgroundChildren = AddTag(GameObjectTag._3DBackground);
                DepthOverChildren  = AddTag(GameObjectTag._3DDepthOver);
            }

            SolidChildren      = AddTag(GameObjectTag._2DSolid);
            ShipChildren       = AddTag(GameObjectTag.ShipGameUnitBasic);
            DistortionChildren = AddTag(GameObjectTag._3DDistortion);

            SolidQuadGrid = Add(new QuadGrid());
#if DRAWQUAD
            DrawQuadGrid = Add(new QuadGrid());
#endif

            FactionManager.Init();

            base.Create();
        }
        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 bool APress(PlayerShip Ship, bool APrevious)
        {
            if (!APrevious)
            {
                {
                    int CardCost = CardCellsCost;
                    if (FactionCostIncreases.ContainsKey(Ship.FactionNumber))
                    {
                        CardCost += CardCellsCostIncrease * FactionCostIncreases[Ship.FactionNumber];
                    }

                    if (FactionManager.CanAfford(Ship.FactionNumber, CardCost) && Ship.CanPlaceTurret(TurretSize))
                    {
                        if (FactionCostIncreases.ContainsKey(Ship.FactionNumber))
                        {
                            FactionCostIncreases[Ship.FactionNumber]++;
                        }
                        else
                        {
                            FactionCostIncreases.Add(Ship.FactionNumber, 1);
                        }

                        FactionManager.AddCells(Ship.FactionNumber, -CardCost);
                        UnitTurret u = (UnitTurret)GetUnit(Ship.FactionNumber);
                        u.MyCard = this;
                        Ship.PlaceTurret(u);
                        return(true);
                    }
                    else
                    {
                        RedFlashAlpha = 1;
                    }
                }
            }
            return(false);
        }
        public virtual Vector2 GetPlacePosition(int FactionNumber)
        {
            float   BestScore    = -500000;
            Vector2 BestPosition = Vector2.Zero;

            float Distance = 1000;
            float JumpSize = 100;

            Vector2 MinPos = new Vector2(10000);
            Vector2 MaxPos = new Vector2(-10000);

            foreach (MiningPlatform m in GameManager.GetLevel().getCurrentScene().Enumerate(typeof(MiningPlatform)))
            {
                if (m.GetTeam() == FactionManager.GetTeam(FactionNumber) && !m.Dead)
                {
                    MinPos = Vector2.Min(MinPos, m.Position.get() - new Vector2(Distance));
                    MaxPos = Vector2.Max(MaxPos, m.Position.get() + new Vector2(Distance));
                }
            }

            Basic2DScene b = (Basic2DScene)GameManager.GetLevel().getCurrentScene();

            MinPos = Vector2.Max(MinPos, b.MinBoundary.get());
            MaxPos = Vector2.Min(MaxPos, b.MaxBoundary.get());

            for (float x = MinPos.X; x < MaxPos.X; x += JumpSize)
            {
                for (float y = MinPos.Y; y < MaxPos.Y; y += JumpSize)
                {
                    if (TestFree(new Vector2(x, y), TurretSize, FactionNumber) &&
                        PathFindingManager.GetCellValue(new Vector2(x, y)) != PathFindingManager.DeadCell)
                    {
                        float score = 5000;

                        if (GetTurretFragility() != 0)
                        {
                            if (PathFindingManager.CollisionLine(new Vector2(x, y), 1, 0, 3))
                            {
                                score += 100 * GetTurretFragility();
                            }
                            if (PathFindingManager.CollisionLine(new Vector2(x, y), -1, 0, 3))
                            {
                                score += 100 * GetTurretFragility();
                            }
                            if (PathFindingManager.CollisionLine(new Vector2(x, y), 0, 1, 3))
                            {
                                score += 100 * GetTurretFragility();
                            }
                            if (PathFindingManager.CollisionLine(new Vector2(x, y), 0, -1, 3))
                            {
                                score += 100 * GetTurretFragility();
                            }

                            if (PathFindingManager.CollisionLine(new Vector2(x, y), -1, -1, 2))
                            {
                                score += 100 * GetTurretFragility();
                            }
                            if (PathFindingManager.CollisionLine(new Vector2(x, y), 1, -1, 2))
                            {
                                score += 100 * GetTurretFragility();
                            }
                            if (PathFindingManager.CollisionLine(new Vector2(x, y), -1, 1, 2))
                            {
                                score += 100 * GetTurretFragility();
                            }
                            if (PathFindingManager.CollisionLine(new Vector2(x, y), 1, 1, 2))
                            {
                                score += 100 * GetTurretFragility();
                            }
                        }

                        foreach (NeutralSpawn spawn in NeutralManager.SpawnList)
                        {
                            if (PathFindingManager.GetCellValue(spawn.Position.get()) > PathFindingManager.StartingCell - 50 &&
                                PathFindingManager.GetCellValue(spawn.Position.get()) < PathFindingManager.StartingCell - 20 &&
                                PathFindingManager.GetAreaClear(spawn.Position.get()))
                            {
                                if (GetTurretFragility() != 0 && PathFindingManager.CollisionLine(new Vector2(x, y), spawn.Position.get()))
                                {
                                    score += 500 * GetTurretFragility();
                                }

                                if (score > BestScore)
                                {
                                    MiningPlatform NearestMiningPlatform = null;
                                    float          NearestDistance       = 10000;

                                    foreach (MiningPlatform m2 in GameManager.GetLevel().getCurrentScene().Enumerate(typeof(MiningPlatform)))
                                    {
                                        if (m2.GetTeam() == FactionManager.GetTeam(FactionNumber) && !m2.Dead)
                                        {
                                            float d = Vector2.Distance(m2.Position.get(), spawn.Position.get());
                                            if (d < NearestDistance)
                                            {
                                                NearestDistance       = d;
                                                NearestMiningPlatform = m2;
                                            }
                                        }
                                    }

                                    score -= Logic.DistanceLineSegmentToPoint(spawn.Position.get(),
                                                                              NearestMiningPlatform.Position.get(), new Vector2(x, y)) * GetTurretAgression();
                                }
                            }
                        }

                        if (score > BestScore)
                        {
                            Basic2DScene Parent2DScene = (Basic2DScene)GameManager.GetLevel().getCurrentScene();
                            QuadGrid     quad          = Parent2DScene.quadGrids.First.Value;

                            foreach (Basic2DObject o in quad.Enumerate(new Vector2(x, y), new Vector2(200)))
                            {
                                if (o.GetType().IsSubclassOf(typeof(UnitBuilding)))
                                {
                                    UnitBuilding s = (UnitBuilding)o;
                                    if (s.GetTeam() == FactionManager.GetTeam(FactionNumber))
                                    {
                                        float d = Vector2.Distance(o.Position.get(), new Vector2(x, y));
                                        if (d < 2000)
                                        {
                                            score -= (2000 - d) * GetBuildingAvoidence();
                                            if (s.GetType().IsSubclassOf(typeof(MiningPlatform)))
                                            {
                                                score -= (2000 - d) * GetBaseAvoidence();
                                            }
                                            else if (s.GetType().IsSubclassOf(typeof(UnitTurret)))
                                            {
                                                UnitTurret t = (UnitTurret)s;
                                                if (t.MyCard != null)
                                                {
                                                    if (t.MyCard.StrongVs.Equals(StrongVs))
                                                    {
                                                        score -= (2000 - d) * GetTurretAvoidence();
                                                    }
                                                }
                                                else
                                                {
                                                    if (StrongVs.Equals("Heavy"))
                                                    {
                                                        score -= (2000 - d) * GetTurretAvoidence();
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }

                            if (score > BestScore)
                            {
                                BestScore    = score;
                                BestPosition = new Vector2(x, y);
                            }
                        }
                    }
                }
            }

            return(BestPosition);
        }
 public override bool CanInteract(PlayerShip p)
 {
     return(FactionManager.CanAfford(p.FactionNumber, UpgradeCost));
 }
 public static void NewEvent(SceneObject Scene)
 {
     FactionManager.NewWaveEvent(Scene);
     NeutralManager.NewWaveEvent();
 }
示例#21
0
        public void Update(GameTime gameTime, BasicController MyController, bool Highlighted)
        {
            if (Highlighted && !ParentMenu.Closing)
            {
                TargetPosition = ParentMenu.Position - TechTreeMenu.NegativeOffset - new Vector2(0, Size.Y / 2);
                Position      += (TargetPosition - Position) * gameTime.ElapsedGameTime.Milliseconds * PlayerMenu.CloseOpenSpeed * 2;
                Alpha          = Math.Min(1, Alpha + gameTime.ElapsedGameTime.Milliseconds * PlayerMenu.CloseOpenSpeed * 2);
                if (Alpha > 0.5f)
                {
                    Vector2 CursorPrevious = Cursor;
                    bool    ExtraSticks    = FactionManager.GetFaction(ParentMenu.ParentShip.FactionNumber).PickingCards;
                    Cursor += MyController.MenuStick(ExtraSticks, ExtraSticks, true, false, false);

                    if (ExtraSticks)
                    {
                        Vector2 BumperCursorPrevious = BumperCursor;
                        BumperCursor = MyController.MenuStick(false, false, false, true, true);
                        if (Math.Abs(BumperCursor.X) > 0.1f && Math.Abs(BumperCursor.X) < 0.1f)
                        {
                            Faction f = FactionManager.GetFaction(ParentMenu.ParentShip.FactionNumber);
                            if (BumperCursor.X > 0)
                            {
                                f.CardPickPosition++;
                                if (f.CardPickPosition == f.Cards.Count)
                                {
                                    ParentMenu.ParentShip.ReadyMenu();
                                }
                            }
                            else
                            {
                                f.CardPickPosition = Math.Max(0, f.CardPickPosition - 1);
                            }
                        }
                    }

                    if (Cursor.Y != 0 && ParentMenu.MyFaction.PickingCards)
                    {
                        if (Cursor.Y < 0)
                        {
                            TechTreeGroup PreviousGroup = MyNode.Previous != null ? MyNode.Previous.Value : MyNode.List.Last.Value;
                            if (PreviousGroup.Cards != null && PreviousGroup.Cards.Count > 0)
                            {
                                PreviousGroup.Cursor.X = Cursor.X;
                                PreviousGroup.Position = Position - new Vector2(0, PreviousGroup.Size.Y);
                                ParentMenu.SetGroup(PreviousGroup);
                                PreviousGroup.SwitchTo();
                            }
                        }
                        else if (Cursor.Y > 0)
                        {
                            TechTreeGroup NextGroup = MyNode.Next != null ? MyNode.Next.Value : MyNode.List.First.Value;
                            if (NextGroup.Cards != null && NextGroup.Cards.Count > 0)
                            {
                                NextGroup.Cursor.X = Cursor.X;
                                NextGroup.Position = Position + new Vector2(0, Size.Y);
                                ParentMenu.SetGroup(NextGroup);
                                NextGroup.SwitchTo();
                            }
                        }
                        Cursor.Y = 0;
                    }
                    Cursor.X = MathHelper.Clamp(Cursor.X, 0, Cards.Count - 1);

                    int i = 0;
                    foreach (FactionCard c in Cards)
                    {
                        c.MenuUpdate(gameTime, (int)Cursor.X == i, 1 - Math.Abs(Cursor.X - i++) / 2.25f);
                    }

                    Vector2 TargetOffset = -new Vector2((Cursor.X - 2) * CellBorders.X, -CellBorders.Y / 2f);
                    DrawOffset += (TargetOffset - DrawOffset) * OffsetSpeed;

                    HighlightedCard = Cards[(int)Cursor.X];
                    if (MyController.AButton() && !MyController.AButtonPrevious())
                    {
                    }
                    HighlightedCard.Update3D(ParentMenu.ParentShip);
                }
            }
            else
            {
                Alpha = Math.Max(0, Alpha - gameTime.ElapsedGameTime.Milliseconds * PlayerMenu.CloseOpenSpeed);
            }
        }
 public override bool CanInteract(PlayerShip p)
 {
     return((FactionManager.CanAfford(p.FactionNumber, FactionManager.GetMiningPlatformCost(p.FactionNumber)) || !p.PlacedStartingMineralRock) && miningPlatform == null && FactionManager.CanBuildMiningPlatform(p.FactionNumber));
 }
 public override void Draw(Vector2 Position, Vector2 Size)
 {
     DigitRenderer.DrawDigits(FactionManager.GetFaction(ParentBox.ParentShip.FactionNumber).Cells, 4, Position, Size, TeamInfo.HudColors[ParentBox.ParentShip.GetTeam()] * Alpha);
     base.Draw(Position, Size);
 }
        public override bool TriggerAsCurrent(BasicMarker m)
        {
            if (BasicMarker.SelectSound != null)
            {
                BasicMarker.SelectSound.Play(BasicMarker.SelectVolume, 0, 0);
            }

            Faction f = FactionManager.Factions[ParentShip.FactionNumber];

            FlashAlpha = 1;

            if (FactionManager.GetFaction(ParentShip.FactionNumber).PickingCards)
            {
                if (Selected)
                {
                    for (int i = 0; i < f.Cards.Count; i++)
                    {
                        if (f.Cards[i] == MyCard)
                        {
                            f.Cards[i] = null;
                            Selected   = false;
                            return(true);
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < f.Cards.Count; i++)
                    {
                        if (f.Cards[i] == null)
                        {
                            f.Cards[i] = MyCard;
                            Selected   = true;
                            break;
                        }
                    }

                    if (!Selected)
                    {
                        f.Cards.Add(MyCard);
                        Selected = true;
                    }

                    if (Faction.MaxCards == f.Cards.Count)
                    {
                        for (int i = 0; i < f.Cards.Count; i++)
                        {
                            if (f.Cards[i] == null)
                            {
                                return(true);
                            }
                        }

                        ParentShip.ReadyMenu();
                    }
                }
            }
            else
            {
                int CardCost = MyCard.CardCellsCost;
                if (MyCard.FactionCostIncreases.ContainsKey(ParentShip.FactionNumber))
                {
                    CardCost += MyCard.CardCellsCostIncrease * MyCard.FactionCostIncreases[ParentShip.FactionNumber];
                }

                if (FactionManager.CanAfford(ParentShip.FactionNumber, CardCost) && ParentShip.CanPlaceTurret(MyCard.TurretSize))
                {
                    if (MyCard.FactionCostIncreases.ContainsKey(ParentShip.FactionNumber))
                    {
                        MyCard.FactionCostIncreases[ParentShip.FactionNumber]++;
                    }
                    else
                    {
                        MyCard.FactionCostIncreases.Add(ParentShip.FactionNumber, 1);
                    }

                    FactionManager.AddCells(ParentShip.FactionNumber, -CardCost);
                    UnitTurret u = (UnitTurret)MyCard.GetUnit(ParentShip.FactionNumber);
                    u.MyCard = MyCard;
                    ParentShip.PlaceTurret(u);
                    //ParentFrame.DeActivate();
                }
                else
                {
                    ErrorAlpha = 1;
                }
            }

            return(base.TriggerAsCurrent(m));
        }
        public override void DrawAsForm(Vector2 Position, Vector2 Size)
        {
            Vector2 FormSize  = Size * Alpha * 1.5f;
            float   FormAlpha = Alpha * DistanceAlpha;

            Render.DrawSprite(WaveCard.UnitPicker, Position, Size * new Vector2((Rand.F() + 6) / 7 * 4, 2.5f), Rotation.get(), MyColor * FormAlpha * 2);

            Render.DrawSprite(WaveCard.UnitBox, Position, FormSize * 1.25f, Rotation.get(), MyColor * (FormAlpha * FormAlpha * 0.3f * (4 + Rand.F())));
            Render.DrawSprite(WaveCard.UnitPicker, Position, FormSize * new Vector2((Rand.F() + 6) / 7, 1), Rotation.get(), MyColor * (FormAlpha * FormAlpha * 0.3f * (4 + Rand.F())));
            Render.DrawSprite(MyTexture, Position, FormSize, Rotation.get(), Color.White * FormAlpha);


            if (FlashAlpha > 0)
            {
                Render.DrawSprite(HudItem.GlowTexture, Position, FormSize * 2, Rotation.get(), MyColor * 1.5f * FlashAlpha * FormAlpha);
            }
            if (ErrorAlpha > 0)
            {
                Render.DrawSprite(HudItem.GlowTexture, Position, FormSize * 2, Rotation.get(), Color.Red * 1.5f * ErrorAlpha * FormAlpha);
                Render.DrawSprite(FactionEvent.LossTexture, Position, FormSize, Rotation.get(), Color.Red * 1.5f * ErrorAlpha * FormAlpha);
            }
            if (SelectedAlpha > 0)
            {
                Render.DrawSprite(FactionEvent.ReadyTexture, Position, FormSize * SelectedAlpha, Rotation.get(), MyColor * SelectedAlpha * 2 * FormAlpha);
                Render.DrawSprite(HudItem.GlowTexture, Position, FormSize, Rotation.get(), MyColor * SelectedAlpha * FormAlpha * 1.5f);
            }

            if (FormAlpha > 0.5 && Font.get() != null)
            {
                float DrawHeight = Position.Y - Size.Y / 2;
                float FontHeight = Font.get().MeasureString(Name.get()).Y;
                DrawHeight -= FontHeight * 2;

                string CostString = "";
                if (MyCard.FactionCostIncreases.ContainsKey(ParentShip.FactionNumber))
                {
                    CostString = "$" + (MyCard.CardCellsCost + MyCard.CardCellsCostIncrease * MyCard.FactionCostIncreases[ParentShip.FactionNumber]).ToString();
                }
                else
                {
                    CostString = "$" + (MyCard.CardCellsCost).ToString();
                }

                Render.DrawShadowedText(Font.get(), Text.get(), new Vector2(Position.X - Font.get().MeasureString(Text.get()).X / 2, DrawHeight),
                                        Vector2.One * 2, Color.White * (FormAlpha - 0.5f) * 2, Color.Black * (FormAlpha - 0.5f) * 2);
                DrawHeight -= FontHeight;
                Render.DrawShadowedText(Font.get(), CostString, new Vector2(Position.X - Font.get().MeasureString(CostString).X / 2, DrawHeight),
                                        Vector2.One * 2, Color.White * (FormAlpha - 0.5f) * 2, Color.Black * (FormAlpha - 0.5f) * 2);
                if (FactionManager.GetFaction(ParentShip.FactionNumber).PickingCards)
                {
                    Vector2 s = Font.get().MeasureString(MyCard.Caption);
                    DrawHeight -= s.Y + 20;
                    //DrawHeight += 2 * FontHeight;
                    Render.DrawSprite(HudItem.GlowTexture, new Vector2(Position.X, DrawHeight + s.Y / 2), s * 6,
                                      0, Color.Black * (FormAlpha - 0.5f) * 2);
                    Render.DrawShadowedText(Font.get(), MyCard.Caption, new Vector2(Position.X - Font.get().MeasureString(MyCard.Caption).X / 2, DrawHeight),
                                            Vector2.One * 2, Color.White * (FormAlpha - 0.5f) * 2, Color.Black * (FormAlpha - 0.5f) * 2);
                }

                if (!MyCard.StrongVs.Equals(""))
                {
                    Render.DrawSprite(MyCard.GetStrongTexture(), Position - Size * 3 / 8 * new Vector2(1, -1), Size / 2, 0, Color.White * (FormAlpha * FormAlpha));
                    Render.DrawShadowedText(Font.get(), MyCard.StrongVs,
                                            new Vector2(Position.X - Size.X * 1 / 8, Position.Y - Font.get().MeasureString(MyCard.StrongVs).Y * 3 / 4 + Size.Y / 2),
                                            Vector2.One * 2, Color.White * (FormAlpha - 0.5f) * 2, Color.Black * (FormAlpha - 0.5f) * 2);
                }
            }

            Render.DrawOutlineRect(Position - FormSize * (FormAlpha - 0.5f), Position + FormSize * (FormAlpha - 0.5f), 2 * FormAlpha, Color.White * (FormAlpha * FormAlpha * FormAlpha));

            base.DrawAsForm(Position, FormSize);
        }
 public static void WaveEnd(SceneObject Scene)
 {
     FactionManager.WaveEnd(Scene);
 }