private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag == MyTags.BULLET_TAG)
     {
         if (tag == MyTags.BEETLE_TAG)
         {
             anim.Play("Stunned");
             canMove         = false;
             myBody.velocity = new Vector2(0, 0);
             StartCoroutine(Dead(0.4f));
             CoinScript.addScore();
         }
         else if (tag == MyTags.SNAIL_TAG)
         {
             if (!stunned)
             {
                 anim.Play("Stunned");
                 canMove         = false;
                 stunned         = true;
                 myBody.velocity = new Vector2(0, 0);
                 CoinScript.addScore();
             }
             else
             {
                 gameObject.SetActive(false);
             }
         }
     }
 }
Example #2
0
    void Update()
    {
        foreach (GameObject coin in coins)
        {
            CoinScript actualCoin = coin.GetComponent <CoinScript>();

            if (actualCoin != null && !actualCoin.IsAlive())
            {
                Vector3 newLoc = RandomLocation(radius);
                Debug.Log("reviving at " + newLoc);
                actualCoin.revive(newLoc, GlobalVars.numDimensions);
            }
            else if (actualCoin == null)
            {
                Debug.Log("couldn't find any coins to revive");
            }

            if (actualCoin.dimension != GlobalVars.currentDimensionIter)
            {
                coin.SetActive(false);
            }
            else
            {
                coin.SetActive(true);
            }
        }
    }
Example #3
0
 // Start is called before the first frame update
 void Start()
 {
     this.rigid2D  = GetComponent <Rigidbody2D>();
     this.animator = GetComponent <Animator>();
     count         = new CoinScript();
     this.point    = count.getPoint();
 }
Example #4
0
 void Start()
 {
     this.kupa  = GameObject.Find("kupa");
     this.key   = this.kupa.transform.localScale.x;
     count      = new CoinScript();
     this.point = count.getPoint();
     print(this.key);
 }
Example #5
0
 public void LoadData()
 {
     CoinScript.SetScore(PlayerPrefs.GetInt("Score"));
     //PlayerThrow.SetNumberOfBones(PlayerPrefs.GetInt("Bones"));
     NeoHealthSystemScript.SetNumberOfCurrentLifes(PlayerPrefs.GetInt("Health"));
     Player.GetComponent <MovementScript>().SetTime(PlayerPrefs.GetFloat("Timer"));
     EasterEggs_Script.SetEasterEggs(PlayerPrefs.GetInt("Eggs"));
 }
 public void CoinCollected(CoinScript coin)
 {
     Destroy(coin.gameObject);
     coinCount++;
     audioSource.PlayOneShot(coinCollectedSound);
     // Alternatively, if you have a dedicated audio source
     // for coin sounds you can just use audioSource.Play();
 }
 private void Awake()
 {
     MyBody = GetComponent <Rigidbody2D>();
     if (instance == null)
     {
         instance = this;
     }
 }
Example #8
0
 void Start()
 {
     this.animator = GetComponent <Animator>();
     this.sr       = GetComponent <SpriteRenderer>();
     this.player   = GameObject.Find("Player");
     count         = new CoinScript();
     this.point    = count.getPoint();
 }
Example #9
0
    private void ScriptOnOnMoneyCollected(object sender, EventArgs e)
    {
        var rawText = "Coins: " + CoinScript.GetCoinAmount().ToString("0");

        if (text != null)
        {
            text.text = rawText;
        }
    }
Example #10
0
 // Start is called before the first frame update
 void Start()
 {
     this.animator       = GetComponent <Animator>();
     this.player         = GameObject.Find("Player");
     this.rigid2D        = GetComponent <Rigidbody2D>();
     this.sr             = GetComponent <SpriteRenderer>();
     this.blessGenerator = GameObject.Find("BlessGenerator");
     this.script         = blessGenerator.GetComponent <BlessGenerator>();
     count      = new CoinScript();
     this.point = count.getPoint();
 }
    void Start()
    {
        ObjectToHide.SetActive(false);

        referenceObject  = GameObject.Find("coin1");
        referenceObject2 = GameObject.Find("coin2");
        referenceObject3 = GameObject.Find("coin3");
        referenceScript  = referenceObject.GetComponent <CoinScript>();
        referenceScript2 = referenceObject2.GetComponent <CoinScript>();
        referenceScript3 = referenceObject3.GetComponent <CoinScript>();
    }
