コード例 #1
0
    // private bool hasPlayerWon()
    // {
    //     if (enemyPlayer.getNumLivingCats() == 0)
    //     {
    //         return true;
    //     }
    //     return false;
    // }

    // private bool hasPlayerLost()
    // {
    //     if (userPlayer.getNumLivingCats() == 0)
    //     {
    //         return true;
    //     }
    //     return false;
    // }


    private void sideEffectReact(SideEffect effect, ExploreCat effectee)
    {
        string[] effectNotifs = null;
        string   secondstring = null;
        float    damage       = 0;

        // if (cat.owner.enemy)
        // {
        //     exploreChoice.getCurrentUser().Disable();
        // }
        switch (effect.effect)
        {
        case Fx.Love:
            effectNotifs = new string[] {
                effectee.cat.Name + " loves their foe too much to focus!",
                effectee.cat.Name + " likes their foe so much that they refuse to battle.",
                effectee.cat.Name + " is too distracted by their love for their foe to pay attention!",
                effectee.cat.Name + " is too busy feeling adoration for their foe!",
                effectee.cat.Name + " wants to make friends, not war!",
            };
            if (UnityEngine.Random.value > 0.6f)
            {
                damage       = effectee.realizedStats.maxHealth * 0.025f;
                secondstring = effectee.cat.Name + " feels hurt at the thought of fighting!";
            }
            break;

        case Fx.Confused:
            effectNotifs = new string[] {
                effectee.cat.Name + " is too confused by the " + effect.effector.ToString().ToLower() + " to fight!",
                effectee.cat.Name + " is too bewildered by the " + effect.effector.ToString().ToLower() + " to attack!",
                effectee.cat.Name + " is caught off guard by the " + effect.effector.ToString().ToLower() + "!",
                effectee.cat.Name + " is confused; they've never seen a " + effect.effector.ToString().ToLower() + " before!",
            };
            if (UnityEngine.Random.value > 0.75f)
            {
                damage       = effectee.realizedStats.maxHealth * 0.05f + 1;
                secondstring = effectee.cat.Name + " got hurt in their confusion!";
            }
            break;

        case Fx.Distracted:
            effectNotifs = new string[] {
                effectee.cat.Name + " is too distracted by the " + effect.effector.ToString().ToLower() + " to attack!",
                effectee.cat.Name + " bats the " + effect.effector.ToString().ToLower() + " happily, forgetting to attack!",
                effectee.cat.Name + " is too busy playing with the " + effect.effector.ToString().ToLower() + " to attack!",
                effectee.cat.Name + " ignores the fight to paw at the " + effect.effector.ToString().ToLower() + "!",
            };
            break;

        case Fx.Scared:
            effectNotifs = new string[] {
                effectee.cat.Name + "'s too scared of the " + effect.effector.ToString().ToLower() + " to move!",
                effectee.cat.Name + " is frozen in fear of the " + effect.effector.ToString().ToLower() + "!",
                effectee.cat.Name + " is too frightened of the " + effect.effector.ToString().ToLower() + " to do anything!",
            };
            if (UnityEngine.Random.value > 0.45f)
            {
                damage       = effectee.realizedStats.maxHealth * 0.05f + 2;
                secondstring = effectee.cat.Name + " got hurt in their fright!";
            }
            break;
        }
        if (effectNotifs != null)
        {
            if (effectee.currentHealth <= 0)
            {
                effectee.onHit(AttackType.None, effectee);
                return;
            }
            if (effectee.owner.enemy)
            {
                exploreChoice.getCurrentUser().Disable();
            }

            string[] notifs = (secondstring == null) ? new string[] {
                effectNotifs[UnityEngine.Random.Range(0, effectNotifs.Length)]
            } : new string[] {
                effectNotifs[UnityEngine.Random.Range(0, effectNotifs.Length)],
                secondstring
            };

            Notify(notifs, () =>
            {
                effectee.onHit(AttackType.None, effectee);
                if (damage > 0)
                {
                    effectee.takeDamage(damage);
                }
            });
            effectee.setEffect();
        }
    }
コード例 #2
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;
    }