Ejemplo n.º 1
0
    //events
    public void DecideOnRandomEnvrionmentalEvent(bool isDay)
    {
        if ((isDay && dayEvent != null) || (!isDay && nightEvent != null)) //means something else already set an event for that period
        {
            return;
        }

        float dieRoll = Random.Range(0.0f, 1.0f);

        string[] eventsList = isDay? EventsLists.environmentalEventsDay : EventsLists.environmentalEventsNight;

        if (dieRoll < simParam.randomEnvironmentalEventProbability && eventsList.Length > 0)
        {
            int id = Random.Range(0, eventsList.Length);

            GameObject eventHolder = new GameObject("event_" + id.ToString());
            eventHolder.transform.position = Vector3.zero;
            eventHolder.transform.SetParent(this.transform);
            eventHolder.name += isDay? "_day" : "_night";
            ScenarioEvent newEvent = (ScenarioEvent)eventHolder.AddComponent(System.Type.GetType(eventsList[id]));

            if (newEvent.CheckRequirement())
            {
                AddScenarioEvent(newEvent, isDay);
            }
            else
            {
                Destroy(eventHolder);
            }
        }
    }
Ejemplo n.º 2
0
 public static void AddEvent(ScenarioEvent newEvent, bool isIntro = false)
 {
     if (instance != null && instance.isIntro && !isIntro)
     {
         return;
     }
     events.Add(newEvent);
 }
Ejemplo n.º 3
0
    public void StartWorkDay()
    {
        dayEvent   = null;
        nightEvent = null;

        workingAnimation = StartCoroutine(WorkAnimation());
        workingProcess   = StartCoroutine(WorkProcess());
    }
Ejemplo n.º 4
0
    public void Hide()
    {
        foreach (Transform child in this.transform)
        {
            child.gameObject.SetActive(false);
        }

        this.gameObject.GetComponent <RawImage>().enabled = false;
        shownEvent = null;
    }
Ejemplo n.º 5
0
        public void Scenario(Token keyword, Token title)
        {
            var scenario = new Scenario(title.Content, file, currentFeature, keyword.LineInFile.Line);

            currentScenario = scenario;
            events.Enqueue(new ScenarioEvent(currentScenario, e =>
            {
                scenario.AddTags(e.Tags);
                ScenarioEvent.Invoke(this, new EventArgs <Scenario>(scenario));
            }));
        }
Ejemplo n.º 6
0
    public void HandleBankrupcy()
    {
        //Similar rationale to HandleWinning().

        print("Player is bankrupt");
        currentGameState = GameState.endGame;

        GameObject    eventHolder = Instantiate(new GameObject("GameOver_Bankrupcy"), Vector3.zero, new Quaternion(), this.transform);
        ScenarioEvent newEvent    = (ScenarioEvent)eventHolder.AddComponent(typeof(Bankrupcy));

        simMan.AddScenarioEvent(newEvent, true);
    }
Ejemplo n.º 7
0
    //Win/Lose cases
    public void HandleWinning()
    {
        //This method is callled at WorkProcess(), before dayEvent is processed. So, we simply override whatever event that may have been set with a Winning event,
        //and let it handle game loss display.
        print("Player has won");
        currentGameState = GameState.endGame;

        GameObject    eventHolder = Instantiate(new GameObject("GameOver_Win"), Vector3.zero, new Quaternion(), this.transform);
        ScenarioEvent newEvent    = (ScenarioEvent)eventHolder.AddComponent(typeof(Win));

        simMan.AddScenarioEvent(newEvent, true);
    }
Ejemplo n.º 8
0
    public void Initialize()
    {
        scenarioEvent = new ScenarioEvent();
        scenarioEvent.Initialize();
        uiEventReward.Initialize();

        foreach (var selectButton in selectButtonList)
        {
            selectButton.Initialize();
            selectButton.scenarioEvent = this.scenarioEvent;
            selectButton.uiEventReward = this.uiEventReward;
        }

        InGameManager.instance.gameState.OnPrepare += CheckScenarioDataAndSetScenarioEvent;
    }
Ejemplo n.º 9
0
    // void ProcessEvents (bool isDay)
    // {
    //     // List<ScenarioEvent> targetEventsList;
    //     // if (isDay)
    //     //     targetEventsList = dayEvents;
    //     // else
    //     //     targetEventsList = nightEvents;

    //     // foreach(ScenarioEvent scenarioEvent in targetEventsList)
    //     // {
    //     //     scenarioEvent.Play(currentDate);
    //     // }

    //     if (isDay)
    //         dayEvent.Play(currentDate);
    //     else
    //         nightEvent.Play(currentDate);
    // }

    public void FinishEvent(ScenarioEvent scenarioEvent)
    {
        if (dayEvent == scenarioEvent)
        {
            dayEvent = null;
        }
        else if (nightEvent == scenarioEvent)
        {
            nightEvent = null;
        }
        else
        {
            print("ERROR! Attempting to finish a non started event");
        }
    }
Ejemplo n.º 10
0
    public void Show(ScenarioEvent scenarioEvent)
    {
        shownEvent = scenarioEvent;

        foreach (Transform child in this.transform)
        {
            child.gameObject.SetActive(true);
        }

        this.gameObject.GetComponent <RawImage>().enabled = true;

        //get event image and description
        if (scenarioEvent.scenarioImage != null)
        {
            eventImage.rectTransform.sizeDelta = ComputeViewporteSize(new Vector2Int(scenarioEvent.scenarioImage.width, scenarioEvent.scenarioImage.height));
        }

        eventImage.texture = scenarioEvent.scenarioImage;

        SetEventDescription();
    }
Ejemplo n.º 11
0
    public void AddScenarioEvent(ScenarioEvent scenarioEvent, bool isDayEvent) //Warning! This method overrides any set event.
    {
        if (isDayEvent)
        {
            if (dayEvent != null)
            {
                dayEvent.Cancel();
            }

            dayEvent = scenarioEvent;
        }
        else
        {
            if (nightEvent != null)
            {
                nightEvent.Cancel();
            }

            nightEvent = scenarioEvent;
        }

        scenarioEvent.Initialize(currentDate);
    }