Exemplo n.º 1
0
        public void CoinOutputQuarters()
        {
            CoinCounter TestCounter = new CoinCounter();

            Assert.AreEqual("HELLO", TestCounter.CoinTest(99));
            // }
            // [TestMethod]
            // public void CoinOutputDimes()
            // {
            //   CoinCounter TestCounter = new CoinCounter();
            //   Assert.AreEqual(13, TestCounter.CoinTest(12));
            // }
            // [TestMethod]
            // public void CoinOutputNickels()
            // {
            //   CoinCounter TestCounter = new CoinCounter();
            //   Assert.AreEqual(13, TestCounter.CoinTest(12));
            // }
            // [TestMethod]
            // public voiinOutputPennys()
            // {
            //   CoinCounter TestCounter = new CoinCounter();
            //   Assert.AreEqual(13, TestCounter.CoinTest(12));
            // }
        }
Exemplo n.º 2
0
        public void ChangeToCoins_TenToDime_OneDime()
        {
            CoinCounter newCoins = new CoinCounter(15);

            newCoins.ConvertToCoins();
            Assert.AreEqual(newCoins.OutputDimes, 1);
        }
Exemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        CoinCount = CoinCounter.GetInstance();

        CC         = GetComponent <CombatCharacter>();
        CC.OnHurt += CC_OnHurt;
    }
 void Start()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Exemplo n.º 5
0
        public void ChangeToCoins_TwentyFiveToQuarter_OneQuarter()
        {
            CoinCounter newCoins = new CoinCounter(79);

            newCoins.ConvertToCoins();
            Assert.AreEqual(newCoins.OutputQuarters, 3);
        }
Exemplo n.º 6
0
 public static CoinCounter getInstance()
 {
     if(CoinCounter.coinCounter == null){
         CoinCounter.coinCounter = new CoinCounter();
     }
     return CoinCounter.coinCounter;
 }
Exemplo n.º 7
0
 // Use this for initialization
 void Start()
 {
     CoinCounter.Reset();
     CoinCounter.instance.disappers += OnGameClear;
     Singleton <CoinGameTimer> .Instance.timeOver += OnTimeOver;
     player = FindObjectOfType <UnityChan>();
     Singleton <FallChecker> .Instance.fall += OnTimeOver;
 }
Exemplo n.º 8
0
 void OnCollisionEnter2D(Collision2D col)
 {
     if (col.gameObject.tag == "Player")   //player has collided with coin
     {
         CoinCounter.incrementCoinCount(); //add 1 coin to the coin count on the display (canvas)
         Destroy(gameObject);              //destroy coin because we picked it up
     }
 }
Exemplo n.º 9
0
    //private LivesCounter livesCounter;


    void Awake()
    {
        coinCounter = GameObject.Find("CoinText").GetComponent <CoinCounter>();
        //livesCounter = GameObject.Find ("LivesText").GetComponent<LivesCounter>();

        coins      = GameObject.FindGameObjectsWithTag("Coin");
        totalCoins = coins.Length;
    }
Exemplo n.º 10
0
 void OnTriggerEnter2D(Collider2D coll)         //when this gameobject encounters a collision with another gameobject
 {
     if (coll.gameObject.name.Equals("player")) //if coll, the object that collided with this game object has the name of "player" <- that is case sensitive
     {
         CoinCounter.addToCoins();              //this calls the static method 'addToCoins' from the CoinCouter script
         Destroy(this.gameObject);              //deletes the coin from the scene
     }
 }
Exemplo n.º 11
0
        public void GivesBackNumberOfChangeOptionsWhenGivenAllSameCoins(int coinAmount)
        {
            var input  = new int[] { coinAmount };
            var actual = 1;

            var expected = CoinCounter.GetTotalChangeOptions(input);

            actual.Should().Be(expected);
        }
Exemplo n.º 12
0
    // Start is called before the first frame update
    void Start()
    {
        if (instance == null)
        {
            instance = this;
        }

        numCoins = coins.transform.childCount;
    }
Exemplo n.º 13
0
        public void GivesBackNumberOfChangeOptionsWhenGivenPenniesAndQuarters()
        {
            var input  = new int[] { 1, 25 };
            var actual = 3;

            var expected = CoinCounter.GetTotalChangeOptions(input);

            actual.Should().Be(expected);
        }
