Beispiel #1
0
 void SetupLifeCounters(int n)
 {
     foreach (LifeCounter LifeCounter in lifeCounters)
     {
         LifeCounter.SetupLifeCounter(n);
     }
 }
Beispiel #2
0
    //private float step1;    //使われていない
    //float speed = 50;       //使われていない
    void Start()
    {
        lifeCounter = GameObject.Find("Lifes").GetComponent <LifeCounter>();

        n = Random.Range(0, 180);//(手裏剣最初のz)
        this.transform.Rotate(0f, 0f, n);
    }
Beispiel #3
0
 void OnCollisionEnter(Collision collision)
 {
     if (state != State.alive || colisionmode)
     {
         return;
     }
     if (collision.gameObject.tag == "Friendly")
     {
     }
     else if (collision.gameObject.tag == "Finish")
     {
         WinTrigger();
     }
     else
     {
         if (lifecount >= 1)
         {
             LifeCounter nc = new LifeCounter();
             nc.lifeamount--;
             reloadtrigger();
         }
         else
         {
             DeathTrigger();
         }
     }
 }
Beispiel #4
0
    //Coroutine function
    public IEnumerator RespawnPlayerCo()
    {
        //Generate Death Particle
        Instantiate(DeathParticle, Player.transform.position, Player.transform.rotation);
        //Hide Player
        //player.enabled = false;
        PC.SetActive(false);
        Player.GetComponent <Renderer> ().enabled = false;
        //Gravity Reset
        GravityStore = Player.GetComponent <Rigidbody2D> ().gravityScale;
        Player.GetComponent <Rigidbody2D>().gravityScale = 0f;
        Player.GetComponent <Rigidbody2D>().velocity     = Vector2.zero;
        //Point Penalty
        ScoreManager.AddPoints(-PointPenalty);
        //Life Penalty
        LifeCounter.AddLife(-LoseLife);
        //Debug Message
        Debug.Log("Player Respawn");
        //Respawn Delay
        yield return(new WaitForSeconds(RespawnDelay));

        //Gravity Restore
        Player.GetComponent <Rigidbody2D>().gravityScale = GravityStore;
        //Match Players transform position
        Player.transform.position = CurrentCheckPoint.transform.position;
        //Show Player
        //player.enabled = true;
        PC.SetActive(true);
        Player.GetComponent <Renderer> ().enabled = true;
        //Generate Spawn Particle
        Instantiate(RespawnParticle, CurrentCheckPoint.transform.position, CurrentCheckPoint.transform.rotation);
    }
Beispiel #5
0
 /// <summary>
 /// Gather and Set Necessary Components, GameObjects, Values, and States
 /// </summary>
 private void InitializePlayer()
 {
     // Components
     playerBody           = GetComponent <SpriteRenderer>();
     myRigidBody          = GetComponent <Rigidbody2D>();
     anim                 = GetComponent <Animator>();
     playerGroundCollider = GetComponent <CapsuleCollider2D>();
     playerRend           = GetComponent <Renderer>();
     playerColor          = playerBody.color;
     // Game Object References
     spawnPoint         = GameObject.Find("SpawnPoint");
     spawnPointLocation = spawnPoint.transform;
     lifeCounter        = FindObjectOfType <LifeCounter>();
     scoreCounter       = FindObjectOfType <ScoreCounter>();
     HealthMeter        = GameObject.Find("PlayerHealthMeter");
     HealthAnim         = HealthMeter.GetComponent <Animator>();
     whatIsGround       = LayerMask.GetMask("Ground");
     groundCheck        = gameObject.transform.GetChild(0); //Retrieves the transform component from the child named GroundCheck
     attackPoint        = gameObject.transform.GetChild(1); //Retrieves the transform component from the child named AttackPoint
     // Values
     PlayerHealth = fullHealth;
     // States
     attackPoint.gameObject.SetActive(false);
     allowMoveInput   = true;
     beingKnockedback = false;
     isDamagable      = true;
 }
Beispiel #6
0
    void Start()
    {
        //setup camera & borders
        cam = Camera.main;

        var vertExtent = cam.orthographicSize;
        var horzExtent = vertExtent * Screen.width / Screen.height;

        minX = -horzExtent;
        maxX = horzExtent;
        minY = -vertExtent;
        maxY = vertExtent;

        //gather components
        sprite        = GetComponent <SpriteRenderer>();
        sprite.sprite = normalSprite;
        lifeCounter   = GameObject.Find("Life Counter").GetComponent <LifeCounter>();

        //only controlled player is green, all others are blue
        if (!photonView.IsMine)
        {
            sprite.color = new Color(0, 0.5294117647f, 0.85882352941f);
        }

        //enable shooting
        InvokeRepeating("Fire", 0.0f, shotFrequency);
    }
