예제 #1
0
 public ScoreDrop(Vector2 pos, float rot)
 {
     Position = pos;
     Rotation = rot;
     size = 0;
     time = 0;
     ngon = new nGonBuilder(Color.White);
     player = GameManager.State.FindObject<Player>();
     velocity = new Vector2((float)r.NextDouble() - 0.5f, (float)r.NextDouble() - 0.5f) * 0.025f;
 }
예제 #2
0
 public UpgradeOverlay(SpriteBatch batch)
 {
     p = GameManager.State.FindObject<Player>();
     current = 0;
     pointsSpent = 0;
     this.batch = batch;
     font = ContentManager.Load<SpriteFont>("UpgradeFont");
     upgLvl = new int[4] { 3, 3, 3, 3 };
     selected = new bool[4] { false, false, false, false };
     transparentColor = Color.Gray;
     transparentColor.A = 200;
     textLoc = new Vector2[4];
     scale = Screen.Scale;
     upgrade = new nGonBuilder[4];
     text = new String[4];
     upgLoc = new Vector2[4];
     oldState = Keyboard.GetState();
     for(int i=0;i<4;i++)
          upgrade[i] = new nGonBuilder(Color.Black);
 }
예제 #3
0
 private void ConfirmUpg()
 {
     { p = GameManager.State.FindObject<Player>();
         for (int i = 0; i < 4; i++)
         {
             //check if upgraded to max
             if (selected[i] && upgLvl[i] < 6)
             {
                 //check if enough points to upgrade
                 if ((p.getScore() - pointsSpent) > 50)
                 {
                     //find player object and commit upgrades
                     Player player = GameManager.State.FindObject<Player>();
                     upgLvl[i] += 1;
                     if (i == 0)
                         player.UpgMovespeed();
                     else if (i == 1)
                         player.UpgBulletCount();
                     else if (i == 2)
                         player.UpgHealth();
                     else if (i == 3)
                         player.UpgBulletSpeed();
                     pointsSpent += 50;
                     return;
                 }
             }
         }
     }
 }
예제 #4
0
        private void UpdateSides()
        {
            if (leftOrb.health <= 5)
                leftOrb.Invulnerable=true;
            if (rightOrb.health <= 5)
                rightOrb.Invulnerable = true;
            if (leftOrb.Invulnerable)
            {
                switch (leftPos)
                {
                    case TeleState.Up:
                        {
                            leftOrb.Position = new Vector2(0+orbRad*2, -Screen.Y + leftOrb.radius*2);
                            leftPos = TeleState.Shoot;
                        } break;

                    case TeleState.Left:
                        {
                            leftOrb.Position = new Vector2(-Screen.X + leftOrb.radius * 2, 0 + orbRad*2);
                            leftPos = TeleState.Shoot;

                        } break;
                    case TeleState.Shoot:
                        {
                            if (stateTime >= 5)
                                leftPos = TeleState.Laser;
                            Vector2 distance = (p.getPosition() - leftOrb.Position) * Screen.Scale;
                            if (cooldown <= 0)
                            {
                                Tesseract.Engine.GameWorld.GameState.InstantiateCurrent(new EnemyBullet(leftOrb.Position, distance));
                                lcd = 1;
                            }
                            else
                            {
                                lcd = lcd - 2 * Time.Delta;
                            }
                        }break;
                    case TeleState.Laser:
                        {
                            Random r = new Random();
                            Vector2 pos = new Vector2(0, 0);
                            pos.Y += ((float)r.NextDouble() - 0.5f) / 10;
                            emitter.Burst(leftOrb.Position, 1, (float)Math.PI);
                            p = GameManager.State.FindObject<Player>();
                            if (leftPos == TeleState.Left || leftPos == TeleState.Right)
                            {
                                if (leftOrb != null && p.Position.Y > leftOrb.Position.Y - 0.1 && p.Position.Y < leftOrb.Position.Y + 0.1)
                                    p.OnDamage(1);
                            }
                            else
                            {
                                if (leftOrb != null && p.Position.X > leftOrb.Position.X - 0.1 && p.Position.X < leftOrb.Position.Y + 0.1)
                                    p.OnDamage(1);
                            }
                        } break;
                }
            }
            if (rightOrb.Invulnerable)
            {
                switch (rightPos)
                {
                    case TeleState.Down:
                        {
                            rightOrb.Position = new Vector2(0 - orbRad*2, Screen.Y - leftOrb.radius * 2);
                            rightPos = TeleState.Shoot;

                        } break;
                    case TeleState.Right:
                        {
                            rightOrb.Position = new Vector2(Screen.X - orbRad * 2, 0 - orbRad*2);
                            rightPos = TeleState.Shoot;
                        } break;
                    case TeleState.Shoot:
                        {
                            if (stateTime >= 5)
                                rightPos = TeleState.Laser;
                            Vector2 distance = (p.getPosition() - rightOrb.Position) * Screen.Scale;
                            if (cooldown <= 0)
                            {
                                Tesseract.Engine.GameWorld.GameState.InstantiateCurrent(new EnemyBullet(rightOrb.Position, distance));
                                rcd = 1;
                            }
                            else
                            {
                                rcd = rcd - 2 * Time.Delta;
                            }
                        }break;
                    case TeleState.Laser:
                        {
                            Random r = new Random();
                            Vector2 pos = new Vector2(0, 0);
                            pos.Y += ((float)r.NextDouble() - 0.5f) / 10;
                            emitter.Burst(rightOrb.Position, 1, (float)Math.PI);
                            p = GameManager.State.FindObject<Player>();
                            if (rightPos == TeleState.Left || rightPos == TeleState.Right)
                            {
                                if (rightOrb != null && p.Position.Y > leftOrb.Position.Y - 0.1 && p.Position.Y < leftOrb.Position.Y + 0.1)
                                    p.OnDamage(1);
                            }
                            else
                            {
                                if (rightOrb != null && p.Position.X > leftOrb.Position.X - 0.1 && p.Position.X < leftOrb.Position.Y + 0.1)
                                    p.OnDamage(1);
                            }
                        } break;
                }
            }
        }