Example #12
0
 public void Start()
 {
     player        = GameObject.FindWithTag("Player").GetComponent <PlayerControl>();
     shopInventory = GameObject.Find("Shop Inventory").GetComponent <inventory>();
     playerCoins   = GameObject.Find("CoinHUD").GetComponent <CoinScript>();
     Manager.Instance.LoadSpecific("0-ARMOR-1;1-BOOTS-1;2-SWORD-1;3-HEALTH-1;4-MANA-1;5-SWIFT-1;6-POWER-1;7-STRENGTH-1;", "Shop Inventory"); // loads contents into specific inventory (contents,name)
     Debug.Log("Loaded");
     shopInventory.RenameSlots("Shop");
     Debug.Log("Renamed");
     shopInventory.SetShopItems();
     Debug.Log("Set");
 }
Example #13
0
 void Awake()
 {
     if (instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         instance = this;
         DontDestroyOnLoad(this);
     }
 }
Example #14
0
 void OnTriggerEnter2D(Collider2D c)
 {
     if (c.gameObject.CompareTag("Coin"))
     {
         if (!isDead)
         {
             CoinScript CoinScript = c.GetComponent <CoinScript> ();
             int        value      = CoinScript.value;
             CoinScript.PlaySound();
             changeScore(value);
             Destroy(c.gameObject);
         }
     }
 }
Example #15
0
    public void SetPowerUp(PowerUp powerUp)
    {
        if (coinObject != null)
        {
            GameObject.Destroy(coinObject);
        }

        SetInactive();


        switch (powerUp)
        {
        case PowerUp.coin:
        {
            coinObject = (GameObject)GameObject.Instantiate(coin, transform);
            break;
        }

        case PowerUp.gun:
        {
            coinObject = (GameObject)GameObject.Instantiate(gun, transform);
            break;
        }

        case PowerUp.shield:
        {
            coinObject = (GameObject)GameObject.Instantiate(shield, transform);
            break;
        }

        case PowerUp.slow:
        {
            coinObject = (GameObject)GameObject.Instantiate(slowDown, transform);
            break;
        }

        case PowerUp.fast:
        {
            coinObject = (GameObject)GameObject.Instantiate(speedUp, transform);
            break;
        }
        }

        if (coinObject != null)
        {
            CoinScript coinScript = coinObject.GetComponent <CoinScript> ();
            coinScript.coinType = powerUp;
        }
    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag == MyTags.BULLET_TAG)
        {
            anim.Play("BirdDead");

            GetComponent <BoxCollider2D>().isTrigger = true;
            myBody.bodyType = RigidbodyType2D.Dynamic;

            canMove = false;

            StartCoroutine(BirdDead());
            CoinScript.addScore();
        }
    }
Example #17
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag == MyTags.BULLET_TAG)
        {
            anim.Play("SpiderDead");
            myBody.bodyType = RigidbodyType2D.Dynamic;

            CoinScript.addScore();
            StartCoroutine(SpiderDead());
            StopCoroutine(coroutine_Name);
        }
        if (collision.tag == MyTags.PLAYER_TAG)
        {
            collision.GetComponent <PlayerDamage>().DealDamage();
        }
    }
Example #18
0
    private void SpawnCoins()
    {
        // Instantiate prefab
        GameObject coin = Instantiate(coinPrefab);

        coin.transform.position = transform.position;
        // Set max and min coins
        CoinScript coinScript = coin.GetComponent <CoinScript>();

        coinScript.minAmount = minCoins;
        coinScript.maxAmount = maxCoins;
        // Set velocity for rigidbody.
        Rigidbody2D rBody = coin.GetComponent <Rigidbody2D>();

        rBody.isKinematic = false;
        rBody.AddForce(new Vector2(Random.Range(3, -3), 10), ForceMode2D.Impulse);
    }
