Beispiel #1
0
 private void Start()
 {
     winLabel.SetActive(false);
     loseLabel.SetActive(false);
     myAudioSource = GetComponent <AudioSource>();
     livesDisplay  = FindObjectOfType <LivesDisplay>();
 }
Beispiel #2
0
    private void OnEnable()
    {
        var levelController = FindObjectOfType <LevelController>();

        star2        = GameObject.Find("Star 2");
        star3        = GameObject.Find("Star 3");
        livesDisplay = FindObjectOfType <LivesDisplay>();
        if (star2 == null || star3 == null || livesDisplay == null)
        {
            Debug.LogWarning("Star 2, Star 3 or LivesDisplay is null, can't properly display stars at end level");
            return;
        }
        if (livesDisplay.LivesLostRatio() < 0.5)
        {
            star2.GetComponent <Image>().color = new Color32(63, 63, 63, 200);
            star3.GetComponent <Image>().color = new Color32(63, 63, 63, 200);
            PlayerPrefsManager.SaveStarsForLevel(levelController.GetGameLevel(), 1);
        }
        else if (livesDisplay.LivesLostRatio() < 1)
        {
            star2.GetComponent <Image>().color = Color.white;
            star3.GetComponent <Image>().color = new Color32(63, 63, 63, 200);
            PlayerPrefsManager.SaveStarsForLevel(levelController.GetGameLevel(), 2);
        }
        else
        {
            PlayerPrefsManager.SaveStarsForLevel(levelController.GetGameLevel(), 3);
        }
    }
Beispiel #3
0
    private void Awake()
    {
        gameOverText = FindObjectOfType <GameOver>();
        if (gameOverText == null)
        {
            Debug.LogError("GameOverText is NULL");
        }
        else
        {
            gameOverText.enabled = false;
        }

        livesDisplay = FindObjectOfType <LivesDisplay>();
        if (livesDisplay == null)
        {
            Debug.LogError("LivesDisplay is NULL");
        }

        if (scoreText == null)
        {
            Debug.LogError("Score Text is NULL!");
        }
        else
        {
            scoreText.text = "Score: 0";
        }
    }
Beispiel #4
0
 public static void addLife()
 {
     if (lives < 3)
     {
         lives++;
         LivesDisplay.livesUpdate(lives);
     }
 }
Beispiel #5
0
    private void Awake()
    {
        _livesDisplay = FindObjectOfType <LivesDisplay>();

        if (_livesDisplay == null)
        {
            throw new Exception($"No LivesDisplayObject on {SceneManager.GetActiveScene().name} scene");
        }
    }
Beispiel #6
0
    private void Awake()
    {
        instance = this;

        livesEmitter = new List <GameObject>
        {
            lifeDisplay0, lifeDisplay1, lifeDisplay2, lifeDisplay3, lifeDisplay4, lifeDisplay5, lifeDisplay6, lifeDisplay7, lifeDisplay8, lifeDisplay9
        };
    }
Beispiel #7
0
    private void Start()
    {
        originalPos = transform.position;
        LivesLeft   = startingLives;

        livesDisplay = FindObjectOfType <LivesDisplay>();

        audioSource = GetComponent <AudioSource>();
    }
Beispiel #8
0
    // Use this for initialization
    void Start()
    {
        livesDisplay = GameObject.Find("Lives").GetComponent <LivesDisplay> ();
        float   distance  = transform.position.z - Camera.main.transform.position.z;
        Vector3 leftmost  = Camera.main.ViewportToWorldPoint(new Vector3(0, 0, distance));
        Vector3 rightmost = Camera.main.ViewportToWorldPoint(new Vector3(1, 0, distance));

        xmin = leftmost.x;
        xmax = rightmost.x;
    }
 public void UpdateLives()
 {
     if (livesDisplay != null && playerLives >= 1)
     {
         livesDisplay.GetComponent <Text>().text = ":" + playerLives.ToString();
     }
     else
     {
         livesDisplay = null;
     }
 }
