////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>   Gets the scenario data from the tag. </summary>
		///
		/// <param name="tagIndex">     Zero-based index of the tag. </param>
		/// <param name="tagManager">   The tag's manager. </param>
		///
		/// <returns>   The scenario data. </returns>
		private ScenarioData GetScenarioData(TagIndexBase tagIndex, BlamLib.Managers.TagManager tagManager)
		{
			var data = new ScenarioData();

			data.MessageSent += MessageRedirect;

			data.CollectData(tagIndex, tagManager);

			data.MessageSent -= MessageRedirect;

			return data;
		}
    public ScenarioData CreateScenarioData()
    {
        ScenarioData data = new ScenarioData();

        //Itera por todos os personagens
        foreach (Transform obj in personagens_folder.transform)
        {
            SpeechableCharacter character = obj.GetComponent <SpeechableCharacter>();
            data.characters.Add(character.data);
        }
        //Itera por todas as pistas
        foreach (Transform obj in pistas_folder.transform)
        {
            PistaItem pista = obj.GetComponent <PistaItem>();
            data.pistas.Add(pista.data);
        }
        //Itera por todos os exits
        foreach (Transform obj in exits_folder.transform)
        {
            data.exits.Add(obj.GetComponent <ExitPoint>().GetData());
        }

        return(data);
    }
Exemple #3
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>	Adds the scenarios objects as child jobs. </summary>
        ///
        /// <param name="scenarioData">	Information describing the scenario. </param>
        /// <param name="objectType">   Type of the object. </param>
        private void AddChildJobs(ScenarioData scenarioData, TypeEnums.ObjectType objectType)
        {
            foreach (var scenarioObjectType in scenarioData.ScenarioObjectLists[objectType])
            {
                // Get the model tag
                if (!BlamLib.Managers.TagIndex.IsValid(scenarioObjectType.ObjectTagDatum))
                {
                    mMessageHandler.SendMessage("Failed to open {0}, child job not added", Path.GetFileName(scenarioObjectType.ObjectTagPath));
                    continue;
                }

                var objectData = new ObjectData();
                objectData.CollectData(TagIndex, TagIndex[scenarioObjectType.ObjectTagDatum]);

                // If no model was set don't continue
                if (objectData.Model.IsNull)
                {
                    continue;
                }

                if (!BlamLib.Managers.TagIndex.IsValid(objectData.Model))
                {
                    mMessageHandler.SendMessage("Failed to open model tag for {0}, child job not added", Path.GetFileName(scenarioObjectType.ObjectTagPath));
                    continue;
                }

                // Add an extraction job for the model tag
                var modelTagManager = TagIndex[objectData.Model];
                var modelFile       = Path.Combine(mModelExtractionData.TagsDirectory.Root
                                                   , mModelExtractionData.TagsDirectory.EndFolder
                                                   , modelTagManager.Name);
                modelFile = Path.ChangeExtension(modelFile, "gbxmodel");

                mModelExtractionData.JobInterface.AddJob(modelFile, mExtractionData);
            }
        }
Exemple #4
0
        private List <Behaviour> GetModifiers(ScenarioData data)
        {
            var behaviours = new List <Behaviour>();

            foreach (var episodeData in data.Episodes)
            {
                foreach (var unitInfo in episodeData.Encounter.UnitTable.Units)
                {
                    var unitData = this.unitDataRepository.Find(unitInfo.UnitId);

                    foreach (var behaviour in this.behaviourRepository.Find(unitData.Behaviours))
                    {
                        if (!behaviour.IsMonsterModifier)
                        {
                            continue;
                        }

                        behaviours.Add(behaviour);
                    }
                }
            }

            return(behaviours.DistinctBy(b => b.Id).ToList());
        }
Exemple #5
0
    private void GenerateChapterOneScenarioDatas()
    {
        int NumOfChapter = 1;

        ScenarioDatas = new Dictionary <int, List <ScenarioData> >();

        foreach (var ScenarioExcelData in ScenarioExcelDatas)
        {
            if (ScenarioDatas.ContainsKey(ScenarioExcelData.WaveId))
            {
                ScenarioData scenarioData = new ScenarioData(ScenarioExcelData);
                ScenarioDatas[ScenarioExcelData.WaveId].Add(scenarioData);
            }
            else
            {
                List <ScenarioData> scenarioDataList = new List <ScenarioData>();
                ScenarioData        scenarioData     = new ScenarioData(ScenarioExcelData);
                scenarioDataList.Add(scenarioData);
                ScenarioDatas.Add(ScenarioExcelData.WaveId, scenarioDataList);
            }
        }

        AllScenarioDatas.Add(NumOfChapter, ScenarioDatas);
    }
