public static ExplorationEvent stealEggs()
    {
        ExplorationEvent e = new ExplorationEvent();

        AnimalDef chicken = new AnimalDef();

        chicken.SizeTrait    = SizeFactory.createTiny();
        chicken.SpeciesTrait = SpeciesFactory.createChicken();

        List <AnimalDef> twoChickens = new List <AnimalDef>()
        {
            chicken, chicken
        };

        List <ExplorationCriteria> variableChickenReward = new List <ExplorationCriteria>()
        {
            new ExplorationCriteria(TraitFactory.Attribute.Fighting.ToString(), int.MinValue, 6, new RewardImpl.RandomAnimalPenalty()),
            new ExplorationCriteria(TraitFactory.Attribute.Fighting.ToString(), 6, 10, new RewardImpl.DoNothingReward("The Chicken looks kinda scary, and you back off.")),
            new ExplorationCriteria(TraitFactory.Attribute.Fighting.ToString(), 10, 20, new RewardImpl.AnimalReward(chicken, "You defeat the mother and get one unbroken egg from the nest.")),
            new ExplorationCriteria(TraitFactory.Attribute.Fighting.ToString(), 20, int.MaxValue, new RewardImpl.AnimalReward(twoChickens, "After defeating the mother there are two viable eggs left in the nest."))
        };

        e.description = "You see a nest with a few eggs.  Its mother, a hugely oversized chicken, is nearby.";
        e.options     = new List <ExplorationEvent.Option>()
        {
            new ExplorationEvent.Option("Fight the chicken", variableChickenReward),
            new ExplorationEvent.Option("Run like the wind", TraitFactory.Attribute.Tracking.ToString(), 4, new RewardImpl.DoNothingReward("You run away"), new RewardImpl.RandomAnimalPenalty(), new List <string>()),
            new ExplorationEvent.Option("Build a defensive wall", TraitFactory.Attribute.Strength.ToString(), 20, new RewardImpl.DoNothingReward("You build a wall and make the chicken pay for it."), new RewardImpl.RandomAnimalPenalty(), new List <string>())
        };

        return(e);
    }
    public void Draw(ExplorationEvent currentEvent, ExploreState state)
    {
        gameObject.GetComponentInChildren <Text> ().text = currentEvent.description;


        for (int i = 0; i < currentEvent.options.Count; i++)
        {
            GameObject button = Instantiate(OptionButton, gameObject.transform.position, gameObject.transform.rotation) as GameObject;
            button.transform.SetParent(OptionPanel.transform);


            Text[] texts = button.GetComponentsInChildren <Text> ();

            texts[0].text = currentEvent.options [i].description;


            List <KeyValuePair <string, int> > list = currentEvent.options [i].probability(state.getParty()).ToList();

            string odds = "";
            foreach (KeyValuePair <string, int> pair in list)
            {
                odds += pair.Key + ": " + pair.Value + "\n";
            }
            texts[1].text = odds;

            button.gameObject.GetComponent <OptionButtonBehavior> ().optionNum = i;
            button.gameObject.GetComponent <OptionButtonBehavior> ().state     = state;

            button.GetComponent <Button>().interactable = currentEvent.options[i].checkSpecialRequirements(state.getParty());
        }

        this.gameObject.transform.position = GameManager.Instance.transform.position;
        this.gameObject.SetActive(true);
    }
Ejemplo n.º 3
0
    protected ExplorationEvent getLost(SpeciesFactory.Species species)
    {
        ExplorationEvent e = new ExplorationEvent();

        e.options = new List <ExplorationEvent.Option>();

        int TrackingScore = 10;
        List <ExplorationCriteria> variableStuckReward = new List <ExplorationCriteria>()
        {
            new ExplorationCriteria(TraitFactory.Attribute.Strength.ToString(), int.MinValue, TrackingScore, new RewardImpl.FoodPenalty(5)),
            new ExplorationCriteria(TraitFactory.Attribute.Strength.ToString(), TrackingScore, 2 * TrackingScore, new RewardImpl.DoNothingReward("You catch your bearings")),
            new ExplorationCriteria(TraitFactory.Attribute.Strength.ToString(), 2 * TrackingScore, int.MaxValue, new RewardImpl.FoodReward(5))
        };

        e.options.Add(new ExplorationEvent.Option("Find your way out", variableStuckReward));

        e.options.Add(
            new ExplorationEvent.Option("Send out your flyer", TraitFactory.Attribute.Fighting.ToString(), 0, new RewardImpl.DoNothingReward("From high up in the air, your winged creature sees the way forward"), new RewardImpl.DoNothingReward("From high up in the air, your winged creature sees the way forward"), new List <string>()
        {
            TraitFactory.Traits.Flying.ToString()
        }));

        e.options.Add(
            new ExplorationEvent.Option("Send your climber up a tree", TraitFactory.Attribute.Fighting.ToString(), 0, new RewardImpl.DoNothingReward("From high up in the tree your creature sees the way forward"), new RewardImpl.DoNothingReward("From the top of the tree your creature sees the way forward"), new List <string>()
        {
            TraitFactory.Traits.Climb.ToString()
        }));


        return(e);
    }
