void Start()
 {
     LevelNumber.setSkipIntro(true);     //main menu intro should no longer be played when returning to it
     ftlJump = GameObject.FindGameObjectWithTag("StarList").GetComponent <FTLJump>();
     ftlJump.stopAllStars();
     blackPanel.gameObject.GetComponent <Image>().enabled = true;
     if (LevelNumber.getLoadedFromMenu())
     {
         blackPanel.setColors(new Color(0, 0, 0, 1), new Color(0, 0, 0, 0));
         preventPauseTimer = 2.5f;
     }
     else
     {
         blackPanel.setColors(new Color(0, 0, 0, 0), new Color(0, 0, 0, 0));
         try
         {
             chargeBar.setProgress(0);
             chargeText.setPercent(0);
         } catch
         {
         }
     }
     blackPanel.startColorChange();
     LevelNumber.setLoadedFromMenu(false);
     shipAudio.clip = shipHit;
     highScores     = getHighScores();
     bombCooldown   = setBombCooldown;
 }
Esempio n. 2
0
        //############################################################################################
        //############################################################################################
        public static Boss CreateBoss(LevelNumber levelNum)
        {
            //The boss to return
            Boss b = new Boss(Textures.TextureName.ShipBoss1);

            switch (levelNum)
            {
                case LevelNumber.One:
                    b = new Boss(Textures.TextureName.ShipBoss1);
                    b.LoadContent();
                    b.name = "Boss #1";
                    //Positioning
                    //b.SetRotation(newDirection);
                    //b.MoveTo(position);
                    //Properties and behaviors
                    //b.moveMethod = new MM();
                    b.fireMethod = new FMSInterval(100, 1000);
                    b.speed = 0.1f;
                    b.points = 22;
                    b.health = 6;
                    //Weapons
                    b.AddWeaponPort(new Vector2(13, 5));
                    b.AddWeaponPort(new Vector2(-13, 5));
                    b.AddWeapon(CreateWeapon(WeaponType.TripleCanon));
                    b.AddWeapon(CreateWeapon(WeaponType.TripleCanon));
                    break;

            }

            return b;
        }
Esempio n. 3
0
        //############################################################################################
        //############################################################################################

        public static Boss CreateBoss(LevelNumber levelNum)
        {
            //The boss to return
            Boss b = new Boss(Textures.TextureName.ShipBoss1);

            switch (levelNum)
            {
            case LevelNumber.One:
                b = new Boss(Textures.TextureName.ShipBoss1);
                b.LoadContent();
                b.name = "Boss #1";
                //Positioning
                //b.SetRotation(newDirection);
                //b.MoveTo(position);
                //Properties and behaviors
                //b.moveMethod = new MM();
                b.fireMethod = new FMSInterval(100, 1000);
                b.speed      = 0.1f;
                b.points     = 22;
                b.health     = 6;
                //Weapons
                b.AddWeaponPort(new Vector2(13, 5));
                b.AddWeaponPort(new Vector2(-13, 5));
                b.AddWeapon(CreateWeapon(WeaponType.TripleCanon));
                b.AddWeapon(CreateWeapon(WeaponType.TripleCanon));
                break;
            }

            return(b);
        }
Esempio n. 4
0
 public bool correctChoice(LevelNumber levelNumber, int leftAnswer, int rightAnswer)
 {
     if (leftAnswer + rightAnswer == levelNumber.Sum)
     {
         return(true);
     }
     return(false);
 }
Esempio n. 5
0
 private void RestartGame(LevelNumber level)
 {
     this._lifetimeScope.Dispose();
     this._container.Dispose();
     this._container     = ContainerConfig.Configure();
     this._lifetimeScope = this._container.BeginLifetimeScope();
     this._game          = this._lifetimeScope.Resolve <IGame>();
     this._game.StartLevel(level);
 }
    public IEnumerator loadNextLevel()
    {
        GameObject.Find("BlackPanel1").GetComponent <GraphicColorLerp>().startColorChange();
        LevelNumber.setSkipIntro(false);
        yield return(new WaitForSeconds(1.5f));

        LevelNumber.setLevel(levelNum + 1);
        SceneManager.LoadScene("Campaign");
    }