Exemple #6
0
        public bool Export(ScenarioData scenarioData
                           , BlamLib.Managers.TagManager tagManager
                           , string outputFile)
        {
            // Create the COLLADA exporter
            var extractor = new ColladaScenarioExporter(mColladaSettings,
                                                        TagIndex,
                                                        tagManager);

            extractor.MessageSent +=
                (sender, args) =>
            {
                mMessageHandler.SendMessage("Exporter Error: {0}", args.Message);
            };

            extractor.AddDataProvider(scenarioData);

            if (extractor.BuildColladaInstance())
            {
                extractor.SaveDAE(outputFile);
                return(true);
            }
            return(false);
        }
    private void LoadScenario(ScenarioData data)
    {
        ClearButtons();

        _iat = data.IAT;

        _introPanel.SetActive(true);
        _introText.text = string.Format("<b>{0}</b>\n\n\n{1}", _iat.ScenarioName, _iat.ScenarioDescription);



        if (_iat.m_worldModelSource != null)
        {
            if (!string.IsNullOrEmpty(_iat.m_worldModelSource.Source))
            {
                var wat = _iat.GetWorldModelSource();

                string errorsOnLoad;

                //  _wm = WorldModel.WorldModelAsset.LoadFromFile(_iat.GetWorldModelSource().RelativePath);
                _wm = WorldModel.WorldModelAsset.LoadFromFile(_iat.GetWorldModelSource().Source, out errorsOnLoad);

                if (errorsOnLoad != null)
                {
                    throw new Exception(errorsOnLoad);
                }
            }
        }
        var characterSources = _iat.GetAllCharacterSources().ToList();

        foreach (var source in characterSources)
        {
            var rpc = RolePlayCharacterAsset.LoadFromFile(source.Source);
            rpc.LoadAssociatedAssets();
            _iat.BindToRegistry(rpc.DynamicPropertiesRegistry);

            if (rpc.CharacterName.ToString().Contains("Player"))
            {
                Player = rpc;
                continue;
            }
            AddButton(characterSources.Count <= 2 ? "Start" : rpc.CharacterName.ToString(),
                      () =>
            {
                var body         = m_bodies.FirstOrDefault(b => b.BodyName == rpc.BodyName);
                _agentController = new AgentControler(data, rpc, _iat, body.CharaterArchtype, m_characterAnchor, m_dialogController);
                StopAllCoroutines();
                _agentController.Start(this, VersionMenu);

                _background.SetActive(true);
                if (!backgrounds.IsEmpty())
                {
                    if (!backgrounds.ToList().FindAll(x => x.scenarioName == _iat.ScenarioName).IsEmpty())
                    {
                        _background.GetComponent <Renderer>().material = backgrounds.ToList().Find(x => x.scenarioName == _iat.ScenarioName).mat;
                    }
                    else
                    {
                        _background.GetComponent <Renderer>().material = activeBackgroundMaterial;
                    }
                }
                else
                {
                    _background.GetComponent <Renderer>().material = activeBackgroundMaterial;
                }
            });
        }
        AddButton("Back to Scenario Selection Menu", () =>
        {
            _iat = null;
            LoadScenarioMenu();
        });
    }
        /// <inheritdoc />
        public override Task <bool> IsEligibleForAnalysisAsync(BaseEntity targetEntity, ScenarioData data)
        {
            Assert.IsNotNull(targetEntity, "targetEntity");
            Assert.IsNotNull(data, "data");

            var reconfig = data.TraceRecord as ReconfigurationCompletedTraceRecord;

            Assert.IsNotNull(
                reconfig,
                string.Format(CultureInfo.InvariantCulture, "Actual Type: {0}, Expected: {1}", data.TraceRecord.GetType(), typeof(ReconfigurationCompletedTraceRecord)));

            if (reconfig.TotalDurationMs > this.currentConfig.ReconfigTimeThresholdForAnalysis.TotalMilliseconds)
            {
                return(Task.FromResult(true));
            }

            if (reconfig.Result != ReconfigurationResult.Completed)
            {
                return(Task.FromResult(true));
            }

            return(Task.FromResult(true));
        }
Exemple #9
0
        /// <summary>
        /// Not all reconfigurations are interesting, here we filter further.
        /// </summary>
        /// <param name="targetEntity"></param>
        /// <param name="data"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public override async Task <bool> IsEligibleForAnalysisAsync(BaseEntity targetEntity, ScenarioData data)
        {
            Assert.IsNotNull(targetEntity, "targetEntity");
            Assert.IsNotNull(data, "data");

            var reconfig = data.TraceRecord as ReconfigurationCompletedTraceRecord;

            Assert.IsNotNull(
                reconfig,
                string.Format(CultureInfo.InvariantCulture, "Actual Type: {0}, Expected: {1}", data.TraceRecord.GetType(), typeof(ReconfigurationCompletedTraceRecord)));

            var partitionEntity = targetEntity as PartitionEntity;

            if (partitionEntity == null)
            {
                this.Logger.LogWarning("targetEntity is not a ParitionEntity, thus ineligible for primary move analysis.", reconfig.PartitionId);
                return(false);
            }

            // We only do analysis for stateful service partitions
            if (partitionEntity.ServiceKind != System.Fabric.Query.ServiceKind.Stateful)
            {
                this.Logger.LogWarning("Partition Id {0} does not belong to a stateful partition, so PrimaryMoveAnalysis does not apply.", reconfig.PartitionId);
                return(false);
            }

            bool primaryPreviousLocationKnown = await this.primaryReplicaContextStore.IsPartitionIdKnownAsync(reconfig.PartitionId).ConfigureAwait(false);

            // Registers the primary location for the first time depending on RA.ReconfigurationCompleted with ReconfigType == Other
            // Afterwards, updates of the primary location is done in the DoAnalysisAsync which happens only for Failover and SwapPrimary type reconfigurations
            if (!primaryPreviousLocationKnown)
            {
                PrimaryReplicaContext primaryReplicaContext = new PrimaryReplicaContext(reconfig.PartitionId, reconfig.NodeName, reconfig.NodeInstanceId, reconfig.TimeStamp.Ticks);
                await this.primaryReplicaContextStore.SavePrimaryReplicaContextAsync(primaryReplicaContext).ConfigureAwait(false);
            }

            return(this.ShouldPerformAnalysis(reconfig, primaryPreviousLocationKnown));
        }
    public void GetGoods(IntPoint2D startingTile, Stack <IntPoint2D> path, StoreManager storeMgr, ScenarioData scenarioInfo)
    {
        GameObject level = GameObject.FindWithTag("GameController");

        WalkerPool pool = level.GetComponent("WalkerPool") as WalkerPool;

        GameObject citizen = pool.GetCitizen(startingTile, ScenarioMgr.Direction.Up);

        CitizenManager citMgr = citizen.GetComponent("CitizenManager") as CitizenManager;

        citMgr.SetUp(scenarioInfo, startingTile, ScenarioMgr.Direction.Up, path, storeMgr, this);
    }
