Esempio n. 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();
    }
Esempio n. 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);
    }
Esempio n. 3
0
    /*
     * use controller.stage.Responses to adjust response to certain actions
     * if no response, use DataUtils.defaultReaction
     * make that action button uninteractable after use so cant be used again
     */
    private void UserAction(Button button, ExploreCat userCat, ActionType action)
    {
        gameObject.SetActive(false);
        ExploreCat enemyCat = controller.enemyPlayer.aliveCats[UnityEngine.Random.Range(0, controller.enemyPlayer.aliveCats.Count)];

        selector.gameObject.SetActive(false);
        Action victory = () =>
        {
            controller.AcceptedGameOver(action, userCat.cat, enemyCat.cat);
        };
        Action defeat = () =>
        {
            defaultResponse(action, userCat);

            ExploreCat enemy = getCurrentEnemy();
            if (enemy != null)
            {
                enemy.Enable();
            }
        };

        //get always response
        alwaysResponse(action, userCat);

        //check if there's a premediated response
        if (controller.stage.Responses != null)
        {
            foreach (ActionResponse response in controller.stage.Responses)
            {
                if (response.action == action)
                {
                    //find enemy cat that matches response
                    enemyCat = findActionCat(enemyCat, response.response);

                    Action meh = () =>
                    {
                        if (action != ActionType.Think)
                        {
                            string[] appeasedNotifs = new string[] {
                                userCat.cat.Name + "'s " + action.ToString() + " seems to make " + enemyCat.cat.Name + " friendlier!",
                                enemyCat.cat.Name + " looks slightly happier from " + userCat.cat.Name + "'s " + action.ToString() + "!",
                                enemyCat.cat.Name + " seems nicer towards " + userCat.cat.Name + "!",
                                enemyCat.cat.Name + " seems appeased by " + userCat.cat.Name + "'s " + action.ToString() + "!",
                                enemyCat.cat.Name + " looks kinder towards " + userCat.cat.Name + " after their " + action.ToString() + "!",
                                enemyCat.cat.Name + " glows a bit from " + userCat.cat.Name + "'s " + action.ToString() + ".",
                                enemyCat.cat.Name + " looks lighter after " + userCat.cat.Name + "'s " + action.ToString() + ".",
                            };
                            controller.Notify(new string[] {
                                appeasedNotifs[UnityEngine.Random.Range(0, appeasedNotifs.Length)]
                            }, () =>
                            {
                                if (enemyCat.currentHealth > 0)
                                {
                                    enemyCat.takeDamage(userCat.realizedStats.attackDamage * 1.75f);
                                }
                                defeat();
                            });
                        }
                        else
                        {
                            defeat();
                        }
                    };

                    if (response.accepted)
                    {
                        controller.exploreStory.Finished += victory;
                    }
                    else
                    {
                        controller.exploreStory.Finished += meh;
                    }

                    controller.exploreStory.InitStory(response.response, userCat, controller.enemyPlayer.allCats);
                    return;
                }
            }
        }
        Debug.Log("CHOICE SPEAKER - " + userCat.cat.Name);
        //else, use default response
        controller.exploreStory.InitStory(DataUtils.defaultReaction(action,
                                                                    //random cat from enemy team
                                                                    enemyCat.cat), userCat, controller.enemyPlayer.allCats);
        // for magic, fly, etc

        controller.exploreStory.Finished += defeat;
    }