Esempio n. 7
0
    public int CompareTo(LevelData other)
    {
        if (other == null)
        {
            return(1);
        }

        return(LevelNumber.CompareTo(other.LevelNumber));
    }
    private IEnumerator loadLevel()
    {
        levelTransition = true;
        LevelNumber.setLevel(levelIndex);
        blackPanel.gameObject.GetComponent <Image>().enabled = true;
        blackPanel.startColorChange();
        yield return(new WaitForSeconds(1.5f));

        SceneManager.LoadScene("Campaign");
    }
 void Start()
 {
     text      = GetComponent <Text>();
     text.text = "Level " + (LevelNumber.getLevel() + 1);
     colorLerp = GetComponent <GraphicColorLerp>();
     if (!LoadedFromMenu)
     {
         StartCoroutine(displayText(1.5f));
     }
 }
 public void mainMenuButton()
 {
     Time.timeScale = 1;     //in case of returning to main menu from pause screen
     LevelNumber.setLoadedFromMenu(true);
     eventSystem.SetSelectedGameObject(null);
     StartCoroutine(transitionIntoSceneLoad(0.5f, "MainMenu"));
     if (survival)
     {
         setHighScore(points);
     }
 }
Esempio n. 11
0
        public void LoadLevel(LevelNumber number)
        {
            //unload old level
            levels[activeLevel].Unload();

            //change active level
            activeLevel = (int)number;

            levels[activeLevel].Load(Textures.TextureName.Level01Background);

            state = GameState.Intro;
        }
Esempio n. 12
0
    void Start()
    {
        if (levelNumber == null)
        {
            levelNumber = GetComponent <LevelNumber>();
        }
        if (levelNumberText == null)
        {
            levelNumberText = transform.Find(defaultLevelNumberObjectName).GetComponent <Text>();
        }

        levelNumberText.text = levelNumber.LevelNum.ToString();
    }
Esempio n. 13
0
    // Use this for initialization
    void Start()
    {
        if (button == null)
        {
            button = GetComponent <Button>();
        }
        if (levelNumber == null)
        {
            levelNumber = GetComponent <LevelNumber>();
        }

        button.onClick.AddListener((UnityAction)(() => GameObject.FindObjectOfType <GoToSceneButtonHandler>().OnClick(string.Format(levelNamePattern, levelNumber.LevelNum))));
    }
Esempio n. 14
0
        public void Build(
            LevelNumber levelNumber,
            IMap map,
            IToolset toolset)
        {
            Condition.Requires(map, nameof(map)).IsNotNull();
            Condition.Requires(toolset, nameof(toolset)).IsNotNull();

            var level = _levels[levelNumber];

            level.FillMap(map);
            level.FillToolset(toolset);
        }
Esempio n. 15
0
        public GameViewModel()
        {
            ReadyCommand        = new Command(ReadyCommandExcute);
            BackCommand         = new Command(BackCommandExcute);
            RestartCommand      = new Command(RestartCommandExcute);
            LaunchCommand       = new Command(LaunchCommandExcute);
            PlayCommand         = new Command(PlayCommandExcute);
            TimeDifferencesList = new List <double>();
            stopwatch           = new Stopwatch();

            DrawLevels();
            MessagingCenter.Subscribe <NextPopupViewModel>(this, "nextLevel", (sender) =>
            {
                JumpButtonText            = "Hold";
                JumpButtonBackgroundColor = Color.FromHex("#E8A24F");
                JumpButtonBorderColor     = Color.FromHex("#4F3824");
                LevelNumber  = Preferences.Get("levelNumber", 1) + 1;
                LevelTime   += 1;
                LaunchText   = "Hold for " + LevelTime + " seconds and release to launch parachute";
                IsRestarting = true;
                foreach (var item in DotsList)
                {
                    if (item.LevelNumber == LevelNumber.ToString())
                    {
                        item.IsCompleted     = true;
                        item.BackgroundColor = Color.FromHex("#C5C5C5");
                    }
                }
            });
            MessagingCenter.Subscribe <RestartPopupViewModel>(this, "restartGame", (sender) =>
            {
                LevelNumber = 1;
                CheckLevelTime();
                IsRestarting = false;
                DrawLevels();
            });
            MessagingCenter.Subscribe <LoseViewModel>(this, "tryAgain", (sender) =>
            {
                JumpButtonText            = "Hold";
                JumpButtonBackgroundColor = Color.FromHex("#E8A24F");
                JumpButtonBorderColor     = Color.FromHex("#4F3824");
                LaunchText = "Hold for " + LevelTime + " seconds and release to launch parachute";
            });
            //this part for check level and add level time according to choosen difficulity
            CheckLevelTime();
            PageTitle = "GamePage";
            Analytics.TrackEvent("Page", new Dictionary <string, string> {
                { "Value", PageTitle }
            });
            CheckMusicIsPlaying();
        }