Exemple #11
0
        public IScenarioNode Build(IEnumerator <parser.token.ITokenable> tokens, IScenarioNode now, ScenarioData scenarioData)
        {
            var result = new ScenarioElement();

            //  attribute解析
            while (tokens.Current.GetType() != parser.token.TokenType.Slash)
            {
                var attribute = new Attribute();
                result.AddAttribute(attribute.Build(tokens, result, scenarioData));
            }

            return(result);
        }
Exemple #12
0
        public IScenarioNode Build(IEnumerator <parser.token.ITokenable> tokens, IScenarioNode now, ScenarioData scenarioData)
        {
            IScenarioNode result = null;

            //  タグの定義< word /> or <word> ... </word>
            if ((tokens.Current.GetType() != parser.token.TokenType.LeftArrow) || !tokens.MoveNext())
            {
                //  シンタックスエラー
                throw new SyntaxErrorException();
            }

            if ((tokens.Current.GetType() != parser.token.TokenType.Word))
            {
                //  シンタックスエラー
                throw new SyntaxErrorException();
            }

            var startWord = tokens.Current.GetToken();

            if (!tokens.MoveNext())
            {
                //  シンタックスエラー
                throw new SyntaxErrorException();
            }

            //  中身
            var builder = Command.Create(startWord);

            result = builder.Build(tokens, now, scenarioData);

            //  ここまでは共通でここから先は異なるはず
            if (!builder.HasEndTag())
            {
                //  一つ目のパターンのはず

                //  Endタグ
                if ((tokens.Current.GetType() != parser.token.TokenType.RightArrow))
                {
                    //  シンタックスエラー
                    throw new SyntaxErrorException("NotRightArrow:" + tokens.Current.ToString());
                }
                tokens.MoveNext();
            }
            else
            {
                //  二つ目のパターンのはず
                //  Endタグ
                if ((tokens.Current.GetType() != parser.token.TokenType.LeftArrow) || !tokens.MoveNext())
                {
                    //  シンタックスエラー
                    throw new SyntaxErrorException("NotLeftArrow:" + tokens.Current.ToString() + startWord + tokens.Current.Next.ToString());
                }
                if ((tokens.Current.GetType() != parser.token.TokenType.Slash) || !tokens.MoveNext())
                {
                    //  シンタックスエラー
                    throw new SyntaxErrorException("NotSlash:" + startWord + tokens.Current.Next.ToString());
                }
                //  開始タグと一致しなければエラー
                if ((tokens.Current.GetType() != parser.token.TokenType.Word) || (startWord != tokens.Current.GetToken()) || !tokens.MoveNext())
                {
                    throw new SyntaxErrorException("NotMatchWord:" + tokens.Current.ToString());
                }

                if ((tokens.Current.GetType() != parser.token.TokenType.RightArrow))
                {
                    //  シンタックスエラー
                    throw new SyntaxErrorException("NotRightArrow:" + tokens.Current.ToString());
                }

                tokens.MoveNext();
            }

            return(result);
        }
        internal static void print()
        {
            try
            {
                //AccessTools.Field
                MyLog.LogDarkBlue("m_AllScenarioData. start");
                if (m_AllScenarioData != null)
                {
                    foreach (var item in m_AllScenarioData)
                    {
                        if (item.Value == null)
                        {
                            continue;
                        }
                        ScenarioData scenarioData = item.Value;
                        MyLog.LogMessage("ScenarioSelectMgr1"
                                         , scenarioData.ID
                                         , scenarioData.NotLineTitle
                                         //, scenarioData.Title
                                         , scenarioData.ScenarioScript
                                         , scenarioData.EventContents
                                         , scenarioData.IsImportant
                                         , scenarioData.IsPlayable
                                         , scenarioData.IsOncePlayed
                                         , scenarioData.ScriptLabel
                                         , scenarioData.NotPlayAgain
                                         , scenarioData.EventMaidCount
                                         , scenarioData.ConditionCount
                                         , MyUtill.Join("/", scenarioData.ConditionText)
                                         );
                    }
                }

                MyLog.LogDarkBlue("m_ImportantScenarioList. start");
                if (m_ImportantScenarioList != null)
                {
                    foreach (ScenarioData scenarioData in m_ImportantScenarioList)
                    {
                        MyLog.LogMessage("ScenarioSelectMgr2"
                                         , scenarioData.ID
                                         , scenarioData.NotLineTitle
                                         //, scenarioData.Title
                                         , scenarioData.ScenarioScript
                                         , scenarioData.EventContents
                                         , scenarioData.IsImportant
                                         , scenarioData.IsPlayable
                                         , scenarioData.IsOncePlayed
                                         , scenarioData.ScriptLabel
                                         , scenarioData.NotPlayAgain
                                         , scenarioData.EventMaidCount
                                         , scenarioData.ConditionCount
                                         , MyUtill.Join("/", scenarioData.ConditionText)
                                         );
                    }
                }

                MyLog.LogMessage("ScenarioSelectMgr3"
                                 , m_AllScenarioData.Count
                                 , m_ImportantScenarioList.Count
                                 , m_AddedScenerio.Length
                                 );
            }
            catch (Exception e)
            {
                MyLog.LogWarning("ScenarioSelectMgr4", e.ToString()
                                 );
            }
        }
            internal async Task Go(CancellationToken cancellationToken, CanvasDevice device, ScenarioData scenarioData)
            {
                var runner = MakeScenarioRunner();
                scenarioData.AddDataToScenarioRunner(runner);

                // Create the image source and the render target.  These sizes are hardcoded and independent of the 
                // display's DPI since we just want a small image to convince ourselves that the scenarios really are 
                // rendering the right thing.
                Image = new CanvasImageSource(device, 128, 128, 96);

                using (var rt = new CanvasRenderTarget(device, 128, 128, 96))
                {
                    // We actually run the scenario on the thread pool - XAML really falls down if you overload the UI thread.
                    var time = await Task.Run(() =>
                    {
                        // Run the scenario multiple times to try and avoid too much noise
                        List<CpuGpuTime> times = new List<CpuGpuTime>();

                        for (int i = 0; i < 10; ++i)
                        {
                            // Hold the device lock while we run the scenario - this prevents other threads
                            // from interacting with the device and interfering with our recorded time.
                            using (var deviceLock = device.Lock())
                            {
                                times.Add(RunScenario(runner, rt));
                            }
                            if (cancellationToken.IsCancellationRequested)
                                return new CpuGpuTime();
                        }

                        var cpuTimes = from entry in times select entry.CpuTimeInMs;
                        var gpuTimes = from entry in times select entry.GpuTimeInMs;

                        return new CpuGpuTime
                        {
                            CpuTimeInMs = GetAverage(cpuTimes),
                            GpuTimeInMs = GetAverage(gpuTimes)
                        };
                    }, cancellationToken);

                    Data[scenarioData.Value] = time;

                    if (cancellationToken.IsCancellationRequested)
                        return;

                    using (var ds = Image.CreateDrawingSession(Colors.Transparent))
                    {
                        ds.DrawImage(rt);

                        var timing = string.Format("{0:0.00}ms\n{1:0.00}ms", time.CpuTimeInMs, time.GpuTimeInMs);
                        ds.DrawText(timing, 0, 0, Colors.White);
                        ds.DrawText(timing, 1, 1, Colors.Black);
                    }
                }

                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs("Image"));
                    PropertyChanged(this, new PropertyChangedEventArgs("Summary"));
                }
            }
