Esempio n. 1
0
        public void RefreshGame()
        {
            if (TimeStamp % 3 == 0)
            {
                DForm.ImgSwitch_Tick();
            }
            if (TimeStamp % 100 == 0)
            {
                Spawn();
            }
            for (int i = 0; i < Projectiles.Count; i++)
            {
                Projectiles[i].Spin += 5;
            }
            CurrentPlayer.ApplyBuffs(TimeStamp);
            if (PlayerOnMove)
            {
                //Vertex UnitVector = Vertex.Norm(DrawForm.GetAngleDegree(CurrentPlayer.Location.ToPoint(), CurrentPlayer.NextLocation.ToPoint())) * CurrentPlayer.Speed;
                Vertex UnitVectorBase = new Vertex(1, 0);
                double Angle          = CurrentPlayer.Facing + 90;
                Vertex UnitVector     = UnitVectorBase.RotateZ(Angle);
                CurrentPlayer.Location += UnitVector * CurrentPlayer.ActiveSpeed;
            }
            for (int i = 0; i < Projectiles.Count; i++)
            {
                double Angle = 0;
                if (Projectiles[i].Behave.Linear)
                {
                    Angle = Projectiles[i].Facing + 90;
                }
                else
                {
                    Angle = -DrawForm.GetAngleDegree(Projectiles[i].Location.ToPoint(), CurrentPlayer.Location.ToPoint()) + 90;
                }
                Vertex UnitVectorBase = new Vertex(1, 0);
                Vertex UnitVector     = UnitVectorBase.RotateZ(Angle);
                Projectiles[i].Location += UnitVector * Projectiles[i].Speed;
                if (!Projectiles[i].Behave.Sustainable)
                {
                    Projectiles[i].Health -= 10;
                }
                if (Projectiles[i].Health == 0)
                {
                    for (int j = 0; j < Projectiles[i].Summons.Count; j++)
                    {
                        if (Projectiles[i].Summons[j].Event == SummonActivationType.OnExpire || Projectiles[i].Summons[j].Event == SummonActivationType.OnBoth)
                        {
                            if (Projectiles[i].Summons[j].Type == SummonType.Projectile)
                            {
                                Projectile P = new Projectile(Projectiles[i].Summons[j].Projectile);
                                P.Owner     = Projectiles[i].Owner;
                                P.Location += Projectiles[i].Location;
                                P.Facing   += Projectiles[i].Facing + Projectiles[i].Summons[j].Facing;
                                Projectiles.Add(P);
                            }
                            else if (Projectiles[i].Summons[j].Type == SummonType.Enemy)
                            {
                                Enemy E = new Enemy(_DataPool.Enemies[Projectiles[i].Summons[j].Enemy]);
                                E.Location += Projectiles[i].Location;
                                E.Facing    = Projectiles[i].Facing;
                                this._Enemies.Add(E);
                            }
                        }
                    }
                    Projectiles[i].Location = null;
                }
            }
            if (PlayerOnFire && TimeStamp % 5 == 0)
            {
                if (!CurrentPlayer.Disabled)
                {
                    for (int i = 0; i < CurrentPlayer.Guns.Count; i++)
                    {
                        if (!CurrentPlayer.Guns[i].Active)
                        {
                            continue;
                        }
                        this._Projectiles.AddRange(CurrentPlayer.Guns[i].Shoot(CurrentPlayer, TimeStamp));
                    }
                    CurrentPlayer.IsActiveEmpty();
                }
            }
            for (int i = 0; i < Effects.Count; i++)
            {
                Effects[i].Lifetime--;
                if (Effects[i].Lifetime == 0)
                {
                    Effects[i].Location = null;
                }
            }
            for (int i = 0; i < Enemies.Count; i++)
            {
                if (Sanctuary > 0)
                {
                    break;
                }
                if (Enemies[i].Location == null)
                {
                    continue;
                }
                Enemies[i].ApplyBuffs(TimeStamp);
                if (Vertex.Distance(Enemies[i].Location, CurrentPlayer.Location) < Enemies[i].Behave.Sight)
                {
                    if (Vertex.Distance(Enemies[i].Location, CurrentPlayer.Location) > Enemies[i].Behave.Radius)
                    {
                        Vertex UnitVectorBase = new Vertex(1, 0);
                        double Angle          = DrawForm.GetAngleDegree(Enemies[i].Location.ToPoint(), CurrentPlayer.Location.ToPoint());
                        Vertex UnitVector     = UnitVectorBase.RotateZ(Angle + 90);
                        UnitVector.Y        *= -1;
                        Enemies[i].Location -= UnitVector * Enemies[i].ActiveSpeed;
                    }
                    else if (TimeStamp % 5 == 0)
                    {
                        Enemies[i].Facing = -DrawForm.GetAngleDegree(Enemies[i].Location.ToPoint(), CurrentPlayer.Location.ToPoint());

                        for (int j = 0; j < Enemies[i].Guns.Count; j++)
                        {
                            if (!Enemies[i].Guns[j].Active)
                            {
                                continue;
                            }
                            this._Projectiles.AddRange(Enemies[i].Guns[j].Shoot(Enemies[i], TimeStamp));
                        }
                    }
                }
            }
            if (this._CurrentBoss != null)
            {
                for (int i = 0; i < this._CurrentBoss.Auxes.Count; i++)
                {
                    this._CurrentBoss.Auxes[i].Location = this._CurrentBoss.Location + this._CurrentBoss.Offsets[i].RotateZ(this._CurrentBoss.Facing);
                    this._CurrentBoss.Auxes[i].Facing   = this._CurrentBoss.Facing;
                }
            }
            isHit();
            isPlayerHit();
            if (PowerUps.Count > 0)
            {
                tookPowerUp();
            }
            if (CurrentPlayer.CurrentWeapons == 0)
            {
                DForm.RefreshData((int)(200 * CurrentPlayer.Health * 1.0 / CurrentPlayer.MaxHealth), "Basic");
            }
            else if (CurrentPlayer.CurrentWeapons == 1)
            {
                DForm.RefreshData((int)(200 * CurrentPlayer.Health * 1.0 / CurrentPlayer.MaxHealth), "Heavy - " + CurrentPlayer.CurrentAmmo());
            }
            else if (CurrentPlayer.CurrentWeapons == 2)
            {
                DForm.RefreshData((int)(200 * CurrentPlayer.Health * 1.0 / CurrentPlayer.MaxHealth), "Laser - " + CurrentPlayer.CurrentAmmo());
            }
            else if (CurrentPlayer.CurrentWeapons == 3)
            {
                DForm.RefreshData((int)(200 * CurrentPlayer.Health * 1.0 / CurrentPlayer.MaxHealth), "Plasma - " + CurrentPlayer.CurrentAmmo());
            }
            RefreshDrawing();
        }