コード例 #1
0
    public void OnTriggerEnter2D(Collider2D a_collider)
    {
        if (a_collider.gameObject.GetComponent <Player>())
        {
            FindObjectOfType <BattleManager>().ChangeScore(m_coinValue);

            RisingFadingText valueText = Instantiate(m_risingTextPrefab, transform.position + new Vector3(0f, m_damageTextYOffset), new Quaternion(), FindObjectOfType <Canvas>().transform).GetComponent <RisingFadingText>();
            valueText.SetTextContent("+" + m_coinValue);
            valueText.SetOriginalColor(Color.yellow);
            Destroy(this.gameObject);
        }
    }
コード例 #2
0
 public void Damage(float a_damage)
 {
     if (m_stats[(int)eStatIndices.health].value > m_stats[(int)eStatIndices.minHealth].value)
     {
         m_stats[(int)eStatIndices.health].value -= a_damage;
         m_stats[(int)eStatIndices.health].value  = Mathf.Clamp(m_stats[(int)eStatIndices.health].value, m_stats[(int)eStatIndices.minHealth].value, m_stats[(int)eStatIndices.maxHealth].value);
         Instantiate(m_collisionSparkTemplate, transform.position, new Quaternion(), transform);
         RisingFadingText damageText = Instantiate(m_risingFadingTextTemplate, transform.position + new Vector3(0f, m_damageTextYOffset), new Quaternion(), FindObjectOfType <Canvas>().transform).GetComponent <RisingFadingText>();
         damageText.SetTextContent(a_damage);
         damageText.SetOriginalColor(Color.white);
     }
     if (m_stats[(int)eStatIndices.health].value <= m_stats[(int)eStatIndices.minHealth].value)
     {
         if (m_gameHandlerRef.m_currentGameMode == GameHandler.eGameMode.Health)
         {
             Die();
         }
     }
     UpdateMass();
     UpdateHealthColor();
 }
コード例 #3
0
    public override void Die()
    {
        m_battleManagerRef.ChangeScore(m_scoreValue);
        m_gameHandlerRef.m_playerStatHandler.ChangeXP(m_xpReward);

        RisingFadingText xpText = Instantiate(m_risingFadingTextTemplate, transform.position + new Vector3(0f, m_xpTextYOffset), new Quaternion(), FindObjectOfType <Canvas>().transform).GetComponent <RisingFadingText>();

        xpText.SetTextContent("XP +" + m_xpReward);
        xpText.SetOriginalColor(Color.cyan);

        m_battleManagerRef.ChangeEnemyCount(-1);

        float[] spawnDirection;

        for (int i = 0; i < m_coinsToSpawn; i++)
        {
            spawnDirection = new float[m_coinsToSpawn];

            spawnDirection[i] = UnityEngine.Random.Range(0f, 360f);
            for (int j = 0; j < i; j++)
            {
                if ((spawnDirection[i] - spawnDirection[j] <= m_closestCoinSpawnAngle) || (spawnDirection[i] - spawnDirection[j] >= 360f - m_closestCoinSpawnAngle))
                {
                    spawnDirection[i] = UnityEngine.Random.Range(0f, 360f);
                    j--;
                }
            }
            Vector3 spawnLocation = new Vector3(m_coinSpawnOffset, 0f, 0f);
            spawnLocation = Quaternion.AngleAxis(spawnDirection[i], Vector3.forward) * spawnLocation;
            Instantiate <GameObject>(m_coinPrefab, transform.position + spawnLocation, new Quaternion());
        }



        base.Die();
    }