Esempio n. 16
0
    void Start()
    {
        if (image == null)
        {
            image = GetComponent <Image>();
        }
        if (levelNumber == null)
        {
            levelNumber = GetComponent <LevelNumber>();
        }

        var levelImagePath = string.Format(levelImagePathTemplate, levelNumber.LevelNum);
        var sprite         = Resources.Load <Sprite>(levelImagePath);

        image.sprite = sprite;
    }
Esempio n. 17
0
    public override void BePickUp(Player player)
    {
        base.BePickUp(player);
        player.PickUp(ProjectileType.Text, _Color.orgin);
        player.conveyObject.GetComponent <TextMesh>().text = text;
        LevelNumber levelNumber = GetComponent <LevelNumber>();

        if (levelNumber)
        {
            LevelNumber target = player.conveyObject.GetComponent <LevelNumber>();
            target.levelNumber    = levelNumber.levelNumber;
            target.targetLocation = levelNumber.targetLocation;
        }
        if (decoration != null)
        {
            decoration.parent = transform.parent;
        }
        Destroy(gameObject);
    }
Esempio n. 18
0
        private void CheckLevelTime()
        {
            var x = Preferences.Get("levelNumber", 1);

            if ((Preferences.Get("levelNumber", 1) == 1))
            {
                LevelNumber  = 1;
                IsRestarting = (LevelNumber == 1) ? false : true;
                var difficulitylevel = Preferences.Get("difficulty", Difficulty.Easy.ToString());
                if (difficulitylevel == (Difficulty.Easy.ToString()))
                {
                    LevelTime = 5;
                }
                else if (difficulitylevel == Difficulty.Medium.ToString())
                {
                    LevelTime = 10;
                }
                else
                {
                    LevelTime = 15;
                }
            }
            else
            {
                LevelNumber = 1;
                LevelTime   = 5;
            }
            JumpButtonText            = "Hold";
            JumpButtonBackgroundColor = Color.FromHex("#E8A24F");
            JumpButtonBorderColor     = Color.FromHex("#4F3824");
            LaunchText = "Hold for " + LevelTime + " seconds and release to launch parachute";
            foreach (var item in DotsList)
            {
                if (item.LevelNumber == LevelNumber.ToString())
                {
                    item.IsCompleted     = true;
                    item.BackgroundColor = Color.FromHex("#C5C5C5");
                }
            }
        }
Esempio n. 19
0
    // Use this for initialization
    void Start()
    {
        menusArray       = new GameObject[Enum.GetNames(typeof(menus)).Length];
        levelSelection   = GameObject.Find("LevelSelection");
        pauseMenu        = GameObject.Find("PauseMenu");
        packSelection    = GameObject.Find("LevelPackScroll");
        ingameUI         = GameObject.Find("IngameUI");
        backgroundBlocks = GameObject.Find("Background Blocks");
        number           = GameObject.Find("LevelNumber").GetComponent <LevelNumber>();
        packName         = GameObject.Find("LevelPackName").GetComponent <LevelPackName>();


        menusArray [(int)menus.levelSelect]      = levelSelection;
        menusArray [(int)menus.pauseMenu]        = pauseMenu;
        menusArray [(int)menus.packMenu]         = packSelection;
        menusArray[(int)menus.ingameUI]          = ingameUI;
        menusArray [(int)menus.backgroundBlocks] = backgroundBlocks;

        if (menusArray [(int)menus.levelSelect] == null)
        {
            print("Unable to find level selection");
        }
        if (menusArray [(int)menus.pauseMenu] == null)
        {
            print("Unable to find pause menu");
        }
        if (menusArray [(int)menus.packMenu] == null)
        {
            print("Unable to find pack selection");
        }
        if (menusArray [(int)menus.backgroundBlocks] == null)
        {
            print("Unable to find background blocks");
        }
        else
        {
            menusArray [(int)menus.pauseMenu].SetActive(false);
        }
    }
    void Awake()
    {
        maxHealth    = health;
        settingsList = getSettings();
        blackPanel   = GameObject.Find("BlackPanel").GetComponent <GraphicColorLerp>();

        if (!survival)
        {
            levelNum = LevelNumber.getLevel();
        }
        setLevelSettings(levelNum);
        currentSettings       = settingsList[levelNum].GetComponentInChildren <GameSettings>();
        timeRemaining         = currentSettings.levelDuration;
        totalDuration         = timeRemaining;
        points                = 0;
        lowHealthText.enabled = false;
        bombs       = currentSettings.startingBombs;
        gameState   = GameState.beforeGame;
        eventSystem = GameObject.Find("EventSystem").GetComponent <EventSystem>();
        if (hideMouse)
        {
            Cursor.visible = false;
        }
    }