Ejemplo n.º 4
0
    private bool CheckPhaseMatched(ExplorationEvent @event)
    {
        switch (@event.phase)
        {
        case ExplorationEvent.EventPhase.SearchingItem:
            if (phaseState == PhaseState.ItemDiscovery1 || phaseState == PhaseState.ItemDiscovery2)
            {
                return(true);
            }
            break;

        case ExplorationEvent.EventPhase.RandomEncounter:
            if (phaseState == PhaseState.RandomEncounter)
            {
                return(true);
            }
            break;

        case ExplorationEvent.EventPhase.FinishingExploration:
            if (phaseState == PhaseState.FinishingExploration)
            {
                return(true);
            }
            break;
        }
        return(false);
    }
    protected ExplorationEvent fishRiver()
    {
        ExplorationEvent e = new ExplorationEvent();

        e.description = "You see fish in the river.";
        e.options     = new List <ExplorationEvent.Option>();

        int trackingScore = 6;
        List <ExplorationCriteria> variableFishReward = new List <ExplorationCriteria>()
        {
            new ExplorationCriteria(TraitFactory.Attribute.Strength.ToString(), int.MinValue, trackingScore, new RewardImpl.RandomAnimalPenalty("You are really bad at fishing.  One of your animals managed to fall in and drown.")),
            new ExplorationCriteria(TraitFactory.Attribute.Strength.ToString(), trackingScore, trackingScore * 2, new RewardImpl.DoNothingReward("The fish gets away.")),
            new ExplorationCriteria(TraitFactory.Attribute.Strength.ToString(), trackingScore * 2, trackingScore * 6, new RewardImpl.FoodReward(4, "You catch a small fish and gain 4 food.")),
            new ExplorationCriteria(TraitFactory.Attribute.Strength.ToString(), trackingScore * 2, int.MaxValue, new RewardImpl.FoodReward(12, "You catch a large fish and gain 12 food."))
        };

        e.options.Add(new ExplorationEvent.Option("Walk away.", TraitFactory.Attribute.Tracking.ToString(), 0, new RewardImpl.DoNothingReward("You walk away."), new RewardImpl.DoNothingReward("You walk away.")));

        e.options.Add(new ExplorationEvent.Option("Try to catch the fish.", variableFishReward));

        e.options.Add(
            new ExplorationEvent.Option("Send in your swimming animal.", TraitFactory.Attribute.Tracking.ToString(), 10, new RewardImpl.FoodReward(12, "You catch a large fish and gain 12 food."), new RewardImpl.FoodReward(4, "You catch a large fish and gain 4 food."), new List <string>()
        {
            TraitFactory.Traits.Swim.ToString()
        }));
        return(e);
    }
Ejemplo n.º 6
0
    protected ExplorationEvent attackedBy(SpeciesFactory.Species species, int numAttackers, string trumpOption)
    {
        ExplorationEvent e = new ExplorationEvent();

        AnimalDef animalReward = AnimalDefFactory.CreateDefForSpecies(species);

        int foodReward = animalReward.GetAttributeScore(TraitFactory.Attribute.Food.ToString()) * numAttackers;

        string foodString = "";

        if (numAttackers == 1)
        {
            e.description = "You are attacked by a wild " + species.ToString();
            foodString    = "You killed the " + species.ToString() + " and harvest its meat to feed your animals";
        }
        else
        {
            e.description = "You are attacked by a pack of " + numAttackers + " wild " + species.ToString();
            foodString    = "You killed every last " + species.ToString() + " and make a meal of their corpses.  you collect a feast of " + foodReward + " food.";
        }

        e.options = new List <ExplorationEvent.Option>();

        int fightScore    = Mathf.FloorToInt(animalReward.GetAttributeScore(TraitFactory.Attribute.Fighting.ToString()) * (0.5f + numAttackers));
        int trackingScore = animalReward.GetAttributeScore(TraitFactory.Attribute.Tracking.ToString());



        List <ExplorationCriteria> variableAnimalReward = new List <ExplorationCriteria>()
        {
            new ExplorationCriteria(TraitFactory.Attribute.Fighting.ToString(), int.MinValue, fightScore * 2, new RewardImpl.RandomAnimalPenalty("The pack of wild " + species.ToString() + " tear one of your animals apart.")),
            new ExplorationCriteria(TraitFactory.Attribute.Fighting.ToString(), fightScore * 2, fightScore * 2 + 3, new RewardImpl.FoodPenalty(25,
                                                                                                                                               "The " + species.ToString() + " nearly killed you.  Before you dealt the winning blow it tore into your pack and scatterd your suppplies.  You lost 25 food.")),
            new ExplorationCriteria(TraitFactory.Attribute.Fighting.ToString(), fightScore * 2 + 3, int.MaxValue, new RewardImpl.FoodReward(foodReward, foodString))
        };

        List <ExplorationCriteria> variableTrackingReward = new List <ExplorationCriteria>()
        {
            new ExplorationCriteria(TraitFactory.Attribute.Tracking.ToString(), int.MinValue, trackingScore, new RewardImpl.RandomAnimalPenalty("You did not run faster than the pack of wild " + species.ToString() + ".")),
            new ExplorationCriteria(TraitFactory.Attribute.Tracking.ToString(), trackingScore, trackingScore * 2,
                                    new RewardImpl.FoodPenalty(animalReward.GetAttributeScore(TraitFactory.Attribute.Food.ToString()), "You drop some of your supplies as you run.  You lose " + animalReward.GetAttributeScore(TraitFactory.Attribute.Food.ToString()) + " food")),
            new ExplorationCriteria(TraitFactory.Attribute.Tracking.ToString(), trackingScore * 2, int.MaxValue, new RewardImpl.DoNothingReward("You escape without losing any of your animals"))
        };


        e.options.Add(new ExplorationEvent.Option("Stand your ground.", variableAnimalReward));
        e.options.Add(new ExplorationEvent.Option("Run like the wind.", variableTrackingReward));

        if (trumpOption != null)
        {
            e.options.Add(
                new ExplorationEvent.Option("Lucky for you, " + species.ToString() + " are afraid of " + trumpOption + ", you can scare them away.", TraitFactory.Attribute.Fighting.ToString(), 0, new RewardImpl.AnimalReward(animalReward), new RewardImpl.DoNothingReward("Nothing interesting happens."), new List <string>()
            {
                trumpOption
            }));
        }

        return(e);
    }
