示例#1
0
 private Day(int number, Weather weather, RandomEvent randomEvent)
 {
     Number = number;
     Weather = weather;
     Event = randomEvent;
     Choices = new List<Choices>();
     Results = new List<Result>();
     LemonadeCost = number < 3 ? 2 : number < 5 ? 4 : 5;
 }
    public static int set_ExpiredTime(IntPtr l)
    {
        int result;

        try
        {
            RandomEvent randomEvent = (RandomEvent)LuaObject.checkSelf(l);
            long        expiredTime;
            LuaObject.checkType(l, 2, out expiredTime);
            randomEvent.ExpiredTime = expiredTime;
            LuaObject.pushValue(l, true);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
    public static int RandomEventsToPBRandomEvents_s(IntPtr l)
    {
        int result;

        try
        {
            List <RandomEvent> randomEvents;
            LuaObject.checkType <List <RandomEvent> >(l, 1, out randomEvents);
            List <ProRandomEvent> o = RandomEvent.RandomEventsToPBRandomEvents(randomEvents);
            LuaObject.pushValue(l, true);
            LuaObject.pushValue(l, o);
            result = 2;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
    public static int PBRandomEventToRandomEvent_s(IntPtr l)
    {
        int result;

        try
        {
            ProRandomEvent pbRadomEvent;
            LuaObject.checkType <ProRandomEvent>(l, 1, out pbRadomEvent);
            RandomEvent o = RandomEvent.PBRandomEventToRandomEvent(pbRadomEvent);
            LuaObject.pushValue(l, true);
            LuaObject.pushValue(l, o);
            result = 2;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
示例#5
0
    //Josi: atualiza o historico de jogadas (setas verdes e pretas)
    public void UpdateMenu()
    {
//		if (PlayerPrefs.GetInt ("gameSelected") == 2)  //Josi: era assim
        if ((PlayerPrefs.GetInt("gameSelected") == 2) || (PlayerPrefs.GetInt("gameSelected") == 3) || (PlayerPrefs.GetInt("gameSelected") == 5))                //Josi 161214: se JG ou MD ou Jogo da memoria
        {
            List <RandomEvent> events = manager.events;

            //Josi: no ultimo jogo entra com events.Count=0, gerando events[-1] entrando em loop com indice outOfRange **
            if (events.Count > 0)
            {
                //print (transform.parent.parent.name);
                RandomEvent e = events [events.Count - 1];

                //Josi: estes sprites estão em Sprites/Interface/Luvas* e tem o desenho da flecha, e da luva (aparentemente um bom lugar para liberar bytes)!
                //      as imagens sao trazidas da definicao no UIManager
                if (events.Count <= nShoots)
                {
                    if (e.correct)
                    {
                        elements [events.Count - 1].img.sprite = manager.rightUISprite [e.resultInt];
                    }
                    else
                    {
                        elements [events.Count - 1].img.sprite = manager.wrongUISprite [e.resultInt];
                    }
                }
                else
                {
                    if (e.correct)
                    {
                        elements [nShoots].img.sprite = manager.rightUISprite [e.resultInt];
                    }
                    else
                    {
                        elements [nShoots].img.sprite = manager.wrongUISprite [e.resultInt];
                    }

                    //anim.SetTrigger ("slide");  //170108 nao encontrado slide; as vezes gerava erro -> trocado por Reposition
                    Reposition();
                }
            }     //Josi: fim do if eventCount > 0
        }         //Josi: fim do if JG
    }
示例#6
0
    public void EnableRandomEvent()
    {
        if (_eventIndex >= _allEvents.events.Length)
        {
            return;
        }
        _currentEvent = _allEvents.events[_eventIndex];
        _eventIndex++;
        eventText.text   = _currentEvent.description;
        choiceText1.text = _currentEvent.choices[0].description + "\nCost: " + _currentEvent.choices[0].cost;
        choiceText2.text = _currentEvent.choices[1].description + "\nCost: " + _currentEvent.choices[1].cost;
        choiceText3.text = _currentEvent.choices[2].description + "\nCost: " + _currentEvent.choices[2].cost;
        effectBox.SetActive(false);

        EventMenu.SetActive(true);
        choiceText1.GetComponentInParent <Button>().Select();

        GameInitializer.SetPaused(true);
    }
    public static int set_WayPointId(IntPtr l)
    {
        int result;

        try
        {
            RandomEvent randomEvent = (RandomEvent)LuaObject.checkSelf(l);
            int         wayPointId;
            LuaObject.checkType(l, 2, out wayPointId);
            randomEvent.WayPointId = wayPointId;
            LuaObject.pushValue(l, true);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
    public static int set_DeadLives(IntPtr l)
    {
        int result;

        try
        {
            RandomEvent randomEvent = (RandomEvent)LuaObject.checkSelf(l);
            int         deadLives;
            LuaObject.checkType(l, 2, out deadLives);
            randomEvent.DeadLives = deadLives;
            LuaObject.pushValue(l, true);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
示例#9
0
    public RandomEvent GetRandomEvent()
    {
        //Debug.Log (randomEventList [randomEventIndex].descriptionText + ": " + randomEventList [randomEventIndex].effect + ", " + randomEventList [randomEventIndex].value);
        RandomEvent currentEvent = randomEventList[randomEventIndex];

        if (ResourceManager.Instance.daysLeft == 5)
        {
            string direction;
            if (ResourceManager.Instance.towerLocation.x < 5)
            {
                direction = "Western";
            }
            else
            {
                direction = "Eastern";
            }
            currentEvent.descriptionText += "\n\nYou heard rumors from postman that he spotted Tele Norland van in the " + direction + " part of the forest.";
        }
        if (ResourceManager.Instance.daysLeft == 3)
        {
            string direction;
            if (ResourceManager.Instance.towerLocation.y < 5)
            {
                direction = "Southern";
            }
            else
            {
                direction = "Northern";
            }
            currentEvent.descriptionText += "\n\nYou heard rumors from postman that he spotted Tele Norland van in the " + direction + " part of the forest.";
        }
        if (randomEventIndex < randomEventList.Count - 1)
        {
            randomEventIndex++;
        }
        else
        {
            randomEventIndex = 0;
            RandomizeList();
        }
        return(currentEvent);
    }
示例#10
0
    public static int GetRandomEvent(IntPtr l)
    {
        int result;

        try
        {
            DataSectionLevel dataSectionLevel = (DataSectionLevel)LuaObject.checkSelf(l);
            int wayPointId;
            LuaObject.checkType(l, 2, out wayPointId);
            RandomEvent randomEvent = dataSectionLevel.GetRandomEvent(wayPointId);
            LuaObject.pushValue(l, true);
            LuaObject.pushValue(l, randomEvent);
            result = 2;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
示例#11
0
 // Token: 0x06000B98 RID: 2968 RVA: 0x000532F0 File Offset: 0x000514F0
 private void SetActiveEvent(RandomEvent ev, bool end = false)
 {
     if (ev != null && this.m_activeEvent != null && ev.m_name == this.m_activeEvent.m_name)
     {
         return;
     }
     if (this.m_activeEvent != null)
     {
         this.m_activeEvent.OnDeactivate(end);
         this.m_activeEvent = null;
     }
     if (ev != null)
     {
         this.m_activeEvent = ev;
         if (this.m_activeEvent != null)
         {
             this.m_activeEvent.OnActivate();
         }
     }
 }
示例#12
0
    public static void Room(Dungeon d, Creature p, Event[] Event)
    {
        foreach (Event e in Event)
        {
            int a = e.eventType;
            switch (a)
            {
            case 0:
                Monster.opponentList = new List <Monster> {
                };
                Monster.opponentList.Add(d.boss.MonsterCopy());
                Combat.Start(p, Monster.opponentList, d);
                break;

            case 1:
                RandomEvent.Event1(d, p, e);
                break;
            }
        }
    }
示例#13
0
        public async Task StartAsync(IDialogContext context)
        {
            var user = this.GetUser(context);

            // force payback if loan outstanding
            if (user.LoanDebt > 0)
            {
                PromptDialog.Confirm(
                    context,
                    ReadyToPayAsync,
                    $"You already got a loan wit' me fer {user.LoanDebt:C0}. Ready to pay up?",
                    "Didn't hear ya'--you ready to pay or what?",
                    promptStyle: PromptStyle.None);
            }
            else
            {
                // randomize rate between 5 and 15 percent
                double rate = 0.0;
                if (!context.UserData.TryGetValue <double>(StateKeys.LoanRate, out rate) || rate == 0.0)
                {
                    rate = RandomEvent.GetRandomDoubleBetween(0.25, 0.50);
                    context.UserData.SetValue <double>(StateKeys.LoanRate, rate);
                }

                var pointsRate = (int)(rate * 100);
                var maxLoan    = user.DayOfGame * Defaults.MaxLoanMultiplier;

                // announce loan shark, explain rates
                await context.PostAsync("Here's how it's gonna work, kid. You only been here " +
                                        $"{user.DayOfGame} day{(user.DayOfGame > 1 ? "s" : string.Empty)} I'll loan ya' up to {maxLoan:C0}, " +
                                        $"but it's gonna cost ya' somethin' like {pointsRate} points a day. Capiche?");

                PromptDialog.Number(
                    context,
                    SetupLoanAsync,
                    "How much ya' want?",
                    "You stupid or somethin'? I need a number.");
            }
        }
    // A partir de um arquivo csv, verifica o status da jogada e envia as que ainda não foram enviadas à base
    public void SendFromCSVToDB(string path, out string playertoken, out int nivel)
    {
        var csv = new List <RandomEvent>();

        string[] lines = File.ReadAllLines(path);

        playertoken = lines[0].Split(',')[1];
        var game_phase = Convert.ToInt32(lines[1].Split(',')[1]);

        nivel = Convert.ToInt32(lines[2].Split(',')[1]);

        Debug.Log(playertoken + ":" + game_phase + ":" + nivel);

        lines = lines.Skip(4).ToArray();

        string[] line_aux;
        bool     status = false;

        foreach (string line in lines)
        {
            line_aux = line.Split(',');

            RandomEvent evento = new RandomEvent();
            evento.resultInt       = Convert.ToInt32(line_aux[1]);
            evento.ehRandom        = Convert.ToChar(line_aux[2]);
            evento.optionChosenInt = Convert.ToInt32(line_aux[3]);
            evento.correct         = Convert.ToBoolean(line_aux[4]);
            evento.time            = Convert.ToSingle(line_aux[5]);
            evento.pauseTime       = Convert.ToSingle(line_aux[6]);
            evento.realTime        = Convert.ToSingle(line_aux[7]);
            evento.sendedToDB      = Convert.ToBoolean(line_aux[8]);
            if (!evento.sendedToDB)
            {
                status = RegistrarJogada(playertoken, game_phase, Convert.ToInt32(line_aux[0]), evento);
            }
            Debug.Log(status);
        }
    }
示例#15
0
    // Token: 0x06000B85 RID: 2949 RVA: 0x00052BFC File Offset: 0x00050DFC
    private void SetForcedEvent(string name)
    {
        if (this.m_forcedEvent != null && name != null && this.m_forcedEvent.m_name == name)
        {
            return;
        }
        if (this.m_forcedEvent != null)
        {
            if (this.m_forcedEvent == this.m_activeEvent)
            {
                this.SetActiveEvent(null, true);
            }
            this.m_forcedEvent.OnStop();
            this.m_forcedEvent = null;
        }
        RandomEvent @event = this.GetEvent(name);

        if (@event != null)
        {
            this.m_forcedEvent = @event.Clone();
            this.m_forcedEvent.OnStart();
        }
    }
示例#16
0
    public RandomItem GetRandomItem()
    {
        RandomItem result = null;

        if (TotalValue == 0)
        {
            TotalValue = this.Sum(p => p.Probability);
        }
        int tempvalue = 0;
        int thisvalue = RandomEvent.Random(0, TotalValue);

        foreach (var tt in this)
        {
            tempvalue += tt.Probability;
            if (thisvalue < tempvalue)
            {
                result = tt;
                break;
            }
        }

        return(result);
    }
示例#17
0
    [SerializeField] private List <UncontrolledEvent> uncontrolledEvents = new List <UncontrolledEvent>(); //Events which the user has no decision over and can only accept

    private void Start()
    {
        //Sets the target game framerate
        Application.targetFrameRate = 45;

        currentCash              = 0;
        currentMood              = 0;
        currentStudyHours        = 0;
        currentDay               = 0;
        currentDate              = System.DateTime.Now;
        currentMonth             = currentDate.ToString("MMMM");
        currentEvent             = null;
        currentUncontrolledEvent = null;
        showingSummary           = false;
        showingUncontrolledEvent = false;

        //Finds a reference to UI Controller and button click audio source
        UIController           = FindObjectOfType <UIController>();
        playerPerformance      = FindObjectOfType <PlayerPerformance>();
        buttonClickAudioSource = GetComponent <AudioSource>();

        //Set up variables for first startup
        SetUpStats();
        SetUpIncome();
        SetUpDebits();

        //Sets up the pool of events to be used in-game
        BuildEventsList();

        //Select a random event from the list of events
        currentEvent = currentEvents[0];

        //Update game UI with startup information
        UIController.UpdateDateText();
        UIController.UpdateEventInformation();
        UIController.UpdateAllStatsText();
    }
示例#18
0
    private void GenerateButtons(RandomEvent eve)
    {
        foreach (var item in player.GetComponent <Player>().companions)
        {
            List <EnumSpace.EventType> companion_types = new List <EnumSpace.EventType>();
            foreach (EnumSpace.EventType reaction in item.eventReactions.Keys)
            {
                companion_types.Add(reaction);
            }

            Debug.Log(eve.type);
            if (companion_types.Contains(eve.type))
            {
                GameObject Button    = Instantiate(Resources.Load("prefab/Button"), new Vector3(0, 0, 0), Quaternion.identity) as GameObject;
                Companion  tmpitem   = item;
                GameObject tmpButton = Button;
                tmpButton.transform.SetParent(EventWindow.transform, false);
                tmpButton.GetComponent <Button>().onClick.AddListener(() => ProcessChoiseResult(eve, tmpitem));
                tmpButton.GetComponentInChildren <Text>().text = tmpitem.CompanionName + " (Chance = " + (0.2f + tmpitem.eventReactions[eve.type]) * 100 + "%)";
                tmpButtons.Add(tmpButton);
                tmpButton.SetActive(true);
            }
        }
    }
示例#19
0
    public void ChooseAndLoadRandomEvent()
    {
        _passedCheck = false;

        int temp = Random.Range(0, MapManager._events.Count);

        _event = MapManager._events[temp];

        questFrame.SetActive(true);
        questTitle.text = _event.EventTitle;
        questText.text  = _event.EventDescription;
        sm.PlaySingleEfx(2);

        EnqueueOptions();
        EnqueueChecks();

        if (_event.EventType == RandomEvent.EventTypes.CHALLENGE)
        {
            _hasCombat = true;
        }

        DestroyButtons();
        CreateButtons(_hasCombat, 2, _options, _checks);
    }
示例#20
0
 // Token: 0x06000B82 RID: 2946 RVA: 0x00052B00 File Offset: 0x00050D00
 private bool IsInsideRandomEventArea(RandomEvent re, Vector3 position)
 {
     return(position.y <= 3000f && Utils.DistanceXZ(position, re.m_pos) < this.m_randomEventRange);
 }
 public void ScheduleEvent(RandomEvent ev, float delay)
 {
     mEvents.Add(new TimedEvent(ev, delay));
 }
示例#22
0
 // Token: 0x06000B93 RID: 2963 RVA: 0x000531AD File Offset: 0x000513AD
 private bool CheckBase(RandomEvent ev, ZDO zdo)
 {
     return(ev.m_nearBaseOnly && zdo.GetInt("baseValue", 0) >= 3);
 }
示例#23
0
    // Token: 0x06000B8B RID: 2955 RVA: 0x00052F00 File Offset: 0x00051100
    public void SetRandomEventByName(string name, Vector3 pos)
    {
        RandomEvent @event = this.GetEvent(name);

        this.SetRandomEvent(@event, pos);
    }
    private void SpawnSeaGullEvent()
    {
        int startQuadrant = Random.Range(0, 4);

        Vector3 startPos = Vector3.zero;

        switch (startQuadrant) {
            case 0:
                startPos = new Vector3(Random.Range(-6f, -8f), 0, Random.Range(6f, 8f));
                break;
            case 1:
                startPos = new Vector3(Random.Range(-6f, -8f), 0, Random.Range(-6f, -8f));
                break;
            case 2:
                startPos = new Vector3(Random.Range(6f, 8f), 0, Random.Range(-6f, -8f));
                break;
            case 3:
                startPos = new Vector3(Random.Range(6f, 8f), 0, Random.Range(6f, 8f));
                break;
        }

        float amount = Random.Range(1, MaxSeagullFlockSize + 1);

        for (int i = 0; i < amount; i++) {
            var spawnPos = startPos + new Vector3(Random.Range(-1f, 1f), Random.Range(-1f, 1f), Random.Range(-1f, 1f));
            var seaGull = Instantiate(SeaGull, spawnPos, Quaternion.identity);
            Destroy(seaGull, 15f);
        }

        _curEvent = RandomEvent.Idle;
    }
示例#25
0
    void Awake()
    {
        refurbishmentTab = controller.transform.FindChild ("RefurbishmentCTR").gameObject.GetComponent<Refurbishment>();
        staffMenu = GameObject.FindGameObjectWithTag ("StaffingController").GetComponent<StaffMenu> ();
        bankingTab = controller.transform.FindChild ("BankingController").gameObject.GetComponent<BankingReport>();
        emsTab = controller.transform.FindChild("EMSController").gameObject.GetComponent<EMSReport>();
        revenueManagementTab = controller.transform.FindChild("RevenueManagerCTR").GetComponent<RevenueManagement>();
        randomEvent = controller.transform.FindChild("EventController").GetComponent<RandomEvent>();
        rateSetup = controller.transform.FindChild("RatesSetUp").GetComponent<RatesSetup>();
        groupController = controller.transform.FindChild("GroupBooking").GetComponent<GroupBookController>();
        calendarController = controller.transform.FindChild("CalendarController").GetComponent<CalendarController>();
        feedbackController = controller.transform.FindChild("FeedBackController").GetComponent<FeedbackController>();
        dataProcessor = GameObject.Find("DataCollection").GetComponent<Serializer_Deserializer>();
        assetSwapper = controller.transform.FindChild("AssetController").GetComponent<AssetSwapper>();
        toolbar = GameObject.FindGameObjectWithTag("UI").transform.FindChild("OverWorld").GetComponent<ToolbarOptions>();
        adController = controller.transform.FindChild("AdvertController").gameObject.GetComponent<Advertisment>();

        SingletonCheck();
        if(monthlyReports == null){
            monthlyReports = new List<MonthlyReport>();//create list on first run.
        }
        //Ensure there's a log for this week (special case for 1st time run)
        if (receptionLogs == null) {
            receptionLogs = new List<ReceptionLog> ();
        }
        if(restaurantBooks == null){
            restaurantBooks = new List<RestaurantBook>();//create a new list on first run.
        }
        //Ensure there's a log for this week (special case for 1st time run)
        if (staffingLogs == null) {
            staffingLogs = new List<StaffingLog> ();
        }
        //create the log once.
        if(balanceSheets == null){
            balanceSheets = new List<BalanceSheet>();//create new balance sheet list on first run.
        }
        GenerateNewMonthReports ();
        firstGeneration = true;

        medianRoomCostWD = rateSetup.medianRoomCostWD;
        medianRoomCostWE = rateSetup.medianRoomCostWE;
    }
 public TimedEvent(RandomEvent ev, float timer)
 {
     mEvent = ev;
     mTimer = timer;
     mState = EventSystemState.PENDING;
 }
    private void SpawnWhaleEvent()
    {
        _spawnPos += new Vector3(Random.Range(-0.5f, 0.5f), 0, Random.Range(-0.5f, 0.5f));
        //var whale = Instantiate(Whale, _spawnPos, Quaternion.identity) as GameObject;

        //_curDolphinInterval = 0;
        _dolphinCount++;

        _curEvent = RandomEvent.Idle;
    }
示例#28
0
 public static int CalculateSales(Choices choices, RandomEvent randomEvent)
 {
     var glassesSold = BaseSales(choices);
     glassesSold = randomEvent.Modify(glassesSold, choices);
     return (int) Math.Floor(glassesSold);
 }
	public void addEvent(RandomEvent e){
		events.Add(++currId, e);
	}
示例#30
0
        private async Task ResumeMainMenu(IDialogContext context, IAwaitable <GameState> result)
        {
            var state = await result;

            if (state.IsGameOver)
            {
                var user = this.GetUser(context);

                var score = user.Wallet;

                if (user.LoanDebt > 0)
                {
                    await context.PostAsync($"Ya' punk #$%! kid--I'm gonna break both your legs and take back my {user.LoanDebt:C0}!");

                    await context.PostAsync("The loan shark proceeds to break your legs and take his money.");

                    score = user.Wallet - user.LoanDebt;
                }

                // record log of game before resetting
                var db = new DrugBotDataContext();

                var game = new Game {
                    UserId = user.UserId, Score = score
                };
                db.Games.Add(game);
                db.Commit();

                // get their rank
                var orderedGame = db.Games
                                  .OrderByDescending(x => x.Score)
                                  .AsEnumerable()
                                  .Select((x, i) => new { Game = x, Rank = i + 1 })
                                  .Single(x => x.Game.GameId == game.GameId);

                await context.PostAsync("Game Over.");

                await context.PostAsync($"You finished with {score:C0} " +
                                        $"({StringHelper.AddOrdinal(orderedGame.Rank)} overall)");

                await this.ShowLeaderboard(context);

                await context.PostAsync("Type PLAY to start another game!");

                // reset user (this commits db changes)
                this.ResetUser(context);

                this.Done(context);
            }
            else if (state.IsTraveling)
            {
                var user = this.GetUser(context);

                // todo: random events for the day
                if (RandomEvent.IsGoingToHappen)
                {
                    // pass context and user to do db things, receive event info
                    var randomEvent = RandomEvent.Get(context, user.UserId);
                    context.UserData.SetValue(StateKeys.RandomEvent, randomEvent);
                }

                // get day and location
                var location = this.GetLocations().Single(x => x.LocationId == user.LocationId);
                await context.PostAsync($"It's day {user.DayOfGame}. You're in {location.Name}.");
                await StartAsync(context);
            }
            else
            {
                // print menu and start again--hopefully
                await StartAsync(context);
            }
        }
示例#31
0
    public void BtnActionGetEvent(string input)
    {
        print ("getting event from player");

        btnsAndQuestion.SetActive(false);

        int e = probs.GetEvent();
        print ("Resultado "+ e);
        string dirEsq = "";

        timeCount.SetActive(false);

        if(OnAnimationStarted != null)
            OnAnimationStarted();
        btnsAndQuestion.SetActive(false);

        RandomEvent eLog = new RandomEvent ();

        eLog.time = stopwatch;
        stopwatch = 0;
        eLog.resultInt = e;
        if(e == 0) //esquerda
        {
            dirEsq = "esquerda";
        }
        else if (e == 1)
        {
            dirEsq = "centro";
        }else
        {
            dirEsq = "direita";
        }

        eLog.result = dirEsq;

        eLog.optionChosen = input;

        if(input.Equals(dirEsq))
        {
            eLog.correct = true;
            success ++;
        }
        else
        {
            eLog.correct = false;
        }

        int targetAnim = probs.GetCurrMachineIndex ();
        if(targetAnim >= gkAnim.Length)
        {
            targetAnim = gkAnim.Length - 1;
        }
        if(input == "esquerda")
        {
            eLog.optionChosenInt = 0;
            if(eLog.correct)
            {
                gkAnim[targetAnim].Play("esq", dirEsq.Substring(0, 3));
            }
            else
            {
                gkAnim[targetAnim].Play("esq_goal", dirEsq.Substring(0, 3)+"_goal");
            }
        }
        else if(input == "direita")
        {
            eLog.optionChosenInt = 2;
            if(eLog.correct)
            {
                gkAnim[targetAnim].Play("dir", dirEsq.Substring(0, 3));
            }
            else
            {
                gkAnim[targetAnim].Play("dir_goal", dirEsq.Substring(0, 3)+"_goal");
            }

        }
        else
        {
            eLog.optionChosenInt = 1;
            if(eLog.correct)
            {
                gkAnim[targetAnim].Play("cen", dirEsq.Substring(0, 3));
            }
            else
            {
                gkAnim[targetAnim].Play("cen_goal", dirEsq.Substring(0, 3)+"_goal");
            }
        }

        _events.Add(eLog);
        print ("log saved");
        print (events.Count);

        eventCount++;

        int successCountInWindow = 0;
        for(int i = 0; i < eventWindow; i++)
        {
            if(eventCount - 1 - i < 0)
            {
                break;
            }
            if(_events[eventCount - 1 - i].correct)
            {
                successCountInWindow ++;
            }
        }

        successRate = ((float) successCountInWindow)/((float)eventWindow);
    }
示例#32
0
 public void TestTeardown()
 {
     gameplay = null;
     random   = null;
 }
示例#33
0
 public RandomProjection Apply(RandomProjection proj, RandomEvent @event)
 {
     proj.I = @event.I;
     return(proj);
 }
    // Update is called once per frame
    void Update()
    {
        if (_curEventTimer > RandomEventTimer) {
            _curEventTimer = 0;
            _spawnPos = new Vector3(Random.Range(-6f, 6f), 0, Random.Range(-8f, 8f));
            if (DoOnlySeagulls)
                _curEvent = RandomEvent.SeaGull;
            else
                _curEvent = (RandomEvent)Random.Range(1, (int)RandomEvent.Size);
        }

        switch (_curEvent) {
            case RandomEvent.Idle:
                _curEventTimer += Time.deltaTime;
                break;
            case RandomEvent.DoplphinSchool:
                SpawnDolphinEvent();
                break;
            case RandomEvent.Whale:
                SpawnWhaleEvent();
                break;
            case RandomEvent.SeaGull:
                SpawnSeaGullEvent();
                break;
        }
    }
示例#35
0
 public CombatContext()
 {
     this.PlayerHitPoints = 100;
     this.EnemyHitPoints  = RandomEvent.GetRandomNumberBetween(30, 60);
 }
示例#36
0
    private void FixedUpdate()
    {
        if (isStarted && StartRegion != null)
        {
            StartRegion.infected    = 1;
            StartRegion.Population -= 1;
            startHum  = StartRegion.average_humidity;
            startTemp = StartRegion.average_temp;

            powerD.SetActive(isDefending);
            powerO.SetActive(!isDefending);
            panelD.SetActive(isDefending);
            panelO.SetActive(!isDefending);
            StartRegion = null;
        }
        //Gameplay
        else if (isStarted && i % 25 == 0)
        {
            //update cooldowns
            if (Tcd > 0)
            {
                Tcd--;
                if (Tcd == 0)
                {
                    TPanel.interactable = true;
                }
            }
            if (Scd > 0)
            {
                Scd--;
                if (Scd == 0)
                {
                    SPanel.interactable = true;
                }
            }

            //WorldWide stat
            totalSane     = 0;
            totalInfected = 0;
            totalDead     = 0;

            int j = 0;
            foreach (var continents in Earth.regionlist)
            {
                continents.Population = 0;
                continents.infected   = 0;
                continents.dead       = 0;
                foreach (var region in continents.countrylist)
                {
                    //check if climate is ok
                    if (region.average_humidity <= startHum + HumidityRes && region.average_humidity >= startHum - HumidityRes &&
                        region.average_temp <= startTemp + tempRes && region.average_temp >= startTemp - tempRes)
                    {
                        //if that region has 0 infected
                        if (!isDefending && region.infected == 0 && region.Population != 0)
                        {
                            if (Random.Range(0.2f, 10f) < transmitionOther || (region.Name == "Australia" && Random.Range(0.1f, 5f) < transmitionOther))
                            {
                                region.infected = 1;
                                OnSpellUsed("NewRegionInfected", region.Name + ", " + GetContinent(region).Name);
                                region.Population -= 1;
                            }
                            else if (!region.isClosed && Random.Range(0.04f, 15f) < transmitionHuman)
                            {
                                region.infected = 1;
                                OnSpellUsed("NewRegionInfected", region.Name + ", " + GetContinent(region).Name);
                                region.Population -= 1;
                            }
                        }
                    }

                    //update infected
                    if (region.Population != 0 && region.infected != 0)
                    {
                        long extraInfected = (long)((transmitionHuman * 0.2f + transmitionOther * 0.1f) * (region.infected + 100));
                        region.infected   += extraInfected;
                        region.Population -= extraInfected;

                        if (region.Population < 0)
                        {
                            region.Population = 0;
                        }
                    }

                    //update dead
                    if (lethality != 0 && region.infected != 0)
                    {
                        long extraDead = (long)(region.infected * lethality) + 3;
                        region.dead     += extraDead;
                        region.infected -= extraDead;
                        if (region.infected < 0)
                        {
                            region.dead    -= region.infected;
                            region.infected = 0;
                        }

                        if (region.infected <= 7)
                        {
                            region.dead    += region.infected;
                            region.infected = 0;
                        }
                    }

                    //update vaccined
                    if (Main_Controller_def.vaccineFound && region.infected != 0)
                    {
                        long extraSane;
                        if (region.Name == sanitaryBonus)
                        {
                            extraSane = (long)(region.infected * 0.2) + 3;
                        }
                        else
                        {
                            extraSane = (long)(region.infected * 0.1) + 3;
                        }

                        region.Population += extraSane;
                        region.infected   -= extraSane;
                        if (region.infected < 0)
                        {
                            region.Population -= region.infected;
                            region.infected    = 0;
                        }

                        if (region.infected <= 7)
                        {
                            region.Population += region.infected;
                            region.infected    = 0;
                        }
                    }

                    //update randomEvents
                    if (AI.isSP && !isDefending && eventsList.Count > 0 && !gotAnEvent)
                    {
                        Debug.Log("rdn event " + this.maxRand);
                        if (Random.Range(1, maxRand) == 1)
                        {
                            Debug.Log("entered rdn event");
                            tempEvent = eventsList[Random.Range(0, eventsList.Count)];
                            //Debug.Log("before");
                            OpenNotification(tempEvent.title, tempEvent.message);
                            //Debug.Log("after");
                            tempEvent.ApplyChanges();
                            if (tempEvent.title == "Accident nucléaire")
                            {
                                nuclearExplosion = true;
                            }
                            //eventsList.Remove(tempEvent);
                            gotAnEvent = true;
                        }
                        if (maxRand <= 1)
                        {
                            maxRand = maxRandEvent;
                        }
                        maxRand -= 1;
                    }
                    if (nuclearExplosion)
                    {
                        var france = (eventsList[4].country);
                        if (france.Population > 50000000 && Random.Range(1, 100) == 1)
                        {
                            france.dead       += 2;
                            france.Population -= 2;
                        }
                    }



                    //PowerO generation
                    if (region.infected > 100)
                    {
                        if (region.infected < 1000 && region.infected % 100 < 4)
                        {
                            Main_Controller_off.powerO++;
                        }
                        else if (region.infected < 10000 && region.infected % 2000 < 25)
                        {
                            Main_Controller_off.powerO += 2;
                        }
                        else if (region.infected < 100000 && region.infected % 20000 < 50)
                        {
                            Main_Controller_off.powerO += 3;
                        }
                        else if (region.infected < 1000000 && region.infected % 200000 < 50)
                        {
                            Main_Controller_off.powerO += 4;
                        }
                    }

                    //PowerD generation
                    if (i == 50)
                    {
                        Main_Controller_def.powerD++;
                        time++;
                        i = 1;
                    }
                    continents.Population += region.Population;
                    continents.infected   += region.infected;
                    continents.dead       += region.dead;
                }
                //update info about the world
                totalSane     += continents.Population;
                totalInfected += continents.infected;
                totalDead     += continents.dead;


                //ui update -BEGIN
                listText[j++].text = continents.infected + "\n" +
                                     continents.Population + "\n" +
                                     (continents.Population + continents.infected) + "\n" +
                                     continents.dead;
            }
            WorldDataText.text = totalInfected + "\n" +
                                 totalSane + "\n" +
                                 (totalSane + totalInfected) + "\n" +
                                 totalDead;
            //ui update -END
            if (isDefending)
            {
                PowerDText.text = Main_Controller_def.powerD.ToString();
            }
            else
            {
                PowerOText.text = Main_Controller_off.powerO.ToString();
            }
            //end ui update

            //check if game is over
            if (totalInfected == 0 && totalSane == 0)
            {
                HasWon = !isDefending;
                SceneManager.LoadScene("victoire");
                return;
            }
            if (totalInfected == 0)
            {
                HasWon = isDefending;
                SceneManager.LoadScene("defaite");
                return;
            }
        }
        else if (!isStarted)
        {
            if (!isDefending && PlayerGameManager.lastContinentClicked != "Oceans" && PlayerGameManager.lastContinentClicked != null)
            {
                isStarted   = true;
                StartRegion = GetCountryFromName(PlayerGameManager.lastContinentClicked);
                OnSpellUsed("RegionSelected", PlayerGameManager.lastContinentClicked);
            }
        }
        i++;
    }
        static void writeRandomEvent(Player p, DoubleStream stream, RandomEvent r, int eventsCount)
        {
            int startIndex = r.Parent.IsA == p.IsA ? 0 : eventsCount;

            stream[startIndex + r.GetID] += 1;
        }
示例#38
0
 public void TestSetup()
 {
     gameplay = new Gameplay();
     random   = new RandomEvent();
 }