Exemple #15
0
 protected virtual void OnEnable()
 {
     m_target = target as ScenarioData;
 }
Exemple #16
0
        public IScenarioNode Build(IEnumerator <parser.token.ITokenable> tokens, IScenarioNode now, ScenarioData scenarioData)
        {
            var result = new ScenarioElement();

            //  コメント解析
            while (tokens.Current.GetType() != parser.token.TokenType.Word || tokens.Current.GetToken() != "--" || tokens.Current.Next.GetType() != parser.token.TokenType.RightArrow)
            {
                tokens.MoveNext();
            }

            tokens.MoveNext();

            return(result);
        }
		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Adds the scenarios objects as child jobs. </summary>
		///
		/// <param name="scenarioData">	Information describing the scenario. </param>
		/// <param name="objectType">  	Type of the object. </param>
		private void AddChildJobs(ScenarioData scenarioData, TypeEnums.ObjectType objectType)
		{
			foreach (var scenarioObjectType in scenarioData.ScenarioObjectLists[objectType])
			{
				// Get the model tag
				if (!BlamLib.Managers.TagIndex.IsValid(scenarioObjectType.ObjectTagDatum))
				{
					mMessageHandler.SendMessage("Failed to open {0}, child job not added", Path.GetFileName(scenarioObjectType.ObjectTagPath));
					continue;
				}

				var objectData = new ObjectData();
				objectData.CollectData(TagIndex, TagIndex[scenarioObjectType.ObjectTagDatum]);

				// If no model was set don't continue
				if (objectData.Model.IsNull)
				{
					continue;
				}

				if (!BlamLib.Managers.TagIndex.IsValid(objectData.Model))
				{
					mMessageHandler.SendMessage("Failed to open model tag for {0}, child job not added", Path.GetFileName(scenarioObjectType.ObjectTagPath));
					continue;
				}

				// Add an extraction job for the model tag
				var modelTagManager = TagIndex[objectData.Model];
				var modelFile = Path.Combine(mModelExtractionData.TagsDirectory.Root
					, mModelExtractionData.TagsDirectory.EndFolder
					, modelTagManager.Name);
				modelFile = Path.ChangeExtension(modelFile, "gbxmodel");

				mModelExtractionData.JobInterface.AddJob(modelFile, mExtractionData);
			}
		}
		public bool Export(ScenarioData scenarioData
			, BlamLib.Managers.TagManager tagManager
			, string outputFile)
		{
			// Create the COLLADA exporter
			var extractor = new ColladaScenarioExporter(mColladaSettings,
				TagIndex,
				tagManager);

			extractor.MessageSent +=
				(sender, args) =>
				{
					mMessageHandler.SendMessage("Exporter Error: {0}", args.Message);
				};

			extractor.AddDataProvider(scenarioData);

			if (extractor.BuildColladaInstance())
			{
				extractor.SaveDAE(outputFile);
				return true;
			}
			return false;
		}
        async Task RunScenarios()
        {
            var device = CanvasDevice.GetSharedDevice();

            int maxValue;

            switch (CurrentGraphMode)
            {
                case GraphMode.DrawCount:
                    maxValue = (int)DrawCountSlider.Maximum;
                    break;

                case GraphMode.BitmapCount:
                    maxValue = (int)BitmapCountSlider.Maximum;
                    break;

                default:
                    throw new Exception();
            }

            for (int value = 0; value <= maxValue; value += (maxValue / 100))
            {
                switch (CurrentGraphMode)
                {
                    case GraphMode.DrawCount:
                        DrawCount = value;
                        break;

                    case GraphMode.BitmapCount:
                        value = Math.Max(1, value);
                        BitmapCount = value;
                        break;
                }

                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs("DrawCount"));
                    PropertyChanged(this, new PropertyChangedEventArgs("BitmapCount"));
                }

                using (var scenarioData = new ScenarioData(device, DrawCount, BitmapCount, value))
                {
                    foreach (var scenario in Scenarios)
                    {
                        await scenario.Go(currentProfilingTaskCancellation.Token, device, scenarioData);
                    }
                }

                InvalidateGraphs();
            }
        }