Esempio n. 21
0
 void Start()
 {
     musicSource.clip      = menuMusic;
     skipIntro             = LevelNumber.getSkipIntro();
     blackPanel            = GameObject.Find("BlackPanel1").GetComponent <GraphicColorLerp>();
     levelSelectController = levelSelectCanvas.GetComponent <LevelSelectController>();
     mainCanvas.SetActive(false);
     levelSelectCanvas.SetActive(false);
     creditsCanvas.SetActive(false);
     if (skipIntro)
     {
         setMenuState((int)MenuState.main);
         GameObject.Find("MenuStarList").GetComponent <FTLJumpWithImage>().stopAllStars();
         LevelNumber.setSkipIntro(false);
     }
     else
     {
         setMenuState((int)MenuState.intro);
     }
     if (hideMouse)
     {
         Cursor.visible = false;
     }
 }
Esempio n. 22
0
 public void CheckHeroCollisions()
 {
     for (int i = 0; i < Masks.Count; i++)
     {
         if (Hero.CheckMask(Masks[i]))
         {
             Masks.Remove(Masks[i]);
         }
     }
     for (int i = 0; i < Disinfectants.Count; i++)
     {
         if (Hero.CheckDisinfectant(Disinfectants[i]))
         {
             Disinfectants.Remove(Disinfectants[i]);
             ++Points;
         }
     }
     if (!Hero.IsMasked)
     {
         for (int i = 0; i < SickPersons.Count; i++)
         {
             if (Hero.CheckSickPerson(SickPersons[i]))
             {
                 SickPersons.Remove(SickPersons[i]);
                 ChangeHearts();
             }
             if (Hero.Lives == 0)
             {
                 IsEnabled = false;
                 CustomMessageBox cmb = new CustomMessageBox();
                 cmb.SetMessage("You lost all your lives. Game over!");
                 cmb.SetRetryButton(true);
                 cmb.Show();
                 break;
             }
         }
     }
     if (Hero.CheckDarkness(Darkness))
     {
         IsEnabled = false;
         CustomMessageBox cmb = new CustomMessageBox();
         cmb.SetMessage("The darkness caught you. Game over!");
         cmb.SetRetryButton(true);
         cmb.Show();
     }
     if (Goal.IsEnabled && Hero.CheckGoal(Goal))
     {
         IsEnabled = false;
         ++Game.CurrentLevel;
         if (LevelNumber < 5)
         {
             CustomMessageBox cmb = new CustomMessageBox();
             cmb.SetMessage(string.Format("Level {0} finished. Good job!", LevelNumber.ToString()));
             cmb.SetRetryButton(false);
             cmb.Show();
         }
         else
         {
             CustomMessageBox cmb = new CustomMessageBox();
             cmb.SetMessage("Game finished. Congratulations!");
             cmb.SetRetryButton(false);
             cmb.Show();
         }
     }
     if (!Goal.IsEnabled && Points >= RequiredPoints)
     {
         Goal.Enable();
     }
 }
