Exemplo n.º 1
0
    public void StartAttack(eDir dir)
    {
        // 方向から対象Idを取得する
        Vector2 targetPos = _MapManager.GetGridPosFromDir(transform.position, dir);
        int?    targetId  = _GameManager.GetCharacterId(targetPos);

        if (targetId == null)
        {
            Debug.Log("ERROR targetId");
            return;
        }

        // IDからパラメータを取得する
        CharacterParam?targetParam = _GameManager.GetCharacterParamFromId((int)targetId);

        if (targetParam == null)
        {
            Debug.Log("ERROR targetParam");
            return;
        }

        // 自身のパラメータと対象のパラメータからダメージを計算する
        int damage = CalculationDamage(_Param, (CharacterParam)targetParam);

        // アニメーションさせる
        _Attack.StartAnimation();

        // ダメージの表示をする
        _MessageMan.AddMessage("プレイヤー" + " は " + "スライム" + " に " + damage + " のダメージを与えた ");
    }
Exemplo n.º 2
0
    public void ResolveAttack()
    {
        if (GameManager.CurrentState != FightState.ConfrontState)
        {
            return;
        }

        if (Player1.ChosenAttacks.Count == 0)
        {
            GameManager.ConfrontIsOver();
            return;
        }

        Attack attack1 = Player1.ChosenAttacks.Dequeue();
        Attack attack2 = Player2.ChosenAttacks.Dequeue();

        AttackAnimation anim1 = Player1.ChosenAttacksAnim.Dequeue();
        AttackAnimation anim2 = Player2.ChosenAttacksAnim.Dequeue();

        Move1Started.Invoke(attack1.Image);
        Move2Started.Invoke(attack2.Image);

        if (attack1.Fervor != attack2.Fervor)
        {
            Player1.Fervor.Value += attack1.Fervor - attack2.Fervor;
            Player2.Fervor.Value += attack2.Fervor - attack1.Fervor;
        }

        anim1.StartAnimation(Attack1EndStatus);
        Player1.GetComponentInChildren <Animator>().SetTrigger(anim1.triggerName);

        anim2.StartAnimation(Attack2EndStatus);
        Player2.GetComponentInChildren <Animator>().SetTrigger(anim2.triggerName);


        result1.Reset();
        result2.Reset();

        Attack1EndStatus.Value = false;
        attack1.ResolveAttack(Player1, Player2, attack2, result1, result2);

        Attack2EndStatus.Value = false;
        attack2.ResolveAttack(Player2, Player1, attack1, result2, result1);


        CreatePopups();


        if (Player1.Population.Value <= 0)
        {
            GameManager.CallGameOver(Player2);
        }
        if (Player2.Population.Value <= 0)
        {
            GameManager.CallGameOver(Player1);
        }
    }