示例#1
0
    public void FillPool(IEventPool <GameEvent> pool, int amountOfEvents, string type)
    {
        //get discrete function for how to pick game events
        double[] eventProbability = Utils.DistributionFunction(GAME_DIFFICULTY_COUNT);

        int[] numberOfEvenetsFromEachLevel = new int[GAME_DIFFICULTY_COUNT];

        for (int i = 0; i < GAME_DIFFICULTY_COUNT; i++)
        {
            numberOfEvenetsFromEachLevel[i] = (int)Math.Floor(eventProbability[i] * amountOfEvents);
        }

        for (int i = 0; i < eventProbability.Length; i++)
        {
            //factory give me from this pool of options an amount of events according to it's
            //specified distrub
            int amount = numberOfEvenetsFromEachLevel[i];

            List <GameEvent> generatedEvents = GameEventFactory.GetIntance().GenerateMany(type, amount, i);

            EventPoolHolder <GameEvent> .AddToPool(pool, generatedEvents);
        }


        //choose from each type x the f(x) amount
        //for every object clone and send to pool

        //call it self in {level} time
    }
示例#2
0
        public override void Enter()
        {
            Init();

            //myEvent =new UnityEvent( GameEventManager.Instance.onPlayerJumpEvent);

            //--Display the fatui image
            //StartCoroutine(ExecuteAfterTime(10))
            TutorialSystem.Instance.DisplayImageOnPlaceHolder(TutorialImage, PrimaryScene, waitForEvent, delay);

            //--Instantiate the constructs using the json data

            //--Create a new list
            List <GameEvent>[] gameEvents = new List <GameEvent> [ApplicationConstants.NumberOfScenes];

            //--Initialize the lists
            for (int i = 0; i < ApplicationConstants.NumberOfScenes; i++)
            {
                gameEvents[i] = new List <GameEvent>();
            }

            //--Populate the lists using the PREvent data
            foreach (PREvent e in Events)
            {
                gameEvents[e.scene].Add(GameEventFactory.GetIntance().GenerateOne(e.type, e.level, e.index));
            }

            holder2 = new CountDownRoot(WakeUp);

            for (int i = 0; i < gameEvents.Length; i++)
            {
                //--If there are game events to deploy
                if (gameEvents[i].Count != 0)
                {
                    DeploymentTubeManager.Instance.ApplyRequestToTube(i, (Action callback) =>
                    {
                        Debug.Log("EventSelector: ApplyRequestToTube");

                        CountDownRoot holder = new CountDownRoot(callback);

                        holder2.IncreaseByOne();

                        //BluePrintConstruct bluePrint = LevelConstructUtil.ConvertFromLevelConstructToBluePrint(gameEvents[i]);

                        SubSceneMultiton.Instance.GetInstance(i).GetLocalLevelBuilder().Build(gameEvents[i], Vector3.zero, holder);
                    }, this);
                }
            }

            ////--Deploy request to tube.
            //for (int i = 0; i < ApplicationConstants.NumberOfScenes; i++)
            //{
            //    BluePrintConstruct bluePrint = LevelConstructUtil.ConvertFromLevelConstructToBluePrint(gameEvents[i]);

            //    DeploymentTubeManager.Instance.ApplyRequestToTube(i, TutorialSystem.Instance.MoveToNexTStep, this);
            //}
        }