Esempio n. 23
0
 private void PlayBgm(LevelNumber levelNumber)
 {
     switch (levelNumber)
     {
         case LevelNumber.One:
             {
                 if (playBGM)
                 {
                     bgmInstance = bgm01.CreateInstance();
                     bgmInstance.IsLooped = true;
                     bgmInstance.Play();
                 }
             }
             break;
         case LevelNumber.Two:
             {
                 if (playBGM)
                 {
                     bgmInstance = bgm02.CreateInstance();
                     bgmInstance.IsLooped = true;
                     bgmInstance.Play();
                 }
             }
             break;
     }
 }
Esempio n. 24
0
        private void Parse(string content)
        {
            if (string.IsNullOrEmpty(content))
            {
                return;
            }

            foreach (string line in content.Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries))
            {
                if (line.Contains("="))
                {
                    string[] values = line.Split('=');

                    if (values.Length < 2)
                    {
                        continue;
                    }

                    if (values[0] == "completed")
                    {
                        Completed = int.Parse(values[1]) == 1;
                    }

                    if (values[0] == "date")
                    {
                        SavedAt = DateTime.Now;
                        if (int.TryParse(values[1], out var unix))
                        {
                            SavedAt = DateTimeOffset.FromUnixTimeSeconds(unix).LocalDateTime;
                        }

                        // For folder name
                        DateTimeSafe = SavedAt.ToString("yyyy-MM-dd HH.mm.ss");

                        // For list view
                        DateTimeString = SavedAt.ToString("yyyy-MM-dd HH:mm:ss");
                    }

                    if (values[0] == "difficulty")
                    {
                        Difficulty = int.Parse(values[1]);
                        DiffToString(Difficulty);
                    }

                    if (values[0] == "mapDesc")
                    {
                        MapDesc = values[1];
                    }

                    if (values[0] == "mapName")
                    {
                        MapName = values[1];
                    }

                    if (values[0] == "time")
                    {
                        PlayedTime = new TimeSpan(0, 0, int.Parse(values[1]));
                    }
                }
            }

            if (MapDesc != "")
            {
                MapSafe = MapDesc;
            }

            foreach (char invalidPathChar in System.IO.Path.GetInvalidPathChars())
            {
                MapSafe = MapSafe.Replace(invalidPathChar, ' ');
            }

            LevelNumber = MapComparer.MapNameToLevel(MapName);
            if (LevelNumber > 0)
            {
                MapSafe = LevelNumber.ToString().PadRight(2) + " - " + MapSafe;
            }
        }
Esempio n. 25
0
 //Contruction
 //should not contain very much stuff
 //since mostly the stuff is loaded during Load() function
 public Level(Rectangle bounds, LevelNumber fromEnum)
 {
     this.bounds = bounds;
     this.levelNumber = fromEnum;
 }