예제 #5
0
        public override bool Update()
        {
            stateTime += Time.Delta;
            UpdateSides();
            leftOrb.Update();
            rightOrb.Update();
            Vector2 distance = (p.getPosition() - Position) * Screen.Scale;
            distance.Normalize();
            if (leftOrb.Invulnerable && rightOrb.Invulnerable)
                this.Invulnerable = false;
            if(stateTime>3&&this.state==TeleState.Shoot)
                nBuild.PolyColor = Color.Lerp(this.nBuild.PolyColor, Color.Red, (1) / (float)32);
            switch (state)
            {
                case TeleState.Up:
                    {
                        this.nBuild.PolyColor = Color.Lerp(this.nBuild.PolyColor, Color.Indigo, 1);
                        leftOrb.nBuild.PolyColor = Color.Lerp(leftOrb.nBuild.PolyColor, new Color(0,1f,0), 1);
                        rightOrb.nBuild.PolyColor = Color.Lerp(rightOrb.nBuild.PolyColor, new Color(0, 1f, 0), 1);
                        Position = new Vector2(0, -Screen.Y + radius + radius);
                        posState = state;
                        if (!leftOrb.Invulnerable) { leftOrb.Position = new Vector2(Position.X + radius + orbRad, Position.Y); }
                        if (!rightOrb.Invulnerable) { rightOrb.Position = new Vector2(Position.X - radius - orbRad, Position.Y); }
                        SetState(TeleState.Shoot);
                    } break;

                case TeleState.Down:
                    {
                        this.nBuild.PolyColor = Color.Lerp(this.nBuild.PolyColor, Color.Indigo, 1 );
                        leftOrb.nBuild.PolyColor = Color.Lerp(leftOrb.nBuild.PolyColor, new Color(0, 1f, 0), 1);
                        rightOrb.nBuild.PolyColor = Color.Lerp(rightOrb.nBuild.PolyColor, new Color(0, 1f, 0), 1);
                        Position = new Vector2(0, Screen.Y - radius - radius);
                        posState = state;
                        if (!leftOrb.Invulnerable) { leftOrb.Position = new Vector2(Position.X - radius - orbRad, Position.Y); }
                        if (!rightOrb.Invulnerable) { rightOrb.Position = new Vector2(Position.X + radius + orbRad, Position.Y); }
                        SetState(TeleState.Shoot);
                    } break;
                case TeleState.Left:
                    {
                        this.nBuild.PolyColor = Color.Lerp(this.nBuild.PolyColor, Color.Indigo, 1 );
                        leftOrb.nBuild.PolyColor = Color.Lerp(leftOrb.nBuild.PolyColor, new Color(0, 1f, 0), 1);
                        rightOrb.nBuild.PolyColor = Color.Lerp(rightOrb.nBuild.PolyColor, new Color(0, 1f, 0), 1);
                        Position = new Vector2(-Screen.X + radius + radius, 0);
                        posState = state;
                        if (!leftOrb.Invulnerable) { leftOrb.Position = new Vector2(Position.X, Position.Y - radius - orbRad); }
                        if (!rightOrb.Invulnerable) { rightOrb.Position = new Vector2(Position.X, Position.Y + radius + orbRad); }
                        SetState(TeleState.Shoot);
                    } break;
                case TeleState.Right:
                    {
                        this.nBuild.PolyColor = Color.Lerp(this.nBuild.PolyColor, Color.Indigo, 1 );
                        leftOrb.nBuild.PolyColor = Color.Lerp(leftOrb.nBuild.PolyColor, new Color(0, 1f, 0), 1);
                        rightOrb.nBuild.PolyColor = Color.Lerp(rightOrb.nBuild.PolyColor, new Color(0, 1f, 0), 1);
                        Position = new Vector2(Screen.X - radius - radius, 0);
                        posState = state;
                        if (!leftOrb.Invulnerable) { leftOrb.Position = new Vector2(Position.X, Position.Y + radius + orbRad); }
                        if (!rightOrb.Invulnerable) { rightOrb.Position = new Vector2(Position.X, Position.Y - radius - orbRad); }
                        SetState(TeleState.Shoot);
                    } break;
                case TeleState.Shoot:
                    {
                        if (stateTime >= 5)
                            SetState(TeleState.Laser);
                        if (cooldown <= 0)
                        {
                            Tesseract.Engine.GameWorld.GameState.InstantiateCurrent(new EnemyBullet(Position, distance));
                            cooldown = 1;
                        }
                        else
                        {
                            cooldown = cooldown - 2 * Time.Delta;
                        }
                    } break;
                case TeleState.Laser:
                    {
                        if (stateTime > 2)
                        {
                            this.nBuild.PolyColor = Color.Lerp(this.nBuild.PolyColor, Color.Transparent, 1 / (float)16);
                            leftOrb.nBuild.PolyColor = Color.Lerp(leftOrb.nBuild.PolyColor, Color.Transparent, 1 / (float)16);
                            rightOrb.nBuild.PolyColor = Color.Lerp(rightOrb.nBuild.PolyColor, Color.Transparent, 1 / (float)16);
                        }
                        if (stateTime > 3)
                        {
                            switch (new Random().Next(4))
                            {
                                case 0:
                                    {
                                        if(posState!=TeleState.Up)
                                        SetState(TeleState.Up);
                                    } break;
                                case 1:
                                    {
                                        if (posState != TeleState.Down)
                                        SetState(TeleState.Down);
                                    } break;
                                case 2:
                                    {
                                        if (posState != TeleState.Left)
                                        SetState(TeleState.Left);
                                    } break;
                                case 3:
                                    {
                                        if (posState != TeleState.Right)
                                        SetState(TeleState.Right);
                                    } break;
                            }
                        }

                        else
                        {
                            Random r = new Random();
                            Vector2 pos = new Vector2(0, 0);
                            pos.Y += ((float)r.NextDouble() - 0.5f) / 10;
                            emitter.Burst(Position, 1, (float)Math.PI);
                            if (leftOrb.health>5)
                                emitter.Burst(leftOrb.Position, 1, (float)Math.PI);
                            if (rightOrb.health>5)
                                emitter.Burst(rightOrb.Position, 1, (float)Math.PI);

                            p = GameManager.State.FindObject<Player>();
                            if (posState == TeleState.Left || posState == TeleState.Right)
                            {
                                if ((p.Position.Y > Position.Y - 0.1 && p.Position.Y < Position.Y + 0.1)
                                || (leftOrb.health>5 && p.Position.Y > leftOrb.Position.Y - 0.1 && p.Position.Y < leftOrb.Position.Y + 0.1)
                                || (rightOrb.health>5 && p.Position.Y > rightOrb.Position.Y - 0.1 && p.Position.Y < rightOrb.Position.Y + 0.1))
                                {
                                    p.OnDamage(1);
                                }
                            }
                            else
                            {
                                if ((p.Position.X > Position.X - 0.1 && p.Position.X < Position.X + 0.1)
                                || (leftOrb.health>5 && p.Position.X > leftOrb.Position.X - 0.1 && p.Position.X < leftOrb.Position.Y + 0.1)
                                || (rightOrb.health>5 && p.Position.X > rightOrb.Position.X - 0.1 && p.Position.X < rightOrb.Position.Y + 0.1))
                                {
                                    p.OnDamage(1);
                                }
                            }
                        }
                    } break;
            }
            emitter.Update();
            return base.Update();
        }
