Exemple #1
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.CompareTag("Player") && !other.isTrigger)
     {
         //Debug.Log("进入了饿啊 我碰到了" + other + ", 它" + other.transform.position);
         context.Raise();
         playerInRange = true;
     }
 }
Exemple #2
0
 public void OpenChest()
 {
     //dialog window on
     dialogBox.SetActive(true);
     //dialog text = content text
     dialogText.text = contents.itemDescription;
     //add contents to the inventory
     playerInventory.AddItem(contents);
     playerInventory.currentItem = contents;
     //raise the singnal to the palyer to animate
     raiseItem.Raise();
     //raise the context clue
     context.Raise();
     //set the chest to opened
     isOpen = true;
     storedOpen.initialValue = isOpen;
     anim.SetBool("opened", isOpen);
 }
Exemple #3
0
 private void MakeArrow()
 {
     if (playerInventory.currentMagic >= projectile.GetComponent <Arrow>().magicCost)
     {
         Arrow arrow = Instantiate(projectile, transform.position, Quaternion.identity).GetComponent <Arrow>();
         arrow.Setup(new Vector2(animator.GetFloat("moveX"), animator.GetFloat("moveY")), getRotation());
         playerInventory.ReduceMagic(arrow.magicCost);
         reduceMagic.Raise();
     }
 }
Exemple #4
0
 private void TakeDamage(float damage)
 {
     health -= damage;
     if (health <= 0)
     {
         DeathEffect();
         MakeLoot();
         gameObject.SetActive(false);
         if (roomSignal != null)
         {
             roomSignal.Raise();
         }
     }
 }
Exemple #5
0
    public void Knock(float knockTime, float damage)
    {
        currentHealth.runtimeValue -= damage;

        PlayerHealthSignaler.Raise();
        //Debug.Log("进入PlayerMovement内的Knock方法,  currentHealth.runtimeValue : " + currentHealth.runtimeValue);

        playerHit.Raise();

        if (currentHealth.runtimeValue > 0)
        {
            //Debug.Log("启动玩家生命信号");
            StartCoroutine(KnockCo(knockTime));
        }
        else
        {
            this.gameObject.SetActive(false);
        }
    }
Exemple #6
0
 public void Use(int amountToIncrease)
 {
     playerHealth.runtimeValue += amountToIncrease;
     healthSignal.Raise();
 }
Exemple #7
0
 public void Use(int amountToIncrease)
 {
     playerInventory.currentMagic = playerInventory.maxMagic < (playerInventory.currentMagic + amountToIncrease) ? playerInventory.maxMagic:playerInventory.currentMagic + amountToIncrease;
     magicSignal.Raise();
 }