Esempio n. 26
0
 public void StartLevel(LevelNumber level)
 {
     this._levelBuilder.Build(level, _map, _toolset);
 }
    // Update is called once per frame
    void Update()
    {
        if (bombUsed)
        {
            bombCooldown -= Time.deltaTime;

            if (bombCooldown <= 0)
            {
                bombUsed     = false;
                bombCooldown = setBombCooldown;
            }
        }
        if (debug)
        {
            if (Input.GetKeyDown(KeyCode.L))
            {
                LevelNumber.setLevel(levelNum + 1);
                SceneManager.LoadScene("Campaign");
            }
            if (Input.GetKeyDown(KeyCode.K))
            {
                LevelNumber.setLevel(levelNum - 1);
                SceneManager.LoadScene("Campaign");
            }
        }
        switch (gameState)
        {
        case (GameState.beforeGame):
            runPreGame();      //level tutorial logic is in here.  Also handles levels without tutorials
            if (preventPauseTimer > 0)
            {
                preventPauseTimer -= Time.deltaTime;
            }
            else if (Input.GetKeyDown(KeyCode.Escape))
            {
                gameState = GameState.paused;
                pauseCanvas.SetActive(true);
                dangerPlaying = shipDangerAudio.isPlaying;
                if (dangerPlaying)
                {
                    shipDangerAudio.Pause();
                }
                eventSystem.SetSelectedGameObject(GameObject.Find("ResumeButton"));                                       //set default button
                GameObject.Find("ResumeButton").GetComponent <Button>().OnSelect(new BaseEventData(EventSystem.current)); //force highlight button
                Time.timeScale = 0;
            }
            break;

        case (GameState.duringGame):
            if (survival)
            {
                StartCoroutine(advanceDropTimer());
            }
            if (timeRemaining > 0)
            {
                timeRemaining -= Time.deltaTime;
            }
            else
            {
                timeRemaining = 0f;             //Ensure values sent to progress bar
                                                //and progress text do not exceed 100%
            }
            if (preventPauseTimer > 1.5)        //survival has a shorter transition
            {
                preventPauseTimer -= Time.deltaTime;
            }
            else if (Input.GetKeyDown(KeyCode.Escape))
            {
                gameState = GameState.paused;
                pauseCanvas.SetActive(true);
                dangerPlaying = shipDangerAudio.isPlaying;
                if (dangerPlaying)
                {
                    shipDangerAudio.Pause();
                }
                eventSystem.SetSelectedGameObject(GameObject.Find("ResumeButton"));                                       //set default button
                GameObject.Find("ResumeButton").GetComponent <Button>().OnSelect(new BaseEventData(EventSystem.current)); //force highlight button
                Time.timeScale = 0;
            }
            if (chargeText != null)
            {
                chargeText.setPercent(1 - (timeRemaining / totalDuration));         //update progress bar
            }
            if (chargeBar != null)
            {
                chargeBar.setProgress(1 - (timeRemaining / totalDuration));         //update text in progress bar
            }
            if (pointsText != null)
            {
                pointsText.text = pointsAsString(points);                           //display points
            }
            if (multiplierText != null)
            {
                multiplierText.text  = multiplier.ToString("n1") + " x";
                multiplierText.color = HelperFunctions.colorInterpolation(Color.red, Color.white, (multiplier - 1) / 9);
            }
            if ((Input.GetKeyDown(KeyCode.LeftShift) || Input.GetKeyDown(KeyCode.RightShift)) && !bombUsed)
            {
                dropBomb();
            }
            if (playerIsDead)
            {
                HelperFunctions.playSound(ref shipAudio, shipDeath);

                lowHealthText.enabled   = false;
                shipDangerAudio.enabled = false;
                gameIsOver = true;
                for (int i = 0; i < currentSettings.enabledUI.Length; i++)
                {
                    currentSettings.enabledUI[i].SetActive(false);
                }
                settingsList[levelNum].SetActive(false);                //turn off enemySpawner
                GameObject[] turrets = GameObject.FindGameObjectsWithTag("Turret");
                for (int i = 0; i < turrets.Length; i++)
                {
                    turrets[i].GetComponent <Turret>().inputDisabled = true;       //disable player input
                    turrets[i].GetComponent <Turret>().fadeTurret();               //fade turrets to transparent
                    turrets[i].transform.Find("TargettingLine").gameObject.SetActive(false);
                }
                GameObject ship = GameObject.FindWithTag("Player");
                ship.transform.Find("Ship").GetComponent <ColorLerp>().startColorChange();
                ship.GetComponent <ParticleSystem>().Play();
                Instantiate(Resources.Load("ClearExplosion"), ship.transform.position, Quaternion.identity);
                deathCanvas.SetActive(true);
                if (survival)
                {
                    gameState = GameState.survivalDeathState;                                                                  //change state to game over screen
                    eventSystem.SetSelectedGameObject(GameObject.Find("RestartButton"));
                    GameObject.Find("RestartButton").GetComponent <Button>().OnSelect(new BaseEventData(EventSystem.current)); //force highlight button
                    setHighScore(points);
                }
                else
                {
                    gameState = GameState.campaignDeathState;                                                                  //change state to campaign game over screen
                    eventSystem.SetSelectedGameObject(GameObject.Find("RestartButton"));
                    GameObject.Find("RestartButton").GetComponent <Button>().OnSelect(new BaseEventData(EventSystem.current)); //force highlight button
                }
            }

            if (!survival && timeRemaining <= 0)                        //survival game mode never leaves this state
            {
                lowHealthText.enabled   = false;
                shipDangerAudio.enabled = false;
                gameIsOver = true;
                for (int i = 0; i < currentSettings.enabledUI.Length; i++)
                {
                    currentSettings.enabledUI[i].SetActive(false);
                }
                chargeBar.setProgress(1);
                dropFTLBomb();                                          //kill all enemies
                settingsList[levelNum].SetActive(false);                //turn off enemySpawner
                jumpTimer = 0;                                          //set jump timer to zero for next state
                gameState = GameState.transition;                       //State Transition
                GameObject[] turrets = GameObject.FindGameObjectsWithTag("Turret");
                for (int i = 0; i < turrets.Length; i++)
                {
                    turrets[i].GetComponent <Turret>().inputDisabled = true;  //disable player input
                    turrets[i].GetComponent <Turret>().fadeTurret();          //fade turrets to transparent
                    turrets[i].transform.Find("TargettingLine").gameObject.SetActive(false);
                    //disable targetting lines
                }
            }
            break;

        case (GameState.transition):

            if (delayBeforeJump > 0)
            {
                delayBeforeJump -= Time.deltaTime;                      //delay before FTL jump
            }
            else
            {
                if (jumpTimer == 0)
                {
                    chargeText.enabled = false;                         //disable automatic color/text changes
                    chargeBar.enabled  = false;                         //disable automatic color/text changes
                    ftlJump.startAllStars();                            //start FTL jump
                    chargeText.GetComponent <Text>().text = "Jumping...";
                }
                if (jumpTimer < jumpDuration)
                {
                    jumpTimer += Time.deltaTime;
                    //Decrease progress bar during jump
                    if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.Space))
                    {
                        jumpTimer = jumpDuration;
                    }
                }
                else
                {
                    gameState = GameState.transitionOver;               //State Transition
                    levelCompletionCanvas.SetActive(true);
                    if (levelNum < 7)
                    {
                        eventSystem.SetSelectedGameObject(GameObject.Find("ContinueButton"));                                       //set default button
                        GameObject.Find("ContinueButton").GetComponent <Button>().OnSelect(new BaseEventData(EventSystem.current)); //force highlight button
                    }
                    else
                    {
                        eventSystem.SetSelectedGameObject(GameObject.Find("MainMenuButton"));                                       //set default button
                        GameObject.Find("ContinueButton").SetActive(false);
                        GameObject.Find("MainMenuButton").GetComponent <Button>().OnSelect(new BaseEventData(EventSystem.current)); //force highlight button
                        GameObject.Find("MainMenuButton").GetComponent <RectTransform>().anchorMin = new Vector2(0.3f, 0);
                        GameObject.Find("MainMenuButton").GetComponent <RectTransform>().anchorMax = new Vector2(0.7f, 0.5f);
                    }
                    if (levelNum >= settingsList.Count)
                    {
                        GameObject.Find("ContinueButton").GetComponent <Button>().interactable = false;         //if on last level, grey out continueButton
                    }
                }
            }

            break;

        case (GameState.transitionOver):

            //display GUI
            break;

        case (GameState.campaignDeathState):

            break;

        case (GameState.survivalDeathState):
            dropTimer = 0.0f;
            break;

        case (GameState.paused):
            GameObject[] turretList = GameObject.FindGameObjectsWithTag("Turret");
            for (int i = 0; i < turretList.Length; ++i)
            {
                turretList[i].GetComponent <Turret>().inputDisabled = true;
            }
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                resumeButton();
            }

            break;
        }
    }
 void Awake()
 {
     LoadedFromMenu = LevelNumber.getLoadedFromMenu();
 }