Ejemplo n.º 7
0
 /// <summary>
 /// @event를 등장시킨다.
 /// </summary>
 /// <param name="event"></param>
 private void AppearEvent(ExplorationEvent @event)
 {
     if (phaseState != PhaseState.ItemDiscovery1 && phaseState != PhaseState.FinishingExploration)
     {
         GameManager.Inst.OnTurnOver(1);
     }
     objectState = ObjectState.EventIsAppeared;
     ExplorationUIManager.Inst.NoticeEvent(@event);
     ExplorationUIManager.Inst.AddResultOptionsToButton(@event);
 }
Ejemplo n.º 8
0
    public override void Step()
    {
        switch (state)
        {
        case State.Start:
            string remaining = "";
            foreach (GameObject partyMember in worldState.GetParty().GetMembers())
            {
                Animal a = partyMember.GetComponent <Animal>();
                remaining += a.SpeciesTrait.name + ", ";
            }
            Debug.Log("party: " + remaining);
            state = State.Continue;
            break;

        case State.Continue:
            currentEvent = regionFactory.getEvent(worldState);
            for (int i = 0; i < currentEvent.options.Count; i++)
            {
                Debug.Log("   press " + (i + 1) + " to " + currentEvent.options[i].description);
            }
            ExplorePanelBehavior.Instance.Draw(currentEvent, this);
            state = State.EncounterEvent;
            break;

        case State.EncounterEvent:
            if (Input.GetKeyUp(KeyCode.Alpha1))
            {
                attempt(0);
            }
            else if (Input.GetKeyUp(KeyCode.Alpha2))
            {
                attempt(1);
            }
            else if (Input.GetKeyUp(KeyCode.Alpha3))
            {
                attempt(2);
            }
            break;

        case State.AfterEvent:
            //Debug.Log("Should display results now");
            //ExplorePanelBehavior.Instance.Results(currentEvent, this);
            break;

        case State.GoingHome:
            Debug.Log("Out of food, time to go home");
            GameManager.Instance.GoHome();
            break;

        default:
            break;
        }
    }
Ejemplo n.º 9
0
 protected override void FinishEvent(ExplorationEvent nextEvent = null, bool isReturnHome = false)
 {
     _isEncountered = true;
     //if(nextEvent == null)
     //{
     //    Debug.LogError("nextEvent is not assigned : " + eventName);
     //    return;
     //}
     UnlockLinkedEvent();
     ExplorationManager.Inst.FinishEvent(phase, nextEvent, isReturnHome);
 }
Ejemplo n.º 10
0
    protected ExplorationEvent findACave(SpeciesFactory.Species species)
    {
        ExplorationEvent e = new ExplorationEvent();

        AnimalDef animalReward = AnimalDefFactory.CreateDefForSpecies(species);

        e.description = "You come across a cave, the opening looks treacherous. You think you hear an animal inside.";
        e.options     = new List <ExplorationEvent.Option>();

        List <AnimalDef> twoAnimals = new List <AnimalDef>()
        {
            animalReward, animalReward
        };


        int strengthScore = animalReward.GetAttributeScore(TraitFactory.Attribute.Strength.ToString());

        List <ExplorationCriteria> variableAnimalReward = new List <ExplorationCriteria>()
        {
            new ExplorationCriteria(TraitFactory.Attribute.Tracking.ToString(), int.MinValue, strengthScore, new RewardImpl.RandomAnimalPenalty("Somestimes things go into a cave, but don't come out.")),
            new ExplorationCriteria(TraitFactory.Attribute.Tracking.ToString(), strengthScore, strengthScore * 3, new RewardImpl.DoNothingReward("You can't clear the entrance.")),
            new ExplorationCriteria(TraitFactory.Attribute.Tracking.ToString(), strengthScore * 3, strengthScore * 6, new RewardImpl.AnimalReward(animalReward, "You find a baby " + species.ToString() + " in the cave.")),
            new ExplorationCriteria(TraitFactory.Attribute.Tracking.ToString(), strengthScore * 6, int.MaxValue, new RewardImpl.AnimalReward(twoAnimals))
        };

        e.options.Add(new ExplorationEvent.Option("Attempt to clear the entrance.", variableAnimalReward));

        int trackingScore = animalReward.GetAttributeScore(TraitFactory.Attribute.Tracking.ToString());

        List <ExplorationCriteria> variableTrackingReward = new List <ExplorationCriteria>()
        {
            new ExplorationCriteria(TraitFactory.Attribute.Tracking.ToString(), int.MinValue, trackingScore, new RewardImpl.RandomAnimalPenalty()),
            new ExplorationCriteria(TraitFactory.Attribute.Tracking.ToString(), trackingScore, trackingScore * 3, new RewardImpl.DoNothingReward("You don't find another way in.")),
            new ExplorationCriteria(TraitFactory.Attribute.Tracking.ToString(), trackingScore * 3, trackingScore * 6, new RewardImpl.AnimalReward(animalReward)),
            new ExplorationCriteria(TraitFactory.Attribute.Tracking.ToString(), trackingScore * 6, int.MaxValue, new RewardImpl.AnimalReward(twoAnimals, "There were 2 of them in there.  You capture 2 baby " + species.ToString() + "."))
        };

        e.options.Add(new ExplorationEvent.Option("Attempt to find another way in.", variableTrackingReward));

        e.options.Add(new ExplorationEvent.Option("Walk away.", TraitFactory.Attribute.Tracking.ToString(), 0, new RewardImpl.DoNothingReward("You walk away."), new RewardImpl.DoNothingReward("You walk away.")));
        e.options.Add(
            new ExplorationEvent.Option("Send your climbing creature in.", TraitFactory.Attribute.Tracking.ToString(), trackingScore - 2, new RewardImpl.AnimalReward(animalReward, "Your climbing creature leads the way and finds a baby " + species.ToString() + "."),
                                        new RewardImpl.RandomAnimalPenalty("Even with a climbing creature to guide you, caves can still be hazzardous."), new List <string>()
        {
            TraitFactory.Traits.Climb.ToString()
        }));
        e.options.Add(
            new ExplorationEvent.Option("Dig through the rubble.", TraitFactory.Attribute.Strength.ToString(), strengthScore - 2, new RewardImpl.AnimalReward(animalReward, "You dig and dig until you find a baby " + species.ToString() + "."), new RewardImpl.DoNothingReward("You don't find anything."), new List <string>()
        {
            TraitFactory.Traits.Dig.ToString()
        }));
        return(e);
    }