Beispiel #10
0
 private void Form1_Load(object sender, EventArgs e)
 {
     Player.Load("Cannon.png");
     Target.Load("Target.png");
     Projectile.Load("Projectile.png");
     LivesDisplay.Load("Lives.png");
     TitleScreen.Load("Title_Screen.png");
     TitleScreen.Left   = 0;
     TitleScreen.Top    = 0;
     TitleScreen.Width  = SCREEN_WIDTH;
     TitleScreen.Height = SCREEN_HEIGHT;
 }
Beispiel #11
0
 private void Form1_Load(object sender, EventArgs e)
 {
     Player.Load("player.png");
     Projectile.Load("projectile.png");
     Enemy.Load("target.png");
     LivesDisplay.Load("lives.png");
     TitleScreen.Load("title_screen.png");
     TitleScreen.Left   = 0;
     TitleScreen.Top    = 0;
     TitleScreen.Width  = SCREENWIDTH;
     TitleScreen.Height = SCREENHEIGHT;
 }
Beispiel #12
0
    // Use this for initialization
    void Start()
    {
        saveHealth   = health;
        livesDisplay = FindObjectOfType <LivesDisplay>();

        float multiplier = (float)Screen.width / (float)Screen.height * 9f / 16f;

        xMax *= multiplier;
        xMin *= multiplier;
        Vector3 s = GetComponent <SpriteRenderer>().transform.localScale;

        GetComponent <SpriteRenderer>().transform.localScale = new Vector3(s.x * multiplier, s.y, s.z);
    }
    void Start()
    {
        lives = startingLives;
        shake = Camera.main.GetComponent <CameraShake>();

        rb       = GetComponent <Rigidbody2D>();
        audioSrc = GetComponent <AudioSource>();

        livesDisplay = FindObjectOfType <LivesDisplay>();
        msgDisplayer = FindObjectOfType <MessageDisplayer>();
        if (!livesDisplay)
        {
            throw new UnityException("Can't find livesDisplay");
        }
        livesDisplay.DisplayLives(lives);
    }
    private void Start()
    {
        lives = FindObjectOfType <LivesDisplay>();

        attackerSpawners = FindObjectsOfType <AttackerSpawner>();

        levelLoader = GetComponent <LevelLoader>();

        audioSource = GetComponent <AudioSource>();

        soundEffectAudioSources = FindObjectsOfType <SoundEffects>();

        winBanner.SetActive(false);
        loseBanner.SetActive(false);

        pauseMenu.SetActive(false);
    }
 // Start is called before the first frame update
 void Start()
 {
     StopSpawners();
     gameStartDelaySeconds += PlayerPrefsManager.Prep;
     timer              = FindObjectOfType <GameTimer>();
     lives              = FindObjectOfType <LivesDisplay>();
     AttackerCount      = 0;
     levelTimerFinished = false;
     winCanvas.SetActive(false);
     loseCanvas.SetActive(false);
     pauseCanvas.SetActive(false);
     winInitiated               = false;
     gameStartInitiated         = false;
     TriggeredLevelLose         = false;
     TriggeredLevelWin          = false;
     DeleteMercenaryModeEnabled = false;
 }
Beispiel #16
0
 void OnTriggerEnter2D(Collider2D collider)
 {
     if (collider.tag == "Death Object")
     {
         if (lives <= 1)
         {
             SceneManager.LoadScene("GameOverScreen");
             lives = 3;
             LivesDisplay.livesUpdate(lives);
         }
         else
         {
             player.position = startPosition;
             lives--;
             LivesDisplay.livesUpdate(lives);
         }
     }
 }
Beispiel #17
0
 // Use this for initialization
 void Start()
 {
     floor = 3;
     if (!livesDisplay)
     {
         livesDisplay = GameObject.Find("Lives").GetComponent <LivesDisplay>();
     }
     if (!lifeLost)
     {
         lifeLost = GameObject.Find("LifeLost");
     }
     if (!epowerDisplay)
     {
         epowerDisplay = GameObject.Find("EPower");
     }
     epowerSlider = epowerDisplay.GetComponent <Slider>();
     epower       = epowerMax;
     lifeLost.SetActive(false);
     origPos     = transform.position;
     gm          = GameObject.Find("GameManager").GetComponent <GameManager>();
     rb          = GetComponent <Rigidbody2D>();
     rend        = GetComponent <SpriteRenderer>();
     audioSource = GetComponent <AudioSource>();
 }
