Esempio n. 1
0
    // Start is called before the first frame update
    void Start()
    {
        skillName.text = skill.name;
        price.text     = skill.levelList[0].price.ToString();
        state.text     = "已习得";
        player         = GameManager.GetInstance().GetPlayer().GetComponent <PlayerProperty>();
        view.onClick.AddListener(() =>
        {
            board.SetIntro(skill.levelList[0].intro);
        });

        if (!bought)
        {
            state.text = "购买";
            buy.onClick.AddListener(() =>
            {
                if (player.GetCoinNumber() < skill.levelList[0].price)
                {
                    return;
                }
                player.SetCoinNumber(-skill.levelList[0].price);
                player.AddSkill(skill.enName);
                state.text = "已习得";
            });
        }
    }
Esempio n. 2
0
 protected virtual void OnTriggerStay2D(Collider2D other)
 {
     if (!isGoods || !other.CompareTag("Player"))
     {
         return;
     }
     if (InputManager.GetButtonDown("Interact"))
     {
         if (player.GetCoinNumber() >= price)
         {
             Destroy(priceTextInstance);
             player.SetCoinNumber(-price);
             isGoods = false;
             if (TryGetComponent <Rigidbody2D>(out var rb))
             {
                 rb.bodyType = RigidbodyType2D.Dynamic;
             }
         }
         else
         {
             GetComponent <TriggerDisplay>().SetText("金币不足");
         }
     }
 }
Esempio n. 3
0
    /// <summary>
    /// 对敌人造成伤害
    /// </summary>
    /// <param name="enemy">敌人对象</param>
    /// <param name="baseDamage">基础伤害</param>
    /// <param name="direction">伤害方向</param>
    /// <param name="extraDamage">额外伤害</param>
    public void Damage(GameObject enemy, float baseDamage, float direction, float extraDamage = 0)
    {
        var enemyMovement = enemy.GetComponent <EnemyMovement>();

        if (!enemyMovement.canGetDamage())
        {
            return;
        }
        int type = 1;

        baseDamage += property.GetAttack();
        if (property.HaveEquipment("SkullSword"))
        {
            baseDamage += property.GetCoinNumber() / 20 * 2;
        }
        if (property.HaveEquipment("WizardSword") && Random.Range(0, 1f) < 0.05f)
        {
            property.SetShield(1);
        }
        if (property.HaveEquipment("ThiefMask") && Random.Range(0, 1f) < 0.1f)
        {
            GameObject coin = Resources.Load <GameObject>("Prefabs/Item/SilverCoin");
            Instantiate(coin).GetComponent <Item>().Emit(enemy.transform.position, false);
        }
        if (property.HaveEquipment("SamuraiSoul") && Random.Range(0, 1f) < 0.3f)
        {
            baseDamage *= 2;
            type       += 2;
        }
        if (extraDamage > 0)
        {
            type++;
        }
        if (property.HaveEquipment("ShadowBlade") && direction * enemy.transform.localScale.x > 0)
        {
            extraDamage += 10;
            if (type != 2 && type != 4)
            {
                type++;
            }
        }
        if (property.HaveEquipment("EnergyDrink"))
        {
            if (Random.Range(0, 1f) < 0.35f)
            {
                extraDamage += Random.Range(10, 51);
                if (type != 2 && type != 4)
                {
                    type++;
                }
            }
        }
        if (property.HaveEquipment("BloodyFangs"))
        {
            if (!enemy.TryGetComponent(out BloodyFangs bloodyFangs))
            {
                bloodyFangs = enemy.AddComponent <BloodyFangs>();
            }
            bloodyFangs.AddHurtNumber();
            extraDamage += bloodyFangs.GetExtraDamage();
            if (extraDamage > 0 && type != 2 && type != 4)
            {
                type++;
            }
        }
        float damage = baseDamage + extraDamage;

        enemyMovement.getDamage(damage, (int)direction);
        PoolManager.GetInstance().GetDamageText(enemy.transform.position, damage, type);
    }