Пример #1
0
 public ViewResult JoinOasis(Spartan spartan)
 {
     if (ModelState.IsValid)
     {
         Repository.AddSpartan(spartan);
         return(View("Thanks", spartan));
     }
     else
     {
         return(View());
     }
 }
Пример #2
0
        public override void SpecialUpdate()
        {
            rotation = Functions.SlowRotation(rotation, beamAttack ? (float)Math.PI : 0, (float)Math.PI / 240);
            ArmAction();
            if (spartanTimer % spartanSpawnCooldown ==0 && !beamAttack && openTimer > preOpenTime)
            {
                for (int s =0; s < spartans.Length; s++)
                {
                    if (spartans[s] == null || !Miasma.gameEntities.Contains(spartans[s]))
                    {
                        float horizontal = 100 + 400 * ((float)(s + 1) / (spartans.Length + 1));
                        spartans[s] = new Spartan(new Vector2(horizontal, -50), new Vector2(horizontal, 50), 0, team);
                        Miasma.enemyFleet.Add(spartans[s]);
                    }
                }
                
            }
            annihilator.UpdateRelativePosition();
            foreach(CenterDoor door in centerDoors)
            {
                door.UpdateRelativePosition();
            }
            foreach(SideDoor door in sideDoors)
            {
                door.UpdateRelativePosition();
            }
            core.UpdateRelativePosition();
            
                openTimer++;
            
            for (int a = 0; a < arms.Count; a++)
            {
                if (!Miasma.gameEntities.Contains(arms[a]))
                {
                    arms.RemoveAt(a);
                }
            }
            if(openTimer > preOpenTime + openTime)
            {
                bool endIt = false;
                if(beamAttack)
                {
                    if (beamRunCounter > 4 && (Position.X >= 295 && Position.X <= 305))
                    {
                        Position.X = 300;
                        Velocity = Vector2.Zero;
                    }
                    if(Position.X<=100)
                    {
                        Position.X = 100;
                        Velocity = Vector2.Zero;
                    }
                    if (Position.X >= 500)
                    {
                        Position.X = 500;
                        Velocity = Vector2.Zero;
                    }
                    if ((Position.X <= 150  && Velocity.X <0)|| (Position.X >= 450 && Velocity.X >0))
                    {
                        beamTimer = 0;
                    }
                    if (beamTimer<maxBeamTime)
                    {
                        beamTimer++;
                        new Particle(annihilator.AbsoluteShootPosition() + Functions.PolarVector(4 - Miasma.random.Next(9), (float)Math.PI / 2 + annihilator.AbsoluteRotation()), Functions.PolarVector(3, annihilator.AbsoluteRotation() + Functions.RandomRotation()*.25f - (float)Math.PI/4), 7, 16);
                        beamOn = false;
                    }
                    else
                    {
                        beamOn = true;
                        if (Velocity == Vector2.Zero)
                        {
                            beamRunCounter++;
                            switch (Position.X)
                            {
                                case 300:
                                    if (beamRunCounter > 4)
                                    {
                                        beamAttack = false;
                                        Velocity = Vector2.Zero;
                                        endIt = true;
                                        beamRunCounter = 0;
                                        beamTimer = 0;
                                    }
                                    else
                                    {
                                        Velocity = Miasma.player.Position.X > Position.X ? Vector2.UnitX * 3 : Vector2.UnitX * -3;
                                    }
                                    
                                    break;
                                case 100:
                                    Velocity = Vector2.UnitX * 3;
                                    break;
                                case 500:
                                    Velocity =  Vector2.UnitX * -3;
                                    break;

                            }
                        }
                    }
                }
                else
                {
                    beamOn = false;
                }
                if(arms.Count <= 0 && !beamAttack)
                {
                    endIt = true;
                }
                if(endIt)
                {
                    foreach (CenterDoor door in centerDoors)
                    {
                        door.ToScale(1f);
                    }
                    bool ready = false;
                    foreach (SideDoor door in sideDoors)
                    {
                        if (door.AimTowardSavedPosition(0))
                        {
                            ready = true;
                        }
                    }
                    if (ready)
                    {
                        openTimer = 0;
                        if ((phase == 0 && health < 2 * (float)maxHealth / 3) || (phase == 1 && health < (float)maxHealth / 3))
                        {
                            beamAttack = true;
                            phase++;
                            for (int s = 0; s < Miasma.gameEntities.Count; s++)
                            {
                                if (Miasma.gameEntities[s] is Ship)
                                {
                                    ((Ship)Miasma.gameEntities[s]).Flee();
                                }

                            }
                        }
                    }
                }
            }
            else if (openTimer == preOpenTime + openTime)
            {
                if (beamAttack)
                {

                }
                else
                {
                    foreach (Entity arm in arms)
                    {
                        if (arm is ArmTip)
                        {
                            ((ArmTip)arm).Activate();
                        }
                    }
                }
            }
            else if(openTimer > preOpenTime)
            {
                foreach (CenterDoor door in centerDoors)
                {
                    door.ToScale(0f);
                }
                foreach (SideDoor door in sideDoors)
                {
                    door.AimTowardSavedPosition(1);
                }
            }
            else if (openTimer == preOpenTime)
            {
                if (beamAttack)
                {

                }
                else
                {
                    for (int i = 0; i < maxArms+phase; i++)
                    {
                        arms.Add(new ArmTip(this, CoreCenter() + new Vector2(Miasma.random.Next(-20, 20), Miasma.random.Next(-20, 20)), 0, team));
                    }
                }
            }
            else
            {
                foreach (CenterDoor door in centerDoors)
                {
                    door.ToScale(1f);
                }
                foreach (SideDoor door in sideDoors)
                {
                    door.AimTowardSavedPosition(0);
                }
            }

            if(beamOn)
            {
                Sounds.beamLighting.PlayContinuous();
                if(Functions.RectangleLineCollision(Miasma.player.Hitbox, annihilator.AbsoluteShootPosition() + Functions.PolarVector(4, annihilator.AbsoluteRotation() + (float)Math.PI/2), annihilator.AbsoluteShootPosition() + Functions.PolarVector(4, annihilator.AbsoluteRotation() + (float)Math.PI / 2) + Functions.PolarVector(800, annihilator.AbsoluteRotation()))||
                    Functions.RectangleLineCollision(Miasma.player.Hitbox, annihilator.AbsoluteShootPosition() + Functions.PolarVector(-4, annihilator.AbsoluteRotation() + (float)Math.PI / 2), annihilator.AbsoluteShootPosition() + Functions.PolarVector(-4, annihilator.AbsoluteRotation() + (float)Math.PI / 2) + Functions.PolarVector(800, annihilator.AbsoluteRotation())))
                {
                    Miasma.player.Strike(2);
                }
            }
        }