Ejemplo n.º 1
0
 public bool enemy(Enemy enemy)
 {
     UM.infoDabuguo  = "你打不过他\n\n";
     UM.infoDabuguo += "怪物属性:\n";
     UM.infoDabuguo += "生命:" + enemy.shengming + "\n";
     UM.infoDabuguo += "攻击:" + enemy.gongji + "\n";
     UM.infoDabuguo += "防御:" + enemy.fangyu + "\n";
     UM.infoDabuguo += "金币:" + enemy.jinbi + "\n";
     UM.infoDabuguo += "经验:" + enemy.jingyan + "\n";
     if (HA._gongji <= enemy.fangyu)
     {
         UM.state = "dabuguo";
     }
     else
     {
         int   shanghai     = HA._gongji - enemy.fangyu;
         float cishu        = Mathf.Floor(enemy.shengming / shanghai);
         float zongshanghai = 0;
         if (enemy.gongji > HA._fangyu)
         {
             float shoushang = enemy.gongji - HA._fangyu;
             zongshanghai = shoushang * cishu;
         }
         if (zongshanghai >= HA._shengming)
         {
             UM.state = "dabuguo";
         }
         else
         {
             AuM.playAudio("fight");
             Instantiate(fightAnimation, enemy.gameObject.transform.position, enemy.gameObject.transform.rotation);
             HA._shengming -= (int)zongshanghai;
             HA._jingyan   += enemy.jingyan;
             HA.plusJinbi(enemy.jinbi);
             UM.tipContent = "经验+" + enemy.jingyan + ",金币+" + enemy.jinbi;
             UM.tipTime    = 3f;
             if (enemy.isDoorProtector)
             {
                 List <GameObject> protectorGameObject = enemy.doorComponent.protectorGameObject;
                 if (protectorGameObject.Remove(enemy.gameObject))
                 {
                     if (protectorGameObject.Count == 0)
                     {
                         DoorAnim = enemy.doorComponent.gameObject.GetComponent <tk2dSpriteAnimator>();
                         DoorAnim.Play("DoorBig");
                         Destroy(enemy.doorComponent.gameObject, 0.5f);
                         tk2dTileMap tm = GameObject.Find("TileMap").GetComponent <tk2dTileMap>();
                         int         x, y;
                         tm.GetTileAtPosition(enemy.doorComponent.gameObject.transform.position, out x, out y);
                         tm.ClearTile(x, y, 1);
                     }
                 }
             }
             Destroy(enemy.gameObject);
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 2
0
    public void buyItem(int x)
    {
        switch (x)
        {
        case 11:
            if (HA._jinbi >= 10)
            {
                HA.plusJinbi(-10);
                HA._key_yellow += 1;
            }
            break;

        case 12:
            if (HA._jinbi >= 50)
            {
                HA.plusJinbi(-50);
                HA._key_blue += 1;
            }
            break;

        case 13:
            if (HA._jinbi >= 100)
            {
                HA.plusJinbi(-100);
                HA._key_red += 1;
            }
            break;

        case 14:
            if (HA._jinbi >= 150)
            {
                HA.plusJinbi(-150);
                HA._key_yellow += 1;
                HA._key_blue   += 1;
                HA._key_red    += 1;
            }
            break;

        case 21:
            if (HA._jinbi >= 25)
            {
                HA.plusJinbi(-25);
                HA._gongji += 1;
            }
            break;

        case 22:
            if (HA._jinbi >= 25)
            {
                HA.plusJinbi(-25);
                HA._fangyu += 1;
            }
            break;

        case 23:
            if (HA._jinbi >= 50)
            {
                HA.plusJinbi(-50);
                HA._gongji += 1;
                HA._fangyu += 1;
            }
            break;

        case 24:
            if (HA._jinbi >= 100)
            {
                HA.plusJinbi(-100);
                HA._gongji += 2;
                HA._fangyu += 2;
            }
            break;

        case 31:
            if (HA._jinbi >= 25)
            {
                HA.plusJinbi(-25);
                HA._shengming += 100;
            }
            break;

        case 32:
            if (HA._jinbi >= 50)
            {
                HA.plusJinbi(-50);
                HA._shengming += 200;
            }
            break;

        case 33:
            if (HA._jinbi >= 100)
            {
                HA.plusJinbi(-100);
                HA._key_yellow += 500;
            }
            break;

        case 34:
            if (HA._jinbi >= 200)
            {
                HA.plusJinbi(-200);
                HA._key_yellow += 1000;
            }
            break;

        case 41:
            if (HA._jinbi >= 250)
            {
                HA.plusJinbi(-250);
                HA._gongji += 10;
            }
            break;

        case 42:
            if (HA._jinbi >= 500)
            {
                HA.plusJinbi(-500);
                HA._gongji += 20;
            }
            break;

        case 43:
            if (HA._jinbi >= 1000)
            {
                HA.plusJinbi(-1000);
                HA._gongji += 40;
            }
            break;

        case 44:
            if (HA._jinbi >= 2000)
            {
                HA.plusJinbi(-2000);
                HA._gongji += 80;
            }
            break;

        case 51:
            if (HA._jinbi >= 3500)
            {
                HA.plusJinbi(-3500);
                HA._gongji += 150;
            }
            break;

        case 52:
            if (HA._jinbi >= 250)
            {
                HA.plusJinbi(-250);
                HA._fangyu += 10;
            }
            break;

        case 53:
            if (HA._jinbi >= 500)
            {
                HA.plusJinbi(-500);
                HA._fangyu += 20;
            }
            break;

        case 54:
            if (HA._jinbi >= 1000)
            {
                HA.plusJinbi(-1000);
                HA._fangyu += 40;
            }
            break;

        case 61:
            if (HA._jinbi >= 2000)
            {
                HA.plusJinbi(-2000);
                HA._fangyu += 80;
            }
            break;

        case 62:
            if (HA._jinbi >= 3500)
            {
                HA.plusJinbi(-3500);
                HA._fangyu += 150;
            }
            break;

        default:
            break;
        }
    }