예제 #1
0
    public void startFight(ExploreCat enemy)
    {
        fadeSelector();
        ExploreCat cEnemy = getCurrentEnemy();
        ExploreCat user   = getCurrentUser();

        if (user == null || cEnemy == null)
        {
            return;
        }
        user.target = enemy;
        user.Enable();
        if (cEnemy.sideEffect != null)
        {
            cEnemy.checkRemoveEffect();
            if (cEnemy.sideEffect != null)
            {
                user.onHit = (AttackType a, ExploreCat c) =>
                {
                    controller.playSound(a);
                    cEnemy.Enable();
                    c.onHit = controller.OnHit;
                };
                return;
            }
        }
        if (!cEnemy.usedAction && EnemyAction(cEnemy))
        //&& UnityEngine.Random.value > 0.15f)
        {
            if (cEnemy.target == null)
            {
                cEnemy.findTarget();
            }
            user.onHit = (AttackType a, ExploreCat c) =>
            {
                controller.playSound(a);
                cEnemy.useAction();
                c.Disable();
                c.onHit = controller.OnHit;
            };
            return;
        }
        cEnemy.Enable();
    }
예제 #2
0
    public void Fight()
    {
        gameObject.SetActive(false);
        ExploreCat currentUser = getCurrentUser();

        //if all cats just died
        if (currentUser == null)
        {
            return;
        }
        if (currentUser.sideEffect != null)
        {
            currentUser.checkRemoveEffect();
            if (currentUser.sideEffect != null)
            {
                fadeSelector();
                currentUser.onHit = (AttackType a, ExploreCat c) =>
                {
                    getCurrentEnemy().Enable();
                    c.onHit = controller.OnHit;
                };
                currentUser.Enable();
                return;
            }
        }

        if (controller.enemyPlayer.aliveCats.Count <= 1)
        {
            startFight(getCurrentEnemy());
            return;
        }

        Camera.main.GetComponent <Physics2DRaycaster>().enabled = true;
        getActiveSelector().transform.SetParent(controller.enemyPlayer.aliveCats[0].transform, false);
        // setSelectorSprite(selector, controller.userPlayer.aliveCats[0].cat.getCatAsset().faction);
    }