public override void UpdateEditor(GameTime gameTime)
        {
            if (WorldViewer.self.ContainsMouse && !WorldViewer.self.MouseOverForm)
            {
                RayCast(gameTime);
            }

            if (MyCamera.get() == null)
            {
                MyCamera.set(FindObject(typeof(Camera3DObject)));
                if (MyCamera.get() != null)
                {
                    if (EditorSelected)
                    {
                        UpdateSelected();
                    }
                }
                else
                {
                    Camera3DObject camera = new Camera3DObject();
                    ParentLevel.AddObject(camera, this);
                    MyCamera.set(camera);
                    camera.Name.set("EditorCamera");
                }
            }
            if (ParentLevel.LevelForEditing)
            {
                base.UpdateEditor(gameTime);
            }
        }
示例#2
0
        public override void PlayerJoinedEvent(PlayerProfile profile)
        {
            List <MineralRock> AllRocks = new List <MineralRock>();

            foreach (MineralRock r in Enumerate(typeof(MineralRock)))
            {
                if (r.IsStartingZone.get() == 1 && r.miningPlatform == null)
                {
                    AllRocks.Add(r);
                }
            }

            if (AllRocks.Count == 0)
            {
                return;
            }

            PlayerShip p = (PlayerShip)ParentLevel.AddObject(new PlayerShip(-1, profile));

            ChooseStartState.AddPlayer();
            MineralRock SelectedRock = AllRocks[Rand.r.Next(AllRocks.Count)];

            p.Position.set(SelectedRock.Position.get());
            SelectedRock.Interact(p);
        }
        public override bool RayCast(GameTime gameTime)
        {
            foreach (GameObject o in Children)
            {
                if (o.RayCast(gameTime))
                {
                    return(true);
                }
            }

            if (!KeyboardManager.AltPressed())
            {
                return(objectControls.RayCast(gameTime));
            }
            else
            {
                if (MouseManager.MouseClicked && CreatorBasic.LastCreator != null)
                {
                    GameObject o = CreatorBasic.LastCreator.ReturnObject();
                    ParentLevel.AddObject(o);
                    if (o.GetType().IsSubclassOf(typeof(Basic2DObject)))
                    {
                        Basic2DObject b = (Basic2DObject)o;
                        b.Position.set(Vector2.Transform(WorldViewer.self.RelativeMousePosition, Matrix.Invert(DrawCamera.ViewMatrix)));
                        ClearSelected();
                        AddSelected(b);
                        if (UseGrid.get())
                        {
                            SnapSelected();
                        }
                    }
                }
                return(true);
            }
        }
        public override void CreateInGame()
        {
            PlasmaTurret p = new PlasmaTurret(FactionNumber.get());

            ParentLevel.AddObject(p);
            p.SetPosition(Position.get());
            base.CreateInGame();
        }