Example #19
0
    public void SaveData()
    {
        int CurrentScore = CoinScript.GetScore();
        //int CurrentBones = PlayerThrow.GetNumberOfBones();
        //Debug.Log($"Bones: {CurrentBones}");
        int   CurrentEggs   = EasterEggs_Script.GetEasterEggs();
        int   CurrentHealth = NeoHealthSystemScript.GetNumberOfCurrentLifes();
        float Timer         = Player.GetComponent <MovementScript>().GetTime();

        //Debug.Log($"Current Health : {CurrentHealth}");
        PlayerPrefs.SetInt("Score", CurrentScore);
        //PlayerPrefs.SetInt("Bones", CurrentBones);
        PlayerPrefs.SetInt("Health", CurrentHealth);
        PlayerPrefs.SetInt("Eggs", CurrentEggs);
        PlayerPrefs.SetFloat("Timer", Timer);
        PlayerPrefs.Save();
    }
Example #20
0
    private void Start()
    {
        Player              = GameObject.FindGameObjectWithTag("Player");
        CoinsCollected      = CoinScript.GetScore();
        EasterEggsCollected = EasterEggs_Script.GetEasterEggs();
        UnusedBones         = Player.GetComponent <ThrowBoneScript>().GetNumberOfBones();
        LifesSaved          = NeoHealthSystemScript.GetNumberOfCurrentLifes();

        TimeInGame       = MovementScript.TimeSpentInGame;
        PickedCoins.text = $"Coins: {CoinsCollected}";
        LeftBones.text   = $"Left bones: {UnusedBones}";

        PickedEasterEggs.text = $"Easter eggs: {EasterEggsCollected}";
        LeftLifes.text        = $"Lifes: {LifesSaved}";
        KilledDinosaurus.text = $"Kills: {DeathDinosaurus}";
        Timer.text            = $"Time: {TimeInGame}";
    }
Example #21
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.tag == "Finish")
        {
            if (!playerController.Dead)
            {
                if (PlayerPrefs.GetInt("Sound", 1) == 1)
                {
                    GameObject.Find("CoinSound").GetComponent <AudioSource>().Play();
                }

                CoinScript.AddPoint();


                gameObject.SetActive(false);
                plusone.SetActive(true);
            }
        }
    }
    public void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag.Equals("DeadlyBox"))
        {
            Die();
        }

        if (collision.gameObject.tag.Equals("Finish"))
        {
            CoinScript.CoinSet();
            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
            AudioManager.PlaySound("complete");
        }

        if (collision.gameObject.tag.Equals("Win"))
        {
            CoinScript.Win();
        }
    }
Example #23
0
    // Start is called before the first frame update
    void Start()
    {
        count               = new CoinScript();
        this.player         = GameObject.FindWithTag("Player");
        this.playerCollider = player.GetComponent <BoxCollider2D>();
        this.sr             = GetComponent <SpriteRenderer>();
        this.colliders      = GetComponentsInChildren <BoxCollider2D>();

        //飛び出るアイテムのコピーをしている
        content = Instantiate(content);
        content.transform.position = transform.position;
        content.transform.SetParent(gameObject.transform);
        content.gameObject.SetActive(false);

        //アイテムの飛び出す目標地点を定めている
        movePoint = (Vector2)transform.position + new Vector2(0.0f, 1.2f);

        this.director = GameObject.Find("UIController");
    }
Example #24
0
    void OnCollisionEnter2D(Collision2D c)
    {
        if (c.gameObject.CompareTag("1up"))
        {
            if (!isDead)
            {
                lives++;

                PlayerPrefs.SetInt("247127CurrentPlayerLives", lives);
                livesScript.playSound(transform.position);
                livesScript.UpdateLives(1);
                Destroy(c.gameObject);
            }
        }
        if (c.gameObject.CompareTag("Coin"))
        {
            if (!isDead)
            {
                CoinScript CoinScript = c.gameObject.GetComponent <CoinScript> ();
                int        value      = CoinScript.value;
                CoinScript.PlaySound();
                changeScore(value);
                Destroy(c.gameObject);
            }
        }
        if (c.gameObject.CompareTag("Heart"))
        {
            if (!isDead)
            {
                HeartScript hScript = c.gameObject.GetComponent <HeartScript> ();
                int         value   = hScript.value;
                if (health + value < 4)
                {
                    healthScript.IncreaseHealth(value);
                    health += value;
                    PlayerPrefs.SetInt("247127CurrentPlayerHealth", health);
                }
                hScript.PlaySound();
                Destroy(c.gameObject);
            }
        }
    }