Exemple #20
0
 /// <inheritdoc />
 protected override Task InternalHandleIncomingEventNotificationAsync(ScenarioData scenarioData, BaseEntity baseEntity)
 {
     return(Task.FromResult(true));
 }
            internal async Task Go(CancellationToken cancellationToken, CanvasDevice device, ScenarioData scenarioData)
            {
                var runner = MakeScenarioRunner();

                scenarioData.AddDataToScenarioRunner(runner);

                // Create the image source and the render target.  These sizes are hardcoded and independent of the
                // display's DPI since we just want a small image to convince ourselves that the scenarios really are
                // rendering the right thing.
                Image = new CanvasImageSource(device, 128, 128, 96);

                using (var rt = new CanvasRenderTarget(device, 128, 128, 96))
                {
                    // We actually run the scenario on the thread pool - XAML really falls down if you overload the UI thread.
                    var time = await Task.Run(() =>
                    {
                        // Run the scenario multiple times to try and avoid too much noise
                        List <CpuGpuTime> times = new List <CpuGpuTime>();

                        for (int i = 0; i < 10; ++i)
                        {
                            // Hold the device lock while we run the scenario - this prevents other threads
                            // from interacting with the device and interfering with our recorded time.
                            using (var deviceLock = device.Lock())
                            {
                                times.Add(RunScenario(runner, rt));
                            }
                            if (cancellationToken.IsCancellationRequested)
                            {
                                return(new CpuGpuTime());
                            }
                        }

                        var cpuTimes = from entry in times select entry.CpuTimeInMs;
                        var gpuTimes = from entry in times select entry.GpuTimeInMs;

                        return(new CpuGpuTime
                        {
                            CpuTimeInMs = GetAverage(cpuTimes),
                            GpuTimeInMs = GetAverage(gpuTimes)
                        });
                    }, cancellationToken);

                    Data[scenarioData.Value] = time;

                    if (cancellationToken.IsCancellationRequested)
                    {
                        return;
                    }

                    using (var ds = Image.CreateDrawingSession(Colors.Transparent))
                    {
                        ds.DrawImage(rt);

                        var timing = string.Format("{0:0.00}ms\n{1:0.00}ms", time.CpuTimeInMs, time.GpuTimeInMs);
                        ds.DrawText(timing, 0, 0, Colors.White);
                        ds.DrawText(timing, 1, 1, Colors.Black);
                    }
                }

                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs("Image"));
                    PropertyChanged(this, new PropertyChangedEventArgs("Summary"));
                }
            }
