Beispiel #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 = "已习得";
            });
        }
    }
Beispiel #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("金币不足");
         }
     }
 }