Esempio n. 29
0
 private void LoadBackground(LevelNumber levelNumber)
 {
     switch (levelNumber)
     {
         case LevelNumber.One:
             {
                 this.mBackground = new Background(4);
                 var background = MGame.Content.Load<Texture2D>("Sprites/Backgrounds/Background01");
                 mBackground.Load(MGame.GraphicsDevice, background);
             }
             break;
         case LevelNumber.Two:
             {
                 this.mBackground = new Background(1);
                 var background = MGame.Content.Load<Texture2D>("Sprites/Backgrounds/hauntedHouseBackground");
                 mBackground.Load(MGame.GraphicsDevice, background);
             }
             break;
     }
     WorldHeight = mBackground.WorldHeight;
     WorldWidth = mBackground.WorldWidth;
 }
Esempio n. 30
0
        private void LoadEnemySprites(LevelNumber levelNumber)
        {
            this.MGame.Engine.LoadEnemies();
            this.enemySprites = new List<EnemySprite>();
            var evilNinjaTexture = this.MGame.Content.Load<Texture2D>("Sprites/Enemies/evil_ninja");
            var evilMonkTexture = this.MGame.Content.Load<Texture2D>("Sprites/Enemies/evil_monk");
            var evilSamuraiTexture = this.MGame.Content.Load<Texture2D>("Sprites/Enemies/evil_samurai");
            var onryoTexture = this.MGame.Content.Load<Texture2D>("Sprites/Enemies/evil_onryo");
            var bossOniTexture = this.MGame.Content.Load<Texture2D>("Sprites/Enemies/Boss_Oni");
            var bossGoryoTexture = this.MGame.Content.Load<Texture2D>("Sprites/Enemies/Boss_Goryo");

            foreach (var enemy in this.MGame.Engine.Enemies)
            {
                if (enemy is NpcMage)
                {
                    if (levelNumber == LevelNumber.One)
                    {
                        this.enemySprites.Add(new EnemySprite(enemy, evilMonkTexture, this.animations, 48, 64, false));
                    }
                    else if (levelNumber == LevelNumber.Two)
                    {
                        this.enemySprites.Add(new EnemySprite(enemy, onryoTexture, this.animations, 48, 64, false));
                    }

                }
                else if (enemy is NpcRogue)
                {
                    this.enemySprites.Add(new EnemySprite(enemy, evilNinjaTexture, this.animations, 48, 64, false));
                }
                else if (enemy is NpcWarrior)
                {
                    this.enemySprites.Add(new EnemySprite(enemy, evilSamuraiTexture, this.animations, 48, 64, false));
                }
            }

            foreach (var enemy in this.MGame.Engine.Bosses)
            {
                if (enemy.Name == "Oni" && this.LevelNumber == LevelNumber.One)
                {
                    this.enemySprites.Add(new EnemySprite(enemy, bossOniTexture, this.bossAnimations, 74, 90, true));
                }
                if (enemy.Name == "Goryo" && this.LevelNumber == LevelNumber.Two)
                {
                    this.enemySprites.Add(new EnemySprite(enemy, bossGoryoTexture, this.bossAnimations, 74, 90, true));
                    break;
                }

            }

            foreach (var e in this.enemySprites)
            {
                //enemy health
                e.FillHealthTexture = new Texture2D(this.MGame.GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
                e.FillHealthTexture.SetData<Color>(new Color[] { Color.Red });
                e.CurrentHealthTexture = new Texture2D(this.MGame.GraphicsDevice, 1, 1, false,
                    SurfaceFormat.Color);
                e.CurrentHealthTexture.SetData<Color>(new Color[] { Color.GreenYellow });
            }
        }
Esempio n. 31
0
        private void LoadEnvironment(LevelNumber levelNumber)
        {
            switch (levelNumber)
            {
                case LevelNumber.One:
                    lme.LoadEnvironmentLevelOne(this, this.MGame);
                    break;
                case LevelNumber.Two:
                    lme.LoadEnvironmentLevelTwo(this, this.MGame);
                    break;
            }

            //add environment to the list of collisions
            this.CollisionRectangles.Clear();
            foreach (var s in environmentSprites)
            {
                if (s.collisionRectangle == Rectangle.Empty)
                {
                    s.SetCollisionRectangle();
                }
                CollisionRectangles.Add(s.collisionRectangle);
            }
        }
Esempio n. 32
0
 //Contruction
 //should not contain very much stuff
 //since mostly the stuff is loaded during Load() function
 public Level(Rectangle bounds, LevelNumber fromEnum)
 {
     this.bounds      = bounds;
     this.levelNumber = fromEnum;
 }
Esempio n. 33
0
 private void StartNextLevel(LevelNumber level)
 {
     this.bgmInstance.Dispose();
     this.MGame.Engine.NextLevel();
     this.LevelNumber = level;
     this.CollisionRectangles.Clear();
     this.environmentSprites.Clear();
     this.enemySprites.Clear();
     this.Interactables.Clear();
     //load new
     //this.LoadBackground();
     //this.LoadEnvironment();
     this.LoadContent();
 }
Esempio n. 34
0
        public void LoadLevel(LevelNumber number)
        {
            //unload old level
            levels[activeLevel].Unload();

            //change active level
            activeLevel = (int)number;

            levels[activeLevel].Load(Textures.TextureName.Level01Background);

            state = GameState.Intro;
        }