Exemplo n.º 1
0
 void OnTriggerEnter(Collider other)
 {
     if (player) //If a player ship collides with another.
     {
         if (other.tag == "Boundary" || other.tag == "Shield")
         {
             return;                          //Player ships cannot touch the boundary, but just in case.
         }
         else if (other.tag == "Collectible") //Player ships collect coins.
         {
             GameControl.AddCoin();
             Destroy(other.gameObject);
         }
         else if (other.tag == "Enemy") //Enemy ships receive damage from players, and viceversa.
         {
             other.GetComponent <Ship>().Damaged(collisionDamage);
         }
     }
     else //If an enemy ship collides with another:
     {
         if (other.tag == "Boundary" || other.tag == "Enemy" || other.tag == "Collectible" || other.tag == "EnemyBolt")
         {
             return;                     //Ships will only destroy themselves and deal damage to players and shields upon collision with them.
         }
         else if (other.tag == "Shield") //Enemy ships damage shields they collide with.
         {
             other.GetComponent <Shield>().Damaged(collisionDamage);
         }
         else if (other.tag == "Player") //Enemy ships damage players they collide with.
         {
             other.GetComponent <Ship>().Damaged(collisionDamage);
         }
     }
 }
Exemplo n.º 2
0
    public void CollectResources()
    {
        Debug.Log("Collecting resources");
        GameControl c = GameControl.control;

        c.AddStone((int)stoneCollected);
        stoneCollected -= (int)stoneCollected;

        c.AddCoin((int)coinCollected);
        coinCollected -= (int)coinCollected;

        c.AddFood((int)foodCollected);
        foodCollected -= (int)foodCollected;

        c.AddSilk((int)silkCollected);
        silkCollected -= (int)silkCollected;

        c.AddLumber((int)lumberCollected);
        lumberCollected -= (int)lumberCollected;

        c.AddEnergy((int)energyCollected);
        energyCollected -= (int)energyCollected;

        c.AddMorale((int)moraleCollected);
        moraleCollected -= (int)moraleCollected;
    }
Exemplo n.º 3
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.tag == "Player")
     {
         GameControl.AddCoin();
         Destroy(gameObject);
     }
 }
Exemplo n.º 4
0
 // Update is called once per frame
 void Update()
 {
     if (hasParent)
     {
         if (script.oscillating)
         {
             transform.GetChild(0).gameObject.SetActive(true);
             transform.DetachChildren();
             GameControl.AddCoin(); // Coins are calculated and dispayed in an upper part of the screen
             Destroy(gameObject);
         }
     }
 }
Exemplo n.º 5
0
    // Update is called once per frame
    void Update()
    {
        if ((transform.position.y > QuestionBlockCenter + 3)) // If a coin moved vertically by more than 3 units
        {                                                     // it is being pushed down
            CoinRigibody.AddRelativeForce(new Vector2(0, -9), ForceMode2D.Impulse);
            goingDown = true;
        }

        if (transform.position.y < QuestionBlockCenter + 1.4f && goingDown) // If a coin, while moving down, is less than 1.4 units away from Question block center it disapears.
        {
            scoore.position = new Vector2(scoore.position.x, QuestionBlockCenter);
            script.SetScoore("200");
            GameControl.AddCoin();
            Destroy(gameObject);
        }
    }