Beispiel #7
0
    public void UpdateLife(int life, int maxLife)
    {
        if (life > maxLife)
        {
            //error
            return;
        }

        if (_lifeCounters.Count < maxLife)
        {
            for (int i = _lifeCounters.Count; i < maxLife; i++)
            {
                GameObject  go          = GameObject.Instantiate(_lifeCounterPrefab) as GameObject;
                LifeCounter lifeCounter = go.GetComponent <LifeCounter>();

                _lifeCounters.Add(lifeCounter);
                lifeCounter.transform.SetParent(_lifeCounterGrid.transform);
                go.transform.localScale = Vector3.one;
            }
        }

        for (int i = 0; i < life; i++)
        {
            _lifeCounters[i].ToggleFilledState(true);
        }
        for (int i = life; i < maxLife; i++)
        {
            _lifeCounters[i].ToggleFilledState(false);
        }
    }
 private void Start()
 {
     lifeCounter = GetComponent <LifeCounter>();
     if (!lifeCounter)
     {
         throw new MissingComponentException("Must have a LifeCounter component!");
     }
 }
Beispiel #9
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     text = GetComponent <Text>();
 }
 void Start()
 {
     Camera camera = Camera.main;
     float distance = transform.position.z - Camera.main.transform.position.z;
     xmin = camera.ViewportToWorldPoint(new Vector3(0,0,distance)).x + padding;
     xmax = camera.ViewportToWorldPoint(new Vector3(1,0,distance)).x - padding;
     lifeCounter = GameObject.Find("GameController").GetComponent<LifeCounter>(); //Agora acha o objeto "GameController", não o texto de vida
 }
Beispiel #11
0
    // Start is called before the first frame update
    void Start()
    {
        rigidbody   = GetComponent <Rigidbody>();
        audiosource = GetComponent <AudioSource>();
        LifeCounter nc = new LifeCounter();

        lifecount    -= nc.lifeamount;
        nc.lifeamount = lifecount;
    }
Beispiel #12
0
        public override void InitLevel()
        {
            SoundManager.Instance.ResetAudio();

            var game = GameManager.Instance;
            var save = GameManager.Instance.SaveData;

            // Disable transitions (except for the title card)
            if(GameOverScreen != null) GameOverScreen.gameObject.SetActive(false);
            if(TimeOverScreen != null) TimeOverScreen.gameObject.SetActive(false);
            if(ActClearScreen != null) ActClearScreen.gameObject.SetActive(false);
            
            // Spawn the player at the last checkpoint (or the spawn, if there is no checkpoint)
            if (string.IsNullOrEmpty(save.Checkpoint)) Checkpoint = Spawn.gameObject;
            else Checkpoint = GameObjectUtility.Find(save.Checkpoint);

            var player = Spawn.Spawn(game.CharacterData, Checkpoint);

            var checkpoint = Checkpoint.GetComponent<Checkpoint>();
            if(checkpoint != null) checkpoint.ActivateImmediate();

            // Add to the game's list of character objects
            game.ActiveCharacters.Add(game.CharacterData, player);
            Player = player.GetComponent<HedgehogController>();

            // Get all the player's counters
            ScoreCounter = player.GetComponent<ScoreCounter>();
            RingCounter = player.GetComponent<RingCounter>();
            LifeCounter = player.GetComponent<LifeCounter>();

            // Listen for death so we can do game over/time over sequences
            Health = player.GetComponent<HedgehogHealth>();
            if (Health != null) Health.OnDeath.AddListener(OnDeathBegin);

            // Get the save data into the components we just stored
            Lives = save.Lives;
            Score = save.Score;
            Rings = save.Rings;
            TimeSeconds = save.Time;

            // Set up the camera for the player and level boundaries
            Camera.Target = Player.transform;
            Camera.LevelBoundsMin = LevelBoundsMin;
            Camera.LevelBoundsMax = LevelBoundsMax;

            // Link with the HUD
            HudManager.Level = this;

            // Start the background music
            if (BGM) SoundManager.Instance.PlayBGM(BGM);
            
            // Done! save, show the title card, and start the level when it's done
            game.SaveProgress();
            ShowTitleCard(StartLevel);
        }
Beispiel #13
0
 void OnEnable()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
 }
    void OnTriggerEnter2D(Collider2D Other)
    {
        if (Other.GetComponent <Rigidbody2D>() == null)
        {
            return;
        }

        LifeCounter.AddLife(AddLife);

        Destroy(gameObject);
    }
Beispiel #15
0
    // Use this for initialization
    void Start()
    {
        lm = FindObjectOfType <LevelManager>();
        bm = FindObjectOfType <BossManager>();
        lc = FindObjectOfType <LifeCounter>();
        pc = FindObjectOfType <PlayerController>();
        sm = FindObjectOfType <ScoreManager>();
        pm = FindObjectOfType <PhoneManager>();

        SpawnFormation();
    }
    void Start()
    {
        // Used to determine boundaries for the game space where the player can move
        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 + padding;
        xmax = rightmost.x - padding;

        // Get LifeCounter so that we can inc/dec lives for certain events
        lifeCounter = GameObject.Find("Lives").GetComponent <LifeCounter>();
    }
Beispiel #17
0
 // This is where death management is taken care of
 public void LoseLife()
 {
     lives      -= 1;
     myText.text = string.Format("Lives: {0}", lives.ToString());
     if (lives >= 0)
     {
         StartCoroutine(RespawnPlayer());
     }
     else
     {
         LifeCounter.Reset();
         GameObject.Find("LevelManager").GetComponent <LevelManager>().LoadNextLevel();
     }
 }