Exemple #22
0
        public static Scenario GetScenario(Guid scenarioGuid, Player currentPlayer, Player enemyPlayer)
        {
            Scenario result = new Scenario();

            using (CodeFighterContext db = new CodeFighterContext())
            {
                ScenarioData scenario = db.ScenarioData
                                        .Include("Features").Include("Features.Feature")
                                        .Include("Ships").Include("Ships.Ship")
                                        .Include("Ships.Ship.ShipHull").Include("Ships.Ship.Parts")
                                        .Include("Ships.Ship.Parts.PartData").Include("Ships.Ship.Parts.PartData.ActionData")
                                        .FirstOrDefault(x => x.ScenarioGUID.Equals(scenarioGuid));
                if (scenario != null)
                {
                    // scenario data
                    result = new Scenario(scenario);

                    // features
                    foreach (ScenarioFeatureData fd in scenario.Features)
                    {
                        result.Features.Add(new Feature(fd));
                    }

                    // ships
                    foreach (ScenarioShipData sd in scenario.Ships)
                    {
                        Ship ship = new Ship();
                        // create hull
                        ShipHull shipHull = new ShipHull(sd.Ship.ShipHull.ClassName, sd.Ship.ShipHull.HullSize);

                        // create parts
                        List <BasePart> parts = new List <BasePart>();
                        foreach (ShipPartData spd in sd.Ship.Parts)
                        {
                            PartData          pd      = spd.PartData;
                            List <BaseAction> actions = new List <BaseAction>();
                            BasePart          part    = null;
                            switch (pd.Type)
                            {
                            case "Weapon":
                                part = new WeaponPart(pd, shipHull.Size.Classification, actions);
                                break;

                            case "Defense":
                                part = new DefensePart(pd, shipHull.Size.Classification, actions);
                                break;

                            case "Action":
                                part = new ActionPart(pd, shipHull.Size.Classification, actions);
                                break;

                            case "Engine":
                                part = new EnginePart(pd, shipHull.Size.Classification, actions);
                                break;
                            }

                            foreach (ActionData ad in pd.ActionData)
                            {
                                switch (ad.Type)
                                {
                                case "RepairPart":
                                    var repairPartActions = JsonConvert.DeserializeObject <Dictionary <string, object> >(ad.ActionValuesJSON);
                                    actions.Add(new RepairPart(part, new CloneableDictionary <string, object>(repairPartActions)));
                                    break;

                                case "RepairShip":
                                    var repairShipActions = JsonConvert.DeserializeObject <Dictionary <string, object> >(ad.ActionValuesJSON);
                                    actions.Add(new RepairShip(ship, new CloneableDictionary <string, object>(repairShipActions)));
                                    break;
                                }
                            }
                            if (actions.Count > 0)
                            {
                                part.Actions = actions;
                            }

                            parts.Add(part);
                        }



                        Point origin = new Point(sd.StartingPositionX, sd.StartingPositionY);

                        ship.ID          = sd.Id;
                        ship.Name        = sd.ShipName;
                        ship.Owner       = sd.IsPlayer?currentPlayer:enemyPlayer;
                        ship.Hull        = shipHull;
                        ship.Parts       = parts;
                        ship.Position    = origin;
                        ship.IsDestroyed = false;
                        ship.MP          = new StatWithMax(ship.MaxMP);
                        ship.GameLogic   = ship.Owner.GameLogic;

                        result.Ships.Add(ship);
                    }
                }
            }


            return(result);
        }
Exemple #23
0
 public object Visit(ScenarioData n)
 {
     throw new NotImplementedException();
 }
Exemple #24
0
        public IScenarioNode Build(IEnumerator <parser.token.ITokenable> tokens, IScenarioNode now, ScenarioData scenarioData)
        {
            var result = new ScenarioElement();

            //  attribute解析
            while (tokens.Current.GetType() != parser.token.TokenType.RightArrow)
            {
                var attribute = new Attribute();
                result.AddAttribute(attribute.Build(tokens, result, scenarioData));
            }

            tokens.MoveNext();

            //  子要素 img命令が0回以上続く
            var image = new Image();

            for (; image.IsSyntax(tokens);)
            {
                var tag = new Tag();
                result.AddChild(tag.Build(tokens, now, scenarioData));
            }


            return(result);
        }
Exemple #25
0
        public IScenarioNode Build(IEnumerator <parser.token.ITokenable> tokens, IScenarioNode now, ScenarioData scenarioData)
        {
            //  とりあえず最初にくるのはタグのみ対応
            var tag = new Tag();

            return(tag.Build(tokens, now, scenarioData));
        }
Exemple #26
0
        private void LoadScenarioData()
        {
            foreach (var scenario in map.Scenarios)
            {
                var scenarioData = new ScenarioData()
                {
                    Id          = scenario.Id,
                    Name        = scenario.Name,
                    Description = scenario.Description,
                    IsDefault   = scenario.IsDefault,
                    EnemyDeckId = scenario.EnemyDeckId,
                };
                if (scenario.EnemyDeckId.HasValue)
                {
                    scenarioData.EnemyDeckName = scenario.EnemyDeck.Name;
                }

                foreach (var objective in scenario.ObjectiveMap.Where(x => x.ObjectiveId.HasValue).Select(x => x.Objective).Distinct())
                {
                    var objectiveData = new ObjectiveData()
                    {
                        Id    = objective.Id,
                        Name  = objective.Name,
                        Color = Color.FromArgb(objective.Red, objective.Green, objective.Blue),
                    };

                    scenarioData.Objectives.Add(objectiveData);
                }

                foreach (var scenarioRule in scenario.ScenarioRuleSet)
                {
                    var scenarioRuleData = new ScenarioRuleData()
                    {
                        Id          = scenarioRule.RuleId,
                        Name        = scenarioRule.Rule.Name,
                        Description = scenarioRule.Rule.Description,
                    };

                    scenarioData.ScenarioRules.Add(scenarioRuleData);
                }

                scenarioData.DeploymentMap = new List <List <int?> >();
                scenarioData.ObjectiveMap  = new List <List <int?> >();
                for (int y = 0; y < GRID_SIZE; y++)
                {
                    var deploymentRow = new List <int?>();
                    var objectiveRow  = new List <int?>();
                    scenarioData.DeploymentMap.Add(deploymentRow);
                    scenarioData.ObjectiveMap.Add(objectiveRow);
                    for (int x = 0; x < GRID_SIZE; x++)
                    {
                        var deploymentCell = scenario.DeploymentMap.Single(cell => cell.RowId == y && cell.ColumnId == x);
                        var objectiveCell  = scenario.ObjectiveMap.Single(cell => cell.RowId == y && cell.ColumnId == x);
                        deploymentRow.Add(deploymentCell.PlayerId);
                        int?objectiveIndex = scenarioData.Objectives.FindIndex(x => x.Id == objectiveCell.ObjectiveId);
                        if (objectiveIndex == -1)
                        {
                            objectiveIndex = null;
                        }
                        objectiveRow.Add(objectiveIndex);
                    }
                }

                scenarioList.Add(scenarioData);
            }
            scenarioList = scenarioList.OrderByDescending(x => x.IsDefault).ThenBy(x => x.Name).ToList();
        }
 /// <summary>
 /// This will be called if there is a notification for a signal which we have expressed interest in.
 /// </summary>
 /// <param name="scenarioData"></param>
 /// <param name="baseEntity"></param>
 /// <returns></returns>
 protected abstract Task InternalHandleIncomingEventNotificationAsync(ScenarioData scenarioData, BaseEntity baseEntity);