Ejemplo n.º 11
0
    /// <summary>
    /// event선택이 종료된 후 후처리를 담당한다.
    /// </summary>
    /// <param name="nextEvent">nextEvent가 있는 경우에 nextEvent를 실행, RandomEncounter임에도 nextEvent가 없는 경우에 랜덤 인카운터를 한 번더 실행</param>
    /// <param name="isReturnHome"></param>
    public void FinishEvent(ExplorationEvent.EventPhase eventPhase, ExplorationEvent nextEvent = null, bool isReturnHome = false)
    {
        ExplorationUIManager.Inst.RemoveEventsFromButton();
        _currentEvent = null;
        switch (eventPhase)
        {
        case ExplorationEvent.EventPhase.SearchingItem:
            explorationCnt++;
            StartCoroutine(ExplorationUIManager.Inst.WaitForEncounter(_timeInterval));
            objectState = ObjectState.SearchNextEvent;
            ChangeToFollowingState();
            Debug.Log(phaseState);
            SelectEvent();
            break;

        case ExplorationEvent.EventPhase.RandomEncounter:
            explorationCnt++;
            if (nextEvent != null)
            {
                SkipInterval();
            }
            else
            {
                StartCoroutine(ExplorationUIManager.Inst.WaitForEncounter(_timeInterval));
            }
            objectState = ObjectState.SearchNextEvent;
            if (nextEvent != null)
            {
                if (nextEvent.phase != ExplorationEvent.EventPhase.RandomEncounter)
                {
                    ChangeToFollowingState();
                }
            }
            Debug.Log(phaseState);
            SelectEvent(nextEvent);
            break;

        case ExplorationEvent.EventPhase.FinishingExploration:
            if (!isReturnHome)
            {
                StartCoroutine(ExplorationUIManager.Inst.WaitForEncounter(_timeInterval));
                objectState = ObjectState.SearchNextEvent;
                ChangeToFollowingState();
                Debug.Log(phaseState);
                SelectEvent();
            }
            break;
        }
    }
    /// <summary>
    /// event의 optionTexts를 option 버튼에 표시한다.
    /// </summary>
    /// <param name="optionTexts"></param>
    private void NoticeOptions(ExplorationEvent @event)
    {
        List <string> optionTexts = @event.optionTexts;

        for (int i = 0; i < optionTexts.Count; i++)
        {
            buttonOptions[i].interactable = @event.GetOptionEnable(i);
            buttonOptions[i].transform.GetChild(0).GetComponent <Text>().text = optionTexts[i];
        }
        for (int i = optionTexts.Count; i < 4; i++)
        {
            buttonOptions[i].interactable = false;
            buttonOptions[i].transform.GetChild(0).GetComponent <Text>().text = null;
        }
    }
Ejemplo n.º 13
0
    public static void CreateEventCallback(UnityWebRequest www)
    {
        var result = JSON.Parse(www.downloadHandler.text);

        UsersApi.ExplorationEvent thisEvent = new ExplorationEvent();
        thisEvent.explorationEventId = result ["id"];
        thisEvent.name        = result ["name"];
        thisEvent.description = result ["description"];
        //Add the evento to the Exploration Event Manager
        myExplorationEventManager.newestEventId = thisEvent.explorationEventId;
        myExplorationEventManager.insertToQueue(thisEvent);
        //Log the Enqueued Event
        Debug.Log("Exploration Event Enqueued print:");
        Debug.Log(thisEvent.toString());
    }