Beispiel #18
0
    void Spawn()
    {
        LifeCounter mc = GetComponent <LifeCounter>();

        if (GameObject.Find("screenSpawn").GetComponent <LifeCounter> ().spawn) //will check if true
        {
            Vector3    SpawnPosition = new Vector3(Random.Range(xMin, xMax), Random.Range(yMin, yMax), Random.Range(zMin, zMax));
            GameObject meteor        = Instantiate(meteorPrefab, SpawnPosition, Quaternion.identity);

            meteorMovement mv = meteor.GetComponent <meteorMovement>();
            mv.target = GameObject.FindWithTag("Player").transform;
            mv.speed  = speed;
        }
    }
Beispiel #19
0
    // Use this for initialization
    void Start()
    {
        father = transform.parent.gameObject.GetComponent<Player>();
        gameController = GameObject.Find("!GameController").GetComponent<GameController>();
        dino = father.transform.Find("RotDino/Dino").gameObject.GetComponent<Animator>();

        if(father.player == Player.PlayerN.Player1){
            lifeCounter = gameController.lifeCounter1.GetComponent<LifeCounter>();
        }else{
            lifeCounter = gameController.lifeCounter2.GetComponent<LifeCounter>();
        }

        Initiate();
    }
Beispiel #20
0
    void Start()
    {
        m_cinderella    = FindObjectOfType <CinderellaController>();
        m_commandButton = FindObjectOfType <CommandButton>();
        m_Lifecounter   = GameObject.Find("LifeCounter");

        lifeCounter = m_Lifecounter.GetComponent <LifeCounter>();

        if (FadeManager.Instance != null)
        {
            FadeManager.Instance.FadeIn();
        }
        SoundManager.Instance.StopBGM();
        Invoke(((System.Action)LatePlayBGM).Method.Name, 1.0f);
    }
Beispiel #21
0
 void Awake()
 {
     lifeCounter         = this.GetComponent <LifeCounter>();
     scoreCounter        = this.GetComponent <ScoreCounter>();
     achievementsManager = this.GetComponent <AchievementsManager>();
     lifeCounter.Refresh();
     scoreCounter.Refresh();
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
    void Spawn()
    {
        LifeCounter mc = GetComponent <LifeCounter>();

        if (GameObject.Find("screenSpawn").GetComponent <LifeCounter>().spawn) //will check if true
        {
            Vector3    SpawnPosition = new Vector3(Random.Range(xMin, xMax), Random.Range(yMin, yMax), Random.Range(zMin, zMax));
            GameObject Enemy         = Instantiate(EnemyPrefab, SpawnPosition, Quaternion.identity);

            EnemyMovement em = Enemy.GetComponent <EnemyMovement>();
            em.target = GameObject.FindWithTag("Player").transform;
            em.speed  = speed;

            GoTo gt = Enemy.GetComponent <GoTo>();
            gt.target = GameObject.FindWithTag("Player").transform;
        }
    }
Beispiel #23
0
    public void Crash()
    {
        if (invincibility.invincible || lives <= 0)
        {
            return;
        }

        lives--;
        LifeCounter.UpdateCounter(lives);
        if (lives == 0)
        {
            Death();
        }
        else
        {
            invincibility.Play();
        }
    }
    public void AddPlayers(int x)
    {
        //for(int i = 0; i < x.Length; i++)
        //{
        GameObject  playerStatsObj = Instantiate(playerStats, transform);
        LifeCounter counter        = playerStatsObj.GetComponentInChildren <LifeCounter>();

        if (counter != null)
        {
            counter.playerId = x;
        }
        Image playerPlacard = playerStatsObj.transform.GetChild(0).GetComponent <Image>();

        if (playerPlacard != null)
        {
            playerPlacard.color = palette.HUDColors[x - 1];
        }
        //}
    }
Beispiel #25
0
 // Use this for initialization
 private void Start()
 {
     shield      = GetComponentInChildren <PlayerShield>();
     lifeCounter = FindObjectOfType <LifeCounter>();
 }
Beispiel #26
0
 void Start()
 {
     scoreKeeper = GameObject.Find("Score").GetComponent <ScoreKeeper>();
     lifeCounter = GameObject.Find("Lives").GetComponent <LifeCounter>();
 }
Beispiel #27
0
 void Start()
 {
     lifeCounter = GameObject.Find("Lifes").GetComponent <LifeCounter>();
     //step1 = speed * Time.deltaTime;
     Invoke("go_die", 1.0f);
 }
Beispiel #28
0
 void Start()
 {
     LifeCounter.UpdateCounter(lives);
 }
 void Awake()
 {
     instance  = this;
     animators = GetComponentsInChildren <Animator>();
 }
Beispiel #30
0
 void Start()
 {
     lifeCounter = FindObjectOfType <LifeCounter>();
 }
 void FindReference()
 {
     //Life counter is on the main camera
     counter = counter == null?GameObject.FindGameObjectWithTag("MainCamera").GetComponent <LifeCounter>() : counter;
 }