Example #25
0
    void CheckForCollision()
    {
        RaycastHit2D hit = Physics2D.Raycast(bottom_Collision.position, Vector2.down, 0.1f, playerLayer);

        if (activeBlock)
        {
            if (hit)
            {
                if (hit.collider.gameObject.tag == MyTags.PLAYER_TAG)
                {
                    audioManager.Play();
                    //increase score
                    CoinScript.addScore();
                    activeBlock = false;
                    //change block
                    anim.Play("BlockCollected");
                    startAnim = true;
                }
            }
        }
    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (canDamage)
        {
            if (collision.tag == MyTags.BULLET_TAG)
            {
                health--;
                CoinScript.addScore();
                canDamage = false;

                if (health == 0)
                {
                    GetComponent <BossScript>().DeactivateBoss();
                    anim.Play("BossDead");
                    Invoke("BossGoneNew", 2f); // 2 ways to solve this - IEnumerator or Invoke
                    //StartCoroutine(BossGone());
                }

                StartCoroutine(WaitForDamage());
            }
        }
    }
Example #27
0
    public void SpitCoin()
    {
        // Instantiate coin at nuzzle
        GameObject coin = Instantiate(CoinPrefab);

        coin.transform.position = Nuzzle.position;

        // Calculates direction vector
        Vector2 directionVector = new Vector2(-15, Random.Range(-8, 4)).normalized;

        // Adds coin to dictionary
        coins.Add(coin, directionVector);

        // Sets up coin script stuff
        CoinScript coinScript = coin.GetComponent <CoinScript>();

        coinScript.OnDestroy = () =>
        {
            coins.Remove(coin);
            coinScripts.Remove(coin);
        };
        coinScripts.Add(coin, coinScript);
    }
Example #28
0
 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "bullet")
     {
         explosion.Play();
         ScoreScript scoreScript = (ScoreScript)score.GetComponent(typeof(ScoreScript));
         scoreScript.score++;
         if (Random.Range(0.0f, 1.0f) > 0.5f)
         {
             GameObject newCoin    = Instantiate(coin, this.transform.position, this.transform.rotation);
             CoinScript coinScript = (CoinScript)newCoin.GetComponent(typeof(CoinScript));
             coinScript.coinGet = coinNoise;
         }
         Destroy(other.gameObject);
         Destroy(this.gameObject);
     }
     if (other.tag == "Player")
     {
         explosion.Play();
         HealthBar healthbar = (HealthBar)health.GetComponent(typeof(HealthBar));
         healthbar.hit();
         Destroy(this.gameObject);
     }
 }
Example #29
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        RedLaser    redLaser    = collider.gameObject.GetComponent <RedLaser> ();
        CoinScript  coin        = collider.gameObject.GetComponent <CoinScript> ();
        CoinsKeeper coinsKeeper = GameObject.Find("zCoins").GetComponent <CoinsKeeper>();

        if (redLaser)
        {
            health -= redLaser.RedDamage();
            redLaser.Hit();
            if (animator.enabled == false)
            {
                animator.enabled = true;
            }
            animator.Play("PlayerHitAnim");
            if (health <= 0)
            {
                Instantiate(playerExplosion, transform.position, Quaternion.identity);
                Destroy(motorLight);
                Destroy(gameObject);
                gameController.GameOver();
            }
        }
        else if (coin)
        {
            zCoins += coin.CoinValue();
            coinsKeeper.CoinsKeeperText(zCoins);
        }
        else
        {
            Instantiate(playerExplosion, transform.position, Quaternion.identity);
            Destroy(motorLight);
            Destroy(gameObject);
            gameController.GameOver();
        }
    }
Example #30
0
 void Start()
 {
     count      = new CoinScript();
     this.point = count.getPoint();
 }