Ejemplo n.º 14
0
    protected ExplorationEvent animalBabyFightMother(SpeciesFactory.Species species, string trumpOption)
    {
        ExplorationEvent e = new ExplorationEvent();

        AnimalDef animalReward = AnimalDefFactory.CreateDefForSpecies(species);

        e.description = "You come across a baby " + species.ToString() + ", its mother is nearby.";
        e.options     = new List <ExplorationEvent.Option>();

        List <AnimalDef> twoAnimals = new List <AnimalDef>()
        {
            animalReward, animalReward
        };

        int fightScore    = animalReward.GetAttributeScore(TraitFactory.Attribute.Fighting.ToString());
        int trackingScore = animalReward.GetAttributeScore(TraitFactory.Attribute.Tracking.ToString());

        List <ExplorationCriteria> variableAnimalReward = new List <ExplorationCriteria>()
        {
            new ExplorationCriteria(TraitFactory.Attribute.Fighting.ToString(), int.MinValue, fightScore * 2, new RewardImpl.RandomAnimalPenalty("The mother " + species.ToString() + " slaughters one of your animals before retreting to safety with her baby.")),
            new ExplorationCriteria(TraitFactory.Attribute.Fighting.ToString(), fightScore * 2, fightScore * 2 + 1, new RewardImpl.DoNothingReward("The " + species.ToString() + " looks kinda scary, and you back off.")),
            new ExplorationCriteria(TraitFactory.Attribute.Fighting.ToString(), fightScore * 2 + 1, fightScore * 4, new RewardImpl.AnimalReward(animalReward, "You feel great about killing a mother " + species.ToString() + " and enslaving her child")),
            new ExplorationCriteria(TraitFactory.Attribute.Fighting.ToString(), fightScore * 4, int.MaxValue, new RewardImpl.AnimalReward(twoAnimals, "You defeat the mother " + species.ToString() + " and notice another second baby hiding behind her corpse.  You capture 2 baby " + species.ToString()))
        };

        List <ExplorationCriteria> variableTrackingReward = new List <ExplorationCriteria>()
        {
            new ExplorationCriteria(TraitFactory.Attribute.Tracking.ToString(), int.MinValue, trackingScore, new RewardImpl.RandomAnimalPenalty("You're not very quiet, but don't have to run faster than the " + species.ToString() + ".  You just have to run faster than the slowest animal in your party.")),
            new ExplorationCriteria(TraitFactory.Attribute.Tracking.ToString(), trackingScore, trackingScore * 2, new RewardImpl.DoNothingReward("You escape.")),
            new ExplorationCriteria(TraitFactory.Attribute.Tracking.ToString(), trackingScore * 2, trackingScore * 4, new RewardImpl.FoodReward(animalReward.GetAttributeScore(TraitFactory.Attribute.Food.ToString()), "After you escape you find " + animalReward.GetAttributeScore(TraitFactory.Attribute.Food.ToString()) + " food with your keen tracking skills")),
            new ExplorationCriteria(TraitFactory.Attribute.Tracking.ToString(), trackingScore * 4, int.MaxValue, new RewardImpl.AnimalReward(animalReward, "You manage to grab the baby " + species.ToString() + " as you walk away without the mother even noticing"))
        };


        e.options.Add(new ExplorationEvent.Option("Grab it.  You are not afraid of a mama " + species.ToString() + ".", variableAnimalReward));
        e.options.Add(new ExplorationEvent.Option("Walk away quietly.", variableTrackingReward));

        if (trumpOption != null)
        {
            e.options.Add(
                new ExplorationEvent.Option("Because you have " + trumpOption + ", you can scare the mom away.", TraitFactory.Attribute.Fighting.ToString(), 0, new RewardImpl.AnimalReward(animalReward), new RewardImpl.DoNothingReward("Nothing interesting happens."), new List <string>()
            {
                trumpOption
            }));
        }

        return(e);
    }
Ejemplo n.º 15
0
    public ExplorationEvent getEvent(WorldState ws)
    {
        if (explorationEvents.Count == 0)
        {
            Init();
        }
        for (int tries = 0; tries < 50; tries++)
        {
            int index          = Random.Range(0, explorationEvents.Count);
            ExplorationEvent e = explorationEvents[index];
            if (e.precondition.check(ws))
            {
                return(e);
            }
        }

        Debug.Log("This is highly improbable");
        return(null);
    }
Ejemplo n.º 16
0
 /// <summary>
 /// 다음으로 등장할 Event를 선택한다.
 /// </summary>
 /// <param name="event">현재 이벤트로 결정된 이벤트</param>
 public void SelectEvent(ExplorationEvent @event = null)
 {
     if (@event != null)
     {
         _currentEvent = @event;
         return;
     }
     if (phaseState == PhaseState.FinishingExploration)
     {
         _currentEvent = _currentRegion.finishExplorationEvents[0];
     }
     else if (phaseState == PhaseState.ItemDiscovery1 || phaseState == PhaseState.ItemDiscovery2)
     {
         _currentEvent = SelectEventFromArray(_itemDiscoveryEvents);
     }
     else if (phaseState == PhaseState.RandomEncounter)
     {
         _currentEvent = SelectEventFromArray(_randomEncounterEvents);
     }
 }
 /// <summary>
 /// option을 선택했을 때 event의 결과를 Button에 등록한다.
 /// </summary>
 private void AddResultEventsToButton(ExplorationEvent @event)
 {
     Debug.Log(@event.name);
     if (@event.OptionNumber >= 0)
     {
         buttonOptions[0].onClick.AddListener(@event.Option0);
         if (@event.OptionNumber >= 1)
         {
             buttonOptions[1].onClick.AddListener(@event.Option1);
             if (@event.OptionNumber >= 2)
             {
                 buttonOptions[2].onClick.AddListener(@event.Option2);
                 if (@event.OptionNumber >= 3)
                 {
                     buttonOptions[3].onClick.AddListener(@event.Option3);
                 }
             }
         }
     }
 }
 /// <summary>
 /// UI에 @event에 관련한 텍스트, 이미지를 출력한다.
 /// </summary>
 public void NoticeEvent(ExplorationEvent @event)
 {
     Debug.Log("발생한 이벤트 : " + @event.titleText);
     NoticeEventText(@event.titleText);
     if (@event.phase == ExplorationEvent.EventPhase.SearchingItem)
     {
         ItemDiscoveryEvent itemDiscoveryEvent = (ItemDiscoveryEvent)@event;
         if (itemDiscoveryEvent.foundItem != null)
         {
             NoticeEventItemImage(itemDiscoveryEvent.foundItem.itemImage);
         }
     }
     NoticeEventText(@event.content);
     if (@event.name == "최초 탐사 시작" || @event.id == 100000)
     {
         NoticeEventText(" ");
         NoticeEventText(" ");
         NoticeEventText(" ");
         NoticeEventText(" ");
     }
     NoticeOptions(@event);
 }
