Update() private method

private Update ( ) : void
return void
Esempio n. 1
0
        public void Update(float ms)
        {
            UpdateAliens(ms);

            UpdateWeaponDepots(ms);
            if (currentSection < sections.Count - 1)
            {
                if (sections[currentSection].GetAlienCount() == 0)
                {
                    sections[currentSection].Open();
                    currentSection += 1;
                    sections[currentSection].FillWithAliens();

                    // respawn
                    if (Globals.gameInstance.players.Length > 1)
                    {
                        if (!Globals.gameInstance.players[0].alive)
                        {
                            Globals.gameInstance.players[0].Respawn(Globals.gameInstance.players[1].Position);
                        }
                        else if (!Globals.gameInstance.players[1].alive)
                        {
                            Globals.gameInstance.players[1].Respawn(Globals.gameInstance.players[0].Position);
                        }
                    }
                }
            }
            else
            {
                // check if players are both on the portal
                bool allOnPortal = true;
                for (int i = 0; i < Globals.gameInstance.players.Length; i++)
                {
                    if (Vector3.DistanceSquared(endteleporter.Position, Globals.gameInstance.players[i].Position) > 1.5f)
                    {
                        allOnPortal = false;
                        break;
                    }
                }

                if (allOnPortal && !endteleporter.Started && !endteleporter.Finished)
                {
                    endteleporter.Start();
                }
                endteleporter.Update(ms);

                if (endteleporter.Progress > 30)
                {
                    // win
                    //Globals.gameInstance.parentLayer.
                    GameLayer game = (GameLayer)Globals.screenManager.GetTop();
                    game.fadeOutCompleteCallback = win;
                    game.StartTransitionOff();
                }
            }

            UpdateDoors(ms);
        }