コード例 #1
0
    public void DamageChassman(Chessman target, int damage)
    {
        target.health -= damage;

        damageDisplay.instance.spawnDamageDisplay(damage, 0, target.gameObject.transform);

        target.healthChecker();
    }
コード例 #2
0
    } //被打

    public void enemyAttack()
    {
        print("dosadjlk");
        Chessman playerChessman = BoardManager.Instance.selectedChessman;
        //playerChessman.GetComponentInChildren<animotionEvent>().hit();
        int takeDamage = 0;

        if (playerChessman.def > 0)
        {
            if (playerChessman.def - BoardManager.Instance.playerHitChessman.damage >= 0)
            {
                playerChessman.def -= BoardManager.Instance.playerHitChessman.damage;
                takeDamage          = 0;
            }
            else
            {
                takeDamage = BoardManager.Instance.playerHitChessman.damage - playerChessman.def;
                print(takeDamage);
                int abs = Mathf.Abs(playerChessman.def -= BoardManager.Instance.playerHitChessman.damage);
                playerChessman.def = 0;
            }
        }
        else
        {
            takeDamage = BoardManager.Instance.playerHitChessman.damage;
        }

        playerChessman.health -= takeDamage;
        damageDisplay.instance.spawnDamageDisplay(takeDamage, 1, playerChessman.gameObject.transform);

        gameController.instance.thisRoundsPlayerTakeDamage = BoardManager.Instance.playerHitChessman.damage;

        gameView.instance.updateHealthDisplay();
        if (playerChessman.health <= 0)
        {
            //player died
            gameController.instance.OnPlayerSelectedChessmanDied();
        }

        playerChessman.healthChecker();

        audioEffectScript.instance.attackEnemy();

        BoardManager.Instance.OnEnemyFinishAttack();
    } //敵人攻擊