コード例 #1
0
    public void SpawnMonster(int id)
    {
        PlayableMonster m = FindMonster(id);

        if (m != null)
        {
            m.isSpawned = true;

            if (m.sceneObject != null)
            {
                m.sceneObject.GetComponent <BunnyBehaviour>().PlayAnimation(0);
            }
        }
    }
コード例 #2
0
    public void MonsterAttack(int id, int abilityIndex)
    {
        if (id != currentTurnId || gameOver == true)
        {
            return;
        }

        PlayableMonster m = FindMonster(id);

        if (m != null && m.isSpawned && m.monster.hp != 0)
        {
            PlayableMonster target = monsters[(id + 1) % monsters.Length];

            Ability usedAbility   = m.monster.abilities[abilityIndex];
            bool    attackSuccess = Random.Range(1, 100) <= usedAbility.hitPercent;
            m.sceneObject.GetComponent <BunnyBehaviour>().PlayAnimation(1);

            if (attackSuccess)
            {
                float damageMultiplier = Random.Range(1, 100) <= usedAbility.critChance ? 1.5f : 1.0f;
                target.monster.hp -= (int)(usedAbility.damage * damageMultiplier);
                target.sceneObject.GetComponent <BunnyBehaviour>().PlayAnimation(2, 0.75f);
                target.sceneObject.GetComponent <BunnyBehaviour>().healthBar.UpdateVisuals(target.monster.hp);

                if (target.monster.hp <= 0)
                {
                    target.monster.hp = 0;
                    MonsterKill(target.id);
                }
            }

            currentTurnId = target.id;

            if (currentTurnId != 0)
            {
                StartCoroutine(AttackAfterDelay(currentTurnId, 3.0f));
            }
        }
    }