Exemplo n.º 14
0
 void OnCollisionEnter2D(Collision2D col)
 {
     if (col.gameObject.tag == "Player")
     {
         Destroy(gameObject);
         //Debug.Log("Coin found"); // For debugging
         CoinCounter.Addcoin();
     }
 }
Exemplo n.º 15
0
    public void OnSceneLoaded(Scene scene, LoadSceneMode mode)
    {
        TimerController.AddTime(time);
        CoinCounter.AddCoins(coins);
        PlayerController.SetHealth(health);
        LevelGenerator.SetLevelNumber(nextLevel);

        SceneManager.sceneLoaded -= OnSceneLoaded;
        Destroy(this);
    }
Exemplo n.º 16
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Player"))
        {
            cointCounter        = collision.GetComponent <CoinCounter>();
            cointCounter.Coins += 1;

            Destroy(gameObject);
        }
    }
Exemplo n.º 17
0
    // Start is called before the first frame update
    void Start()
    {
        coinCounter = transform.parent.gameObject.GetComponent <CoinCounter>();

        // look at center of map
        Vector3    vectorToTarget = transform.position - Vector3.zero;
        float      angle          = Mathf.Atan2(-vectorToTarget.z, vectorToTarget.x) * Mathf.Rad2Deg;
        Quaternion q = Quaternion.AngleAxis(angle, Vector3.up);

        transform.rotation = q;
    }
    void OnTriggerEnter2D(Collider2D other)
    {
        CoinCounter counter = other.gameObject.GetComponent <CoinCounter>();

        if (counter != null)
        {
            counter.increment();
        }

        Destroy(gameObject);
    }
Exemplo n.º 19
0
    public static void OnGameOver()
    {
        if (self == null)
        {
            return;
        }
        self.canvas.SetActive(true);
        self.GetComponent <AudioSource>().Play();

        self.textField.text = "You got a score of " + CoinCounter.GetCoins() + " and took " + TimerController.GetTime() + " Minutes!";
    }
Exemplo n.º 20
0
    void OnTriggerEnter2D(Collider2D other)
    {
        //Destroys enemies on contact with projectiles. Adds points.
        if (other.tag == "Enemy")
        {
            Instantiate(enemyDeath, other.transform.position, other.transform.rotation);
            Destroy(other.gameObject);
            CoinCounter.AddPoints(pointsForKill);
        }

        Destroy(gameObject);
    }
Exemplo n.º 21
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.name == "Player")
        {
            //player collects coin
            //print("you've collected a coin");

            CoinCounter.AddPoints(coinValue);

            Destroy(gameObject);
        }
    }
Exemplo n.º 22
0
 private void Awake()
 {
     //Enforce singleton
     if (!instance)
     {
         instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
Exemplo n.º 23
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (col.tag != "Player")
        {
            return;
        }
        time   = TimerController.GetTimeRaw();
        coins  = CoinCounter.GetCoins();
        health = PlayerController.GetHealth();

        SceneManager.sceneLoaded += OnSceneLoaded;
        SceneManager.LoadScene(levelName);
    }
Exemplo n.º 24
0
    private void OnTriggerEnter2D(Collider2D collider)
    {
        CoinCounter coinCounter = FindObjectOfType <CoinCounter>();
        Character   character   = collider.GetComponent <Character>();

        coin = GameObject.FindGameObjectsWithTag("Coin");
        if (character)
        {
            character.coin++;
            coinCounter.Refresh(character.coin);
            if (coin.Length == 1)
            {
                door.SetActive(true);
            }
            Destroy(gameObject);
        }
    }
Exemplo n.º 25
0
    protected override void Awake()
    {
        lives = PlayerPrefs.GetInt("HP");

        rigidbody   = GetComponent <Rigidbody2D>();
        animator    = GetComponent <Animator>();
        sprite      = GetComponent <SpriteRenderer>();
        healthBar   = FindObjectOfType <HealthBar>();
        manaBar     = FindObjectOfType <ManaBar>();
        starCounter = FindObjectOfType <StarCounter>();
        bullet      = Resources.Load <Bullet>("Bullet");
        coinCounter = FindObjectOfType <CoinCounter>();
        score       = 0;
        scoreInfo   = FindObjectOfType <Score>();
        damageTimer = 0;
        stars       = 0;
    }
Exemplo n.º 26
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (col.tag == "Player")
        {
            if (coinValue != 0)
            {
                CoinCounter.AddCoins(coinValue);
            }

            if (healthValue != 0)
            {
                PlayerController.AddHealth(healthValue);
            }

            if (isKey)
            {
                GameEvents.self.OnCollectingKey(keyId);
            }

            PlayerController.PlayCollectSound();
            Destroy(gameObject);
        }
    }