Ejemplo n.º 19
0
    protected ExplorationEvent babyInATree(SpeciesFactory.Species species)
    {
        ExplorationEvent e = new ExplorationEvent();

        AnimalDef animalReward = AnimalDefFactory.CreateDefForSpecies(species);

        e.description = "You come across a baby " + species.ToString() + " in a tree.";
        e.options     = new List <ExplorationEvent.Option>();

        List <AnimalDef> twoAnimals = new List <AnimalDef>()
        {
            animalReward, animalReward
        };

        int trackingScore = animalReward.GetAttributeScore(TraitFactory.Attribute.Tracking.ToString());

        List <ExplorationCriteria> variableAnimalReward = new List <ExplorationCriteria>()
        {
            new ExplorationCriteria(TraitFactory.Attribute.Tracking.ToString(), int.MinValue, trackingScore, new RewardImpl.RandomAnimalPenalty("You discover that falling from a tree can be fatal.")),
            new ExplorationCriteria(TraitFactory.Attribute.Tracking.ToString(), trackingScore, trackingScore * 2, new RewardImpl.DoNothingReward("You can't reach it.")),
            new ExplorationCriteria(TraitFactory.Attribute.Tracking.ToString(), trackingScore * 2, trackingScore * 5, new RewardImpl.AnimalReward(animalReward, "You 'rescue' the baby " + species.ToString() + ".  It will never have suffer the pains of freedom again.")),
            new ExplorationCriteria(TraitFactory.Attribute.Tracking.ToString(), trackingScore * 5, int.MaxValue, new RewardImpl.AnimalReward(twoAnimals, "There were 2 of them up there.  You capture 2 baby " + species.ToString() + "."))
        };

        e.options.Add(new ExplorationEvent.Option("Attempt to climb the tree to get it.", variableAnimalReward));
        e.options.Add(new ExplorationEvent.Option("Walk away.", TraitFactory.Attribute.Tracking.ToString(), 0, new RewardImpl.DoNothingReward("You walk away."), new RewardImpl.DoNothingReward("You walk away.")));
        e.options.Add(
            new ExplorationEvent.Option("Send your climbing creature after it.", TraitFactory.Attribute.Tracking.ToString(), 0, new RewardImpl.AnimalReward(animalReward, "Your climbing creature brings the baby " + species.ToString() + " down from the tree"), new RewardImpl.AnimalReward(animalReward), new List <string>()
        {
            TraitFactory.Traits.Climb.ToString()
        }));
        e.options.Add(
            new ExplorationEvent.Option("Send your flying creature after it.", TraitFactory.Attribute.Tracking.ToString(), 0, new RewardImpl.AnimalReward(animalReward, "Your flying creature brings the baby " + species.ToString() + " down from the tree"), new RewardImpl.AnimalReward(animalReward), new List <string>()
        {
            TraitFactory.Traits.Flying.ToString()
        }));
        return(e);
    }
    protected ExplorationEvent babyIslandSwim(SpeciesFactory.Species species)
    {
        ExplorationEvent e = new ExplorationEvent();

        AnimalDef animalReward = AnimalDefFactory.CreateDefForSpecies(species);

        e.description = "You come across a baby " + species.ToString() + " on an island.";
        e.options     = new List <ExplorationEvent.Option>();

        List <AnimalDef> twoAnimals = new List <AnimalDef>()
        {
            animalReward, animalReward
        };

        int strengthScore = animalReward.GetAttributeScore(TraitFactory.Attribute.Strength.ToString());

        List <ExplorationCriteria> variableAnimalReward = new List <ExplorationCriteria>()
        {
            new ExplorationCriteria(TraitFactory.Attribute.Strength.ToString(), int.MinValue, strengthScore, new RewardImpl.RandomAnimalPenalty("The current was too swift.")),
            new ExplorationCriteria(TraitFactory.Attribute.Strength.ToString(), strengthScore, strengthScore * 2, new RewardImpl.DoNothingReward("The tree doesn't budge.")),
            new ExplorationCriteria(TraitFactory.Attribute.Strength.ToString(), strengthScore * 2, int.MaxValue, new RewardImpl.AnimalReward(animalReward, "You crosses the water and captured a baby " + species.ToString()))
        };

        e.options.Add(new ExplorationEvent.Option("There is a tree nearby, you can try to push it over.", variableAnimalReward));
        e.options.Add(new ExplorationEvent.Option("Walk away.", TraitFactory.Attribute.Tracking.ToString(), 0, new RewardImpl.DoNothingReward("You walk away."), new RewardImpl.DoNothingReward("You walk away.")));

        e.options.Add(
            new ExplorationEvent.Option("Because you have swim, you can reach the island and get the baby.", TraitFactory.Attribute.Fighting.ToString(), 0, new RewardImpl.AnimalReward(animalReward), new RewardImpl.AnimalReward(animalReward), new List <string>()
        {
            TraitFactory.Traits.Swim.ToString()
        }));
        e.options.Add(
            new ExplorationEvent.Option("Because you have flying, you can reach the island and get the baby.", TraitFactory.Attribute.Fighting.ToString(), 0, new RewardImpl.AnimalReward(animalReward), new RewardImpl.AnimalReward(animalReward), new List <string>()
        {
            TraitFactory.Traits.Flying.ToString()
        }));
        return(e);
    }
    protected ExplorationEvent animalStuckMud()
    {
        ExplorationEvent e = new ExplorationEvent();

        e.description = "One of your animals gets stuck in deep mud. If you can't get it out, you'll have to leave it behind.";
        e.options     = new List <ExplorationEvent.Option>();

        int strengthScore = 10;
        List <ExplorationCriteria> variableStuckReward = new List <ExplorationCriteria>()
        {
            new ExplorationCriteria(TraitFactory.Attribute.Strength.ToString(), int.MinValue, strengthScore, new RewardImpl.RandomAnimalPenalty("The Earth itself has swallowed one of your animals.")),
            new ExplorationCriteria(TraitFactory.Attribute.Strength.ToString(), strengthScore, int.MaxValue, new RewardImpl.DoNothingReward("You get the animal free."))
        };

        e.options.Add(new ExplorationEvent.Option("Pull the animal out.", variableStuckReward));

        e.options.Add(
            new ExplorationEvent.Option("Dig the animal out.", TraitFactory.Attribute.Fighting.ToString(), 0, new RewardImpl.DoNothingReward("You get the animal free."), new RewardImpl.DoNothingReward("You get the animal free."), new List <string>()
        {
            TraitFactory.Traits.Dig.ToString()
        }));
        return(e);
    }
 /// <summary>
 /// 선택지가 선택되었을 때 발생하는 결과 텍스트 출력 이벤트를 버튼에 등록한다.
 /// </summary>
 private void AddResultTextsToButton(ExplorationEvent @event)
 {
     //if (@event.phase != ExplorationEvent.EventPhase.FinishingExploration && !ExplorationManager.Inst.GetIsOverwork())
     if (@event.phase != ExplorationEvent.EventPhase.FinishingExploration)
     {
         if (@event.OptionNumber >= 0)
         {
             buttonOptions[0].onClick.AddListener(() => NoticeEventText(@event.optionResultTexts[0]));
             if (@event.OptionNumber >= 1)
             {
                 buttonOptions[1].onClick.AddListener(() => NoticeEventText(@event.optionResultTexts[1]));
                 if (@event.OptionNumber >= 2)
                 {
                     buttonOptions[2].onClick.AddListener(() => NoticeEventText(@event.optionResultTexts[2]));
                     if (@event.OptionNumber >= 3)
                     {
                         buttonOptions[3].onClick.AddListener(() => NoticeEventText(@event.optionResultTexts[3]));
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 23
0
    public static void GetEventCallback(UnityWebRequest www)
    {
        string events_json = www.downloadHandler.text;

        Debug.Log("Object state: ");
        Debug.Log(events_json);
        var result = JSON.Parse(events_json);
        int last   = result[result.Count - 1]["id"].AsInt;

        myExplorationEventManager.newestEventId = last;

        if (last > myExplorationEventManager.lastProcessedEventId)
        {
            // put in queue
            for (int i = 0; i < last - myExplorationEventManager.lastProcessedEventId; i++)
            {
                ExplorationEvent ev = new ExplorationEvent();
                ev.explorationEventId = result[result.Count - 1 - i]["id"].AsInt;
                ev.name        = result[result.Count - 1 - i]["name"];
                ev.description = result[result.Count - 1 - i]["description"];
                myExplorationEventManager.insertToQueue(ev);
            }
        }
    }
 protected override void FinishEvent(ExplorationEvent nextEvent = null, bool isReturnHome = false)
 {
     ExplorationManager.Inst.FinishEvent(phase, nextEvent, isReturnHome);
 }
 /// <summary>
 /// @event의 option을 선택했을 때 일어나는 일을 Button에 등록한다.
 /// </summary>
 /// <param name="event"></param>
 public void AddResultOptionsToButton(ExplorationEvent @event)
 {
     //AddResultTextsToButton(@event);
     AddResultEventsToButton(@event);
 }
 /// <summary>
 /// 이벤트가 종료되었을 때 해야하는 작업을 명시한다.
 /// SelectNextEvent가 마지막에 와야 한다.
 /// </summary>
 protected abstract void FinishEvent(ExplorationEvent nextEvent = null, bool isReturnHome = false);
Ejemplo n.º 27
0
    protected ExplorationEvent rescueFromQuicksand(SpeciesFactory.Species species, int numAttackers = 1)
    {
        ExplorationEvent e = new ExplorationEvent();

        AnimalDef animalReward = AnimalDefFactory.CreateDefForSpecies(species);

        int foodReward = animalReward.GetAttributeScore(TraitFactory.Attribute.Food.ToString()) * numAttackers;

        string foodString = "";

        if (numAttackers == 1)
        {
            e.description = "You see a " + species.ToString() + " trapped in the quicksand";
            foodString    = "You rescued the " + species.ToString() + " and harvest its meat to feed your animals";
        }
        else
        {
            e.description = "You see " + numAttackers + " " + species.ToString() + " trapped in the quicksand";
            foodString    = "You killed every last " + species.ToString() + " and make a meal of their corpses.  you collect a feast of " + foodReward + " food.";
        }

        string tameString = "";

        if (numAttackers == 1)
        {
            e.description = "You see a " + species.ToString() + " trapped in the quicksand";
            tameString    = "You rescued the " + species.ToString() + " and it joins you.";
        }
        else
        {
            e.description = "You see " + numAttackers + " " + species.ToString() + " trapped in the quicksand";
            tameString    = "You rescued every last " + species.ToString() + " and they join you.";
        }

        e.options = new List <ExplorationEvent.Option>();

        int trackingScore = Mathf.FloorToInt(animalReward.GetAttributeScore(TraitFactory.Attribute.Tracking.ToString()) * (0.5f + numAttackers));
        //int trackingScore = animalReward.GetAttributeScore(TraitFactory.Attribute.Tracking.ToString());


        List <ExplorationCriteria> variableFoodReward = new List <ExplorationCriteria>()
        {
            new ExplorationCriteria(TraitFactory.Attribute.Tracking.ToString(), int.MinValue, trackingScore * 2, new RewardImpl.RandomAnimalPenalty()),
            new ExplorationCriteria(TraitFactory.Attribute.Tracking.ToString(), trackingScore * 2, trackingScore * 2 + 3, new RewardImpl.FoodPenalty(25,
                                                                                                                                                     "The quicksand nearly killed you and claimed some of your supplies.  You lost 25 food.")),
            new ExplorationCriteria(TraitFactory.Attribute.Tracking.ToString(), trackingScore * 2 + 3, int.MaxValue, new RewardImpl.FoodReward(foodReward, foodString))
        };

        List <ExplorationCriteria> variableRescueReward = new List <ExplorationCriteria>()
        {
            new ExplorationCriteria(TraitFactory.Attribute.Tracking.ToString(), int.MinValue, trackingScore * 3, new RewardImpl.RandomAnimalPenalty()),
            new ExplorationCriteria(TraitFactory.Attribute.Tracking.ToString(), trackingScore * 3, trackingScore * 3 + 3, new RewardImpl.FoodPenalty(25,
                                                                                                                                                     "The quicksand nearly killed you and claimed some of your supplies.  You lost 25 food.")),
            new ExplorationCriteria(TraitFactory.Attribute.Tracking.ToString(), trackingScore * 3 + 3, int.MaxValue, new RewardImpl.AnimalReward(animalReward, tameString))
        };


        e.options.Add(new ExplorationEvent.Option("Your animals are hungry.  Let's try to get some meat.", variableFoodReward));
        e.options.Add(new ExplorationEvent.Option("The " + species.ToString() + " look like great new travel companions. Maybe if we rescue them, they will join our cause?", variableRescueReward));
        e.options.Add(new ExplorationEvent.Option("Do Nothing.",
                                                  new ExplorationCriteria(TraitFactory.Attribute.Tracking.ToString(), int.MinValue, int.MaxValue, new RewardImpl.DoNothingReward())
                                                  ));

        return(e);
    }
Ejemplo n.º 28
0
    void Update()
    {
        currentObjectId = myExplorationObject.explorationObjectId;

        if (myUser.isAdmin && !exploration)
        {
            createExploration(myUser.user_id);
            exploration = true;
            model.GetComponent <Model>().student = false;
        }
        else if (isStudent && !exploration)
        {
            // get newest entry for exploration
            getExplorations();
            exploration = true;
        }

        if (myUser.isAdmin && myExplorationObject.explorationObjectId != -1 && !teacherExplorationObject)
        {
            teacherExplorationObject = true;
            createExplorationObject();
            currentObjectId = myExplorationObject.explorationObjectId;
        }

        if (exploration && teacherExplorationObject && (oldObjectId != currentObjectId))
        {
            oldObjectId = currentObjectId;
            updateExplorationObject(myExploration.explorationId, myExplorationObject.explorationObjectId);
            createExplorationEvent("setExplorationObject", myExplorationObject.explorationObjectId.ToString());
        }

        // teacher updates teacher's object

        string modelName = "";

        if (model.GetComponent <Model>().modelID == 0)
        {
            modelName = "desk";
        }
        else if (model.GetComponent <Model>().modelID == 1)
        {
            modelName = "dinosaur";
        }
        else
        {
            modelName = "dna";
        }

        if (myUser.isAdmin && teacherExplorationObject &&
            (myExplorationObject.modelName.Equals(modelName)))
        {
            string parameters = "";
            parameters  = model.GetComponent <Model>().model.transform.position.ToString("F4");
            parameters += ";";
            parameters += model.GetComponent <Model>().model.transform.rotation.ToString("F4");
            parameters += ";";
            parameters += model.GetComponent <Model>().model.transform.localScale.ToString("F4");

            updateObject(myExplorationObject.explorationObjectId, parameters);
        }

        // group members update group object

        // guided exploration
        if (myExploration.explorationMode == 0 && !myUser.isAdmin && exploration)
        {
            model.GetComponent <Model>().setModel(myModelType);

            getExplorationObjectState(myExploration.explorationObjectId);
            model.GetComponent <Model>().setPosition(myPosition);
            model.GetComponent <Model>().setRotation(myRotation);
            model.GetComponent <Model>().setScale(myScale);
        }


        if (myExplorationEventManager.awaitingProcessEventsQueue.Count > 0)
        {
            ExplorationEvent ev = myExplorationEventManager.awaitingProcessEventsQueue.Dequeue();
            if (ev.name.Equals("setExplorationObject"))
            {
            }
            else
            {
            }
        }
    }