Exemple #28
0
        public IScenarioNode Build(IEnumerator <parser.token.ITokenable> tokens, IScenarioNode now, ScenarioData scenarioData)
        {
            var result = new ScenarioElement();

            while (tokens.Current.GetType() != parser.token.TokenType.Slash)
            {
                var attribute = new Attribute();
                result.AddAttribute(attribute.Build(tokens, result, scenarioData));
            }


            //  とりあえずtype = charactersのみ対応しとこ
            //  href要素を探す
            if (result.GetAttribute("type").Value != "characters")
            {
                throw new NotSupportedException();
            }
            var href = result.GetAttribute("href");

            var linkData = loadLinkData(href.Value);

            //  んーどこでやるか悩むけどここでキャラ構築やっちゃうか
            for (var character = linkData.ScenarioRoot.Next; character != null;)
            {
                var scenarioCharacter = new ScenarioCharacter(character.GetAttribute("id").Value, character.GetAttribute("name").Value);

                //foreach (var image in character.GetChildren())
                {
                    //scenarioCharacter.AddImage(image.GetAttribute("type").Value, image.GetAttribute("src").Value);
                }

                scenarioData.Characters.Add(scenarioCharacter);
                character = character.Next;
            }

            return(result);
        }
Exemple #29
0
 protected ScenarioSteps(ScenarioContext scenarioContext, FeatureContext featureContext)
 {
     FeatureContext  = featureContext;
     ScenarioContext = scenarioContext;
     ScenarioData    = new ScenarioData(scenarioContext);
 }
		private List<string> GetNodeReferences(ScenarioData.ScenarioObject objectType, string permutation)
		{
			var nodeIds = new List<string>(); 

			// Add geometry instances to the node
			if (!TagIndex.IsValid(objectType.ObjectTagDatum))
			{
				throw new ColladaException("Failed to load the object type tag {0}", objectType.ObjectTagPath);
			}

			var objectName = Path.GetFileNameWithoutExtension(objectType.ObjectTagPath);
			objectName += "-perm" + permutation;

			// Collect data about the object
			var objectData = new ObjectData();
			objectData.CollectData(mTagIndex, mTagIndex[objectType.ObjectTagDatum]);
			if (!TagIndex.IsValid(objectData.Model))
			{
				return nodeIds;
			}

			if(COLLADAFile.LibraryNodes == null)
			{
				AddLibraryNodes();
			}

			// Collect data about the model
			var modelData = new ModelData();
			modelData.CollectData(mTagIndex, mTagIndex[objectData.Model]);

			// Get all of the geometries that make up the permutation at the highest lod
			var geometryList = modelData.GetGeometries(permutation, Blam.Halo1.TypeEnums.LevelOfDetailEnum.SuperHigh);

			// Add geometry instances for all geometries
			foreach(var geometrySet in geometryList)
			{
				var name = objectName + "-" + geometrySet.Name;

				ColladaNCName nodeName = name;
				ColladaID<ColladaNode> nodeId = name;

				nodeIds.Add(nodeId);

				if (COLLADAFile.LibraryNodes.Node.Exists(node => node.ID == nodeId.ToString()))
				{
					break;
				}

				// Create shader references for all shaders used by the geometry
				var materialReferences = new MaterialReferenceList();
				foreach (var shader in geometrySet.Shaders)
				{
					ColladaNCName symbolName = shader.MaterialName;
					ColladaID<Fx.ColladaMaterial> shaderName = shader.MaterialName;

					var url = ColladaUtilities.BuildExternalReference(modelData,
						colladaSettings.RootDirectory,
						shaderName);

					materialReferences.Add(new MaterialReference(shaderName, url, symbolName));
				}

				// Build the geometry reference URL and add the geometry instance
				string geometryURL = ColladaUtilities.BuildExternalReference(modelData,
					colladaSettings.RootDirectory,
					new ColladaID<Core.ColladaGeometry>(geometrySet.Name));

				var nodeType = CreateNode(nodeName, "", nodeId, Enums.ColladaNodeType.NODE);
				nodeType.Add(CreateInstanceGeometry(geometryURL, geometrySet.Name, materialReferences));

				COLLADAFile.LibraryNodes.Node.Add(nodeType);
			}

			return nodeIds;
		}