예제 #6
0
        public void Update()
        {
            p = GameManager.State.FindObject<Player>();
            Upgrades();
            location = new Vector2(Screen.Width/2,Screen.Height/2);
            Screen.RelationToPosition(location);
            overlay = new Rectangle(0,0 , (int)Screen.Width,(int)Screen.Height);
            overlay.Inflate(5, 5);
            KeyboardState state = Keyboard.GetState();
            // keyboard input for selecting upgrade
                if (state.IsKeyDown(Keys.W))
                {
                    selected[current] = false;
                    selected[1] = true;
                    current = 1;

                }
                else if (state.IsKeyDown(Keys.D))
                {
                    selected[current] = false;
                    selected[2] = true;
                    current = 2;
                }
                else if (state.IsKeyDown(Keys.S))
                {
                    selected[current] = false;
                    selected[3] = true;
                    current = 3;
                }
                else if (state.IsKeyDown(Keys.A))
                {
                    selected[current] = false;
                    selected[0] = true;
                    current = 0;
                }
                if (state.IsKeyUp(Keys.Enter)&&oldState.IsKeyDown(Keys.Enter))
                    ConfirmUpg();

            if(state.IsKeyDown(Keys.Back))
            {
                Time.GameSpeed = 1;
                GameManager.Navigate(new MainMenuState());
            }
                oldState = state;
        }