示例#5
0
 public void MakeFadeManager()
 {
     if (FadeManager == null)
     {
         ParentLevel.AddObject(FadeManager = new FadeManager());
     }
     FadeManager.self = FadeManager;
 }
 public override void CreateInGame()
 {
     for (int i = 0; i < FlareCount.get(); i++)
     {
         ParentLevel.AddObject(new WorldFlare(Distance.get(), SpawnPosition.get(), Color.getAsColor(), Speed.get()));
     }
     base.CreateInGame();
 }
        public override void Update(GameTime gameTime)
        {
            frame.WorldMatrix = WorldMatrix;
            if (UnitCount > 0 && !Dead && WaveFSM.WaveStepState.WeaponsFree)
            {
                UnitDelay += gameTime.ElapsedGameTime.Milliseconds;
                if (UnitDelay > MaxUnitDelay)
                {
                    UnitCount--;
                    UnitDelay -= MaxUnitDelay;

                    UnitShip s = (UnitShip)SpawnCard.GetUnit(FactionNumber);
                    ParentLevel.AddObject(s);
                    s.SetLevel((IsUpdgraded ? 3 : 2) * WaveManager.DifficultyMult, 1);

                    if (GetTeam() == WaveManager.ActiveTeam)
                    {
                        float   Theta     = 0;
                        float   Offset    = 0;
                        Vector3 Position3 = new Vector3(Position.X(), Y, Position.Y());

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

                        Vector2 BestPosition = Position.get() + Logic.ToVector2(Theta) * Offset;

                        s.Position.set(BestPosition);

                        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);
                        }

                        Position3 = new Vector3(Position.X(), 0, Position.Y());
                        ParticleManager.CreateParticle(Position3, Vector3.Zero, new Color(1, 0.75f, 0.5f), 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);
                        }
                    }
                    else
                    {
                        s.Position.set(NeutralManager.GetSpawnPosition());
                    }
                }
            }

            base.Update(gameTime);
        }
        public override void Damage(float damage, float pushTime, Vector2 pushSpeed, BasicShipGameObject Damager, AttackType attackType)
        {
            if (attackType != AttackType.White && HasDamageField && BasicField.TestFieldClear(Position.get()))
            {
                HasDamageField = false;
                DamageBoostField c = new DamageBoostField();
                ParentLevel.AddObject(c);
                c.SetPosition(Position.get());
            }

            base.Damage(damage, pushTime, pushSpeed, Damager, attackType);
        }
示例#9
0
        public override void Destroy()
        {
            if (HasCloakField && BasicField.TestFieldClear(Position.get()))
            {
                HasCloakField = false;
                CloakingField c = new CloakingField();
                ParentLevel.AddObject(c);
                c.SetPosition(Position.get());
            }

            base.Destroy();
        }
示例#10
0
        public override void Destroy()
        {
            if (HasSpeedField && BasicField.TestFieldClear(Position.get()))
            {
                HasSpeedField = false;
                SpeedBoostField s = new SpeedBoostField();
                ParentLevel.AddObject(s);
                s.Position.set(Position.get());
            }

            base.Destroy();
        }
        private void SpawnUnit(UnitShip s)
        {
            ParentLevel.AddObject(s);
            s.SetLevel(1, 1);

            PlaceRotationMult += PlaceRotationMultChange;
            if (PlaceRotationMult > 1)
            {
                PlaceRotationMult -= 1;
            }

            s.Position.set(Position.get() + Logic.ToVector2(PlaceRotationMult * PlaceRotation) * (Size.X() + s.Size.X()) / 1.95f);
        }
        private void SummonUnits()
        {
            if (!CanSummon)
            {
                return;
            }

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

            CanSummon   = false;
            HasSummoned = true;

            float Theta  = 0;
            float Offset = Size.X() * 2;

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

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

                u.SetForGhost();
                u.SetLevel(UnitLevel, 1);
                u.Position.set(BestPosition);

                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);
                }
            }


            Position3 = new Vector3(Position.X(), 0, Position.Y());
            ParticleManager.CreateParticle(Position3, Vector3.Zero, new Color(1, 0.75f, 0.5f), 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);
            }
        }