Exemplo n.º 27
0
    // Attempts to move the player in the requested direction
    // If that space is occupied by a non-passable block, then the player
    // bounce off of the spot and mvoe nowhere
    // rowMove and colMove represent the scale of the movement
    //      1, 0, or -1 for moving by one block
    //      other float values for moving back on recursive call in case of collision
    IEnumerator SmoothMove(float rowMove, float colMove, float distance)
    {
        canMove = false;            // Prevent player from beginning another move while they are moving
        float   remDist = distance; // The remaining distance to move the player
        float   thisMove;           // Holds how much the player will move each frame
        Vector3 startPos = this.gameObject.transform.position;

        // Player begins movithis.gameObject.transform.position;ng slow, and picks up speed until they reach their final position
        while (remDist > 0)
        {
            thisMove = Mathf.Round((distance - remDist) * 100f) / 100f; // Round
            thisMove = Mathf.Max(thisMove, .01f);                       // Max is used to allow the movement to start
            thisMove = Mathf.Min(remDist, thisMove, maxMovementSpeed);  // prevent from moving past the block or too fast

            RaycastHit2D[] hits = Physics2D.RaycastAll(transform.position, new Vector2(colMove, rowMove), thisMove);
            foreach (RaycastHit2D hit in hits)
            {
                if (debug)
                {
                    Debug.Log(hit.collider.gameObject.tag + ", " + hasCollided);
                }

                if ((hit.collider.gameObject.tag == "Blocking" || hit.collider.gameObject.tag == "Door") && !hasCollided)
                {
                    hasCollided = true; // Prevents multiple collisions fro happening
                    if (debug)
                    {
                        Debug.Log("Collision Detected!");
                    }
                    if (hit.collider.gameObject.tag == "Door")
                    {
                        ThoughtBubble.startPos = startPos;
                        Debug.Log("Saving position as: " + ThoughtBubble.startPos);
                        ThoughtBubble.stillMoving = true;
                        Debug.Log("Displaying Thought Bubble...");
                        gameObject.GetComponent <ThoughtBubble>().DisplayBubble();
                    }

                    StartCoroutine(SmoothMove(-rowMove, -colMove, distance - remDist)); // Move in reverse direction until at original position

                    yield break;                                                        // Leave coroutine as to not finish forward movement
                }
                else if (hit.collider.gameObject.tag == "Button")
                {
                    door.GetComponent <DoorObstacle>().Open();
                }
                else if (hit.collider.gameObject.tag == "Coin")
                {
                    CoinCounter.AddCoin();
                    Destroy(hit.collider.gameObject);
                }
            }

            Vector2 move = new Vector2(colMove * thisMove, rowMove * thisMove);
            rb.MovePosition((Vector2)transform.position + move);
            remDist -= thisMove;

            if (debug)
            {
                Debug.Log("Player moved " + thisMove + " units, remaining: " + remDist);
            }

            yield return(new WaitForFixedUpdate()); // Wait for Fixed Update to assure MovePosition functions correctly
        }
        if (debug && remDist != 0)
        {
            Debug.Log("Imperfect movement detected: Ramaining Distance of " + remDist + " was not moved!");
        }
        canMove     = true;  // allow the player to move again
        hasCollided = false; // Resolve any collisions
        ThoughtBubble.stillMoving = false;
    }
Exemplo n.º 28
0
 // Start is called before the first frame update
 void Awake()
 {
     coinCounter      = GameObject.Find("CoinCounter").GetComponent <CoinCounter>();
     label_score      = GameObject.Find("coinText").GetComponent <Text>();
     label_score.text = "Score: " + coinCounter.count;
 }
Exemplo n.º 29
0
 // Initialize
 private void Start() => _counter = GameObject.Find("GameCanvas/Coins").GetComponent <CoinCounter>();
Exemplo n.º 30
0
 // Start is called before the first frame update
 void Awake()
 {
     self  = this;
     coins = 0;
     tf    = GetComponent <UnityEngine.UI.Text>();
 }
 void Start()
 {
     this.coinCounter = GameObject.Find("Coins").GetComponent <CoinCounter> ();
     this.UpdateCoinCollected();
 }