Beispiel #18
0
 void Start()
 {
     livesDisplay = GameObject.FindObjectOfType <LivesDisplay>();
     levelManager = GameObject.FindObjectOfType <LevelManager>();
 }
 void Start()
 {
     livesDisplay = FindObjectOfType <LivesDisplay>();
     UpdateLives();
 }
Beispiel #20
0
    // Use this for initialization
    void Start()
    {
        score = 0;

        if (!player)
        {
            player = GameObject.Find("Player");
        }
        playerScript = player.GetComponent <Player>();

        if (!introScreen)
        {
            introScreen = GameObject.Find("IntroScreen");
        }
        if (!tutorialScreen)
        {
            tutorialScreen = GameObject.Find("TutorialScreen");
        }
        if (!gameScreen)
        {
            gameScreen = GameObject.Find("GameScreen");
        }
        if (!levelTransitionScreen)
        {
            levelTransitionScreen = GameObject.Find("LevelTransitionScreen");
        }
        if (!gameOverScreen)
        {
            gameOverScreen = GameObject.Find("GameOverScreen");
        }

        if (!setupPanel)
        {
            setupPanel = GameObject.Find("SetupPanel");
        }

        if (!tm)
        {
            tm = GameObject.Find("TrapManager").GetComponent <TrapManager>();
        }
        if (!kidSpawner)
        {
            kidSpawner = GameObject.Find("KidSpawner").GetComponent <KidSpawner>();
        }
        if (!timeSlider)
        {
            timeSlider = GameObject.Find("TimeSlider").GetComponent <Slider>();
        }
        timeSlider.value = 1;
        modeText         = timeSlider.GetComponentInChildren <Text>();
        if (!levelText)
        {
            levelText = GameObject.Find("LevelText").GetComponent <Text>();
        }
        if (!scoreText)
        {
            scoreText = GameObject.Find("ScoreText").GetComponent <Text>();
        }
        if (!middleText)
        {
            middleText = GameObject.Find("MiddleText").GetComponent <Text>();
        }

        if (!livesDisplay)
        {
            livesDisplay = GameObject.Find("Lives").GetComponent <LivesDisplay>();
        }

        gameScreen.SetActive(true);

        floor2_y = GameObject.Find("Floor2").transform.position.y - 1.5f;
        floor3_y = GameObject.Find("Floor3").transform.position.y - 1.5f;

        string[] trapTriggerNames = new string[] { "11", "12", "13", "21", "22", "23", "31", "32", "33" };
        trapTriggers = new List <TrapTrigger>();
        foreach (string s in trapTriggerNames)
        {
            trapTriggers.Add(GameObject.Find(s).GetComponent <TrapTrigger>());
        }

        introScreen.SetActive(false);
        gameScreen.SetActive(false);
        levelTransitionScreen.SetActive(false);
        gameOverScreen.SetActive(false);

        levelTimer = setupTimerMax;
    }
 private void Awake()
 {
     instance = this;
 }
Beispiel #22
0
 private void Start()
 {
     livesDisplay = FindObjectOfType <LivesDisplay>();
     levelManager = FindObjectOfType <LevelManager>();
 }
Beispiel #23
0
 private void Start()
 {
     winPanel.SetActive(false);
     losePanel.SetActive(false);
     lives = FindObjectOfType <LivesDisplay>();
 }
Beispiel #24
0
 private void Start()
 {
     livesDisplay = FindObjectOfType <LivesDisplay>();
 }
 private void Awake()
 {
     ld = FindObjectOfType <LivesDisplay>();
 }
Beispiel #26
0
    private void Start()
    {
        livesDisplay = FindObjectOfType <LivesDisplay>();

        audioSource = GetComponent <AudioSource>();
    }