示例#13
0
        public override void Damage(float damage, float pushTime, Vector2 pushSpeed, BasicShipGameObject Damager, AttackType attackType)
        {
            if (attackType != AttackType.White && HasSpeedField && BasicField.TestFieldClear(Position.get()))
            {
                HasSpeedField = false;
                SpeedBoostField s = new SpeedBoostField();
                ParentLevel.AddObject(s);
                s.Position.set(Position.get());
            }

            if (attackType != Weakness && attackType != AttackType.Explosion && attackType != AttackType.Melee)
            {
                attackType = Resistence;
            }

            base.Damage(damage, pushTime, pushSpeed, Damager, attackType);
        }
 public override void Update(GameTime gameTime)
 {
     /*
      * SparkTimer += gameTime.ElapsedGameTime.Milliseconds;
      * if (SparkTimer > MaxSparkTimer.get())
      * {
      *  SparkTimer -= MaxSparkTimer.get();
      *  ParentLevel.AddObject(new PathfindingFlare(PathFindingManager.self, Rand.r.Next(PathFindingManager.self.CellsX.get()),
      *      Rand.r.Next(PathFindingManager.self.CellsX.get()), 0, 0, Color.getAsColor()));
      * }*/
     if (!WaveFSM.WaveStepState.WeaponsFree)
     {
         Basic2DScene Parent2DScene = (Basic2DScene)ParentScene;
         Vector2      p             = NeutralManager.GetSpawnPosition();
         ParentLevel.AddObject(new PathfindingFlare(PathFindingManager.self,
                                                    (int)((p.X - Parent2DScene.MinBoundary.X()) / PathFindingManager.self.Divisor.X),
                                                    (int)((p.Y - Parent2DScene.MinBoundary.Y()) / PathFindingManager.self.Divisor.Y),
                                                    0, 0, Color.getAsColor()));
     }
     base.Update(gameTime);
 }
        public override void PlayerJoinedEvent(PlayerProfile p)
        {
            SpyPlayer player = new SpyPlayer(p);

            ParentLevel.AddObject(player, this);

            foreach (GameObject o in Children)
            {
                if (o.GetType().Equals(typeof(SpyPlayerSpawn)))
                {
                    SpyPlayerSpawn spawn = (SpyPlayerSpawn)o;
                    if (spawn.PlayerNumber.get() == p.PlayerNumber)
                    {
                        player.Position.set(spawn.Position.get());
                    }
                    return;
                }
            }

            base.PlayerJoinedEvent(p);
        }
        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 Update(GameTime gameTime)
        {
            if (!Dead)
            {
                MineAddTime += gameTime.ElapsedGameTime.Milliseconds;
                if (MineAddTime > MaxMineAddTime)
                {
                    MinesToAdd++;
                    MineAddTime = 0;

                    SearchTime -= MaxSearchTime;

                    QuadGrid quad = Parent2DScene.quadGrids.First.Value;

                    foreach (Basic2DObject o in quad.Enumerate(Position.get(), new Vector2(MaxEngagementDistance * 2)))
                    {
                        if (o.GetType().IsSubclassOf(typeof(UnitBasic)))
                        {
                            UnitBasic s = (UnitBasic)o;
                            float     d = Vector2.Distance(Position.get(), o.Position.get());
                            if (!s.IsAlly(this) && s.CanBeTargeted() && d < MaxEngagementDistance + o.Size.X() / 2)
                            {
                                if (Mines.Count > 0)
                                {
                                    float BestDistance = 10000;
                                    Mine  BestMine     = null;

                                    foreach (Mine m in Mines)
                                    {
                                        float MineDist = Vector2.Distance(m.Position.get(), o.Position.get());
                                        if (MineDist < BestDistance)
                                        {
                                            BestDistance = MineDist;
                                            BestMine     = m;
                                        }
                                    }

                                    BestMine.SetAttackTarget(s);
                                    Mines.Remove(BestMine);

                                    SoundManager.Play3DSound("MineFieldTarget", new Vector3(Position.X(), Y, Position.Y()), 0.35f,
                                                             1000, 2);
                                }
                                if (d < (Size.X() + o.Size.X()))
                                {
                                    MinesToAdd = 0;
                                }

                                break;
                            }
                        }
                    }
                }

                if (Mines.Count >= MaxMines)
                {
                    MinesToAdd = 0;
                }

                while (MinesToAdd > 0)
                {
                    Mine m = new Mine(this, FactionNumber);
                    ParentLevel.AddObject(m);
                    Mines.AddLast(m);

                    Vector2 toPosition = Position.get() + Rand.V2() * Size.X() / 2;

                    m.Position.set(toPosition);
                    MinesToAdd--;
                }
            }
            base.Update(gameTime);
        }