Exemple #31
0
    private void Awake()
    {
        if (main == null)
        {
            main = this;
        }
        else if (main != this)
        {
            Destroy(gameObject);
        }

        actors = new List <Actor>();

        if (!isDebug)
        {
            Destroy(debugGrid);
            mapData     = GameObject.FindGameObjectWithTag("Data").GetComponent <ScenarioData>();
            mapData.map = Instantiate <GameObject>(mapData.map);
            isMulti     = mapData.isMulti;
            team        = mapData.myTeam;
            grid        = mapData.map.GetComponent <Grid>();

            for (int i = 0; i < Math.Min(mapData.levelData.spawnpointTeam1.Count, mapData.ActorRole1.Count); i++)
            {
                if (!isMulti || team == 1)
                {
                    actors.Add(new Player(mapData.ActorRole1[i], mapData.levelData.spawnpointTeam1[i], 1));
                }
                else
                {
                    actors.Add(new MPlayer(mapData.ActorRole1[i], mapData.levelData.spawnpointTeam1[i], 1));
                }
            }
            for (int i = 0; i < Math.Min(mapData.levelData.spawnpointTeam2.Count, mapData.ActorRole2.Count); i++)
            {
                if (!isMulti)
                {
                    actors.Add(new AIPlayer(mapData.ActorRole2[i], mapData.levelData.spawnpointTeam2[i], 2));
                }
                else if (isMulti && team == 2)
                {
                    actors.Add(new Player(mapData.ActorRole2[i], mapData.levelData.spawnpointTeam2[i], 2));
                }
                else
                {
                    actors.Add(new MPlayer(mapData.ActorRole2[i], mapData.levelData.spawnpointTeam2[i], 2));
                }
            }
        }
        else
        {
            debugGrid.SetActive(true);
            grid = debugGrid.GetComponent <Grid>();
            actors.Add(new Player("Ninja", new Vector3Int(0, 0, 0), 1));
            actors[0].MoveRadius         = 35;
            actors[0].moveAnimationSpeed = 4f;
            team = 1;
        }
        GetWorldTiles();

        for (int i = 0; i < actors.Count; i++)
        {
            actors[i].Idx = i;
        }

        if (team == 1)
        {
            turnQueue = new TurnQueue(actors);
        }

        if (isMulti)
        {
            teamName = new string[] {
                Client.Instance.players.Where(x => x.isHost).ToList()[0].name,
                Client.Instance.players.Where(x => !x.isHost).ToList()[0].name
            };
        }

        waiting = null;
    }
Exemple #32
0
        public IScenarioNode Build(IEnumerator <parser.token.ITokenable> tokens, IScenarioNode now, ScenarioData scenarioData)
        {
            if ((tokens.Current.GetType() != parser.token.TokenType.LeftArrow) || !tokens.MoveNext())
            {
                throw new SyntaxErrorException();
            }

            if ((tokens.Current.GetType() != parser.token.TokenType.Word))
            {
                throw new SyntaxErrorException();
            }

            if ((tokens.Current.GetToken() != Command.WaitNext || !tokens.MoveNext()))
            {
                throw new SyntaxErrorException();
            }

            if ((tokens.Current.GetType() != parser.token.TokenType.Slash) || !tokens.MoveNext())
            {
                throw new SyntaxErrorException();
            }

            if ((tokens.Current.GetType() != parser.token.TokenType.RightArrow) || !tokens.MoveNext())
            {
                throw new SyntaxErrorException();
            }

            return(new ScenarioElement(
                       new executor.WaitNext()
                       ));
        }
Exemple #33
0
        public IScenarioNode Build(IEnumerator <parser.token.ITokenable> tokens, IScenarioNode now, ScenarioData scenarioData)
        {
            var result = new ScenarioElement(
                new executor.Say()
                );

            //  attribute解析
            while (tokens.Current.GetType() != parser.token.TokenType.RightArrow)
            {
                var attribute = new Attribute();
                result.AddAttribute(attribute.Build(tokens, result, scenarioData));
            }

            tokens.MoveNext();


            //  子要素
            //  0回以上NewLine or WaitNext or テキストが続く
            while (true)
            {
                var textBuilder = new Text();
                if (textBuilder.IsSyntax(tokens))
                {
                    result.AddChild(textBuilder.Build(tokens, result, scenarioData));
                    continue;
                }

                var newLineBuilder = new NewLine();
                if (newLineBuilder.IsSyntax(tokens))
                {
                    result.AddChild(newLineBuilder.Build(tokens, result, scenarioData));
                    continue;
                }

                var waitNextBuilder = new WaitNext();
                if (waitNextBuilder.IsSyntax(tokens))
                {
                    result.AddChild(waitNextBuilder.Build(tokens, result, scenarioData));
                    continue;
                }

                var comment = new Comment();
                if (comment.IsSyntax(tokens))
                {
                    var tag = new Tag();
                    result.AddChild(tag.Build(tokens, result, scenarioData));

                    continue;
                }

                break;
            }
            return(result);
        }
 public void IncreaseProbability(ScenarioData scenarioData)
 {
     currentProbability += scenarioData.ScenarioProbability;
 }
Exemple #35
0
 private ScenarioInfo Wrap(ScenarioData data)
 {
     return(new ScenarioInfo(data, GetRewards(data), GetModifiers(data), DetermineStatus(data)));
 }
Exemple #36
0
 /// <inheritdoc />
 protected override Task InternalHandleIncomingEventNotificationAsync(ScenarioData scenarioData, BaseEntity entity)
 {
     this.Logger.LogMessage("InternalHandleIncomingEventNotificationAsync:: Received Signal '{0}'", scenarioData.TraceRecord);
     return(Task.FromResult(true));
 }