public static PathContainer Initialize <TPackage>(bool NeedRoslyn) where TPackage : AsyncPackage { PathContainer container = new PathContainer(typeof(TPackage)); string wrongDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), container.PackageName); if (Directory.Exists(wrongDir)) { if (Directory.Exists(container.Path)) { foreach (string x in Directory.EnumerateDirectories(container.Path, "*", SearchOption.AllDirectories)) { Directory.CreateDirectory(x.Replace(container.Path, wrongDir)); } foreach (string x in Directory.EnumerateFiles(container.Path, "*", SearchOption.AllDirectories)) { File.Copy(x, x.Replace(container.Path, wrongDir), true); } Directory.Delete(container.Path, true); } Directory.Move(wrongDir, container.Path); } if (NeedRoslyn) { #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed InitializeRoslynAsync(container.RoslynPath); #pragma warning restore CS4014 } return(container); }
void setPointsAsRotatable(PathContainer container) { foreach (var point in container.points) { point.canMove = true; } }
// Use this for initialization void Start() { //Initalise the camera and map loader cam = Camera.main; buildMenuMapLoader.InitialiseMapFinder(); paths = GameObject.Find("SessionManager").GetComponent <PathContainer>(); }
void SetContainerAsMovable(PathContainer container) { foreach (var point in container.points) { point.canMove = true; } }
public void EqualsFalseTest() { PathContainer container = new PathContainer(); Assert.False(container.Equals(148)); Assert.False(container.Equals("diffusion")); Assert.False(container.Equals(null)); }
private GameObject SpawnEnemy(GameObject prefab, PathContainer path, int id) { GameObject enemy = Instantiate(prefab); var ec = enemy.GetComponent <EnemyController>(); ec.Spawn(this.level, id, path); return(enemy); }
public void FollowPath(PathContainer newPath, UnityEvent callback) { state = MovementState.FollowingPath; path = newPath; transform.position = path.transform.position; WaypointId = 0; this.callback = callback; }
void ParseCompleted(VideoInfo info) { videoInfo = info; PathContainer currentPath = Instantiate(path).GetComponent <PathContainer>(); currentPath.path = /*Utils.ValidParsedVideoUrl(videoInfo, videoInfo.url);*/ videoInfo.url; ListContainer.Instance.paths.Add(currentPath); }
private void Awake() { _mainCamera = Camera.main; _mapBuilder = FindObjectOfType <Map>(); _pathfinder = FindObjectOfType <Pathfinder>(); _pathContainer = GetComponent <PathContainer>(); }
void GetPathList() { PathCount = PathContainer.childCount; for (int i = 0; i < PathCount; i++) { Paths.Add(PathContainer.GetChild(i)); } MyTarget = Paths[TargetCounter]; IHavePaths = true; }
public override void OnInspectorGUI() { DrawDefaultInspector(); PathContainer myScript = (PathContainer)target; if (GUILayout.Button("Add")) { myScript.AddNewWaypoint(); } }
public PathContainer GetRelativePathTo(PathContainer path) { if (!IsChildOf(path)) { throw new NotChildException(); } string[] segmentsCopy = new string[Segments.Length - path.Segments.Length]; Array.Copy(Segments, path.Segments.Length, segmentsCopy, 0, Segments.Length - path.Segments.Length); PathContainer relativePath = new PathContainer(segmentsCopy); return(relativePath); }
public void SaveAssemblySearchPath(string path) { _path = path; PathContainer pathContainer = PathContainerFor(Db4oClient.OMNConnection); if (pathContainer.SearchPath != null) { Db4oClient.OMNConnection.Delete(pathContainer.SearchPath); } pathContainer.SearchPath = AssemblySearchPath; pathContainer.ConnectionPath = path; Db4oClient.OMNConnection.Store(pathContainer); Db4oClient.CloseRecentConnectionFile(); }
public void EqualsTest() { PathContainer container2 = new PathContainer(); Assert.True(container.Equals(container)); Assert.True(container.Equals(container2)); Path dummyPath1 = MockRepository.GenerateMock <Path>(); container2.AddPath(dummyPath1); Assert.False(container.Equals(container2)); Assert.True(container2.Equals(container2)); }
public void ClearTest() { PathContainer container = new PathContainer(); Path dummyPath1 = MockRepository.GenerateMock <Path>(); Path dummyPath2 = MockRepository.GenerateMock <Path>(); container.AddPath(dummyPath1); container.AddPath(dummyPath2); container.Clear(); Assert.AreEqual(0, container.Count); Assert.AreEqual(0, container.TotalPointCount); }
public void SetGetPaths() { PathContainer container = new PathContainer(); List <Path> paths = new List <Path>(); Path path1 = new Path(); Path path2 = new Path(); Path path3 = new Path(); paths.Add(path1); paths.Add(path2); paths.Add(path3); container.Paths = paths; Assert.AreEqual(container.Paths, paths); }
public void CloneTest() { IPathContainer container1 = new PathContainer(); Path dummyPath1 = MockRepository.GenerateMock <Path>(); Path dummyPath2 = MockRepository.GenerateMock <Path>(); dummyPath1.Stub(x => x.Equals(Arg <Path> .Is.Anything)).Return(true); dummyPath2.Stub(x => x.Equals(Arg <Path> .Is.Anything)).Return(true); container1.AddPath(dummyPath1); container1.AddPath(dummyPath2); IPathContainer container2 = container1.Clone(); Assert.True(container1.Equals(container2)); Assert.False(container1 == container2); }
public bool IsChildOf(PathContainer path) { if (path.Segments.Length >= Segments.Length) { return(false); } for (int segmentIndex = 0; segmentIndex < path.Segments.Length; segmentIndex++) { if (!path.Segments[segmentIndex].Equals(Segments[segmentIndex], StringComparison.OrdinalIgnoreCase)) { return(false); } } return(true); }
void Start() { if (path == null) { if (GameObject.Find("SessionManager")) { paths = GameObject.Find("SessionManager").GetComponent <PathContainer>(); } else { Debug.Log("Critical error"); } } if (paths.pathsValid) { FindFiles(); } }
/// <summary> /// Interpolates a single frame, starting at index /// </summary> /// <param name="index">The index pointing to the first frame</param> public double InterpolateManual(int index, double maxError) { Frame firstFrame = frameList.FramesList.ElementAt(index); Frame secondFrame = frameList.FramesList.ElementAt(index + 1); Image <Bgr, Byte> firstImage = GetImageAt(index); Image <Bgr, Byte> secondImage = GetImageAt(index + 1); IPathContainer tempContainer = new PathContainer(); double error = interpolator.InterpolatePaths(firstFrame.Curves, tempContainer, firstImage, secondImage); if (error < maxError) { if (secondFrame.Curves.TotalPointCount > 0) { if (NextFrameContainsCurves != null) { InterpolationArgs args = new InterpolationArgs(); NextFrameContainsCurves(this, args); if (args.Handled == true) { secondFrame.Curves = tempContainer; } else { return(double.MaxValue); } } else { return(double.MaxValue); } } else { secondFrame.Curves = tempContainer; } } return(error); }
public PathPoint(Vector3 pos, Vector3 normal, PathContainer container) { this.container = container; position = pos; this.normal = normal; realCamPosition = Camera.main.WorldToScreenPoint(pos); screenPosition = realCamPosition; screenPosition.z = 0; // We actually get a world position, but where all the objects are at // the same distance from the Camera. camPosition = Camera.main.ScreenToWorldPoint(screenPosition); for (var i = 0; i < 3; i++) { camPosition[i] = Mathf.Round(camPosition[i] * 10f) * .5f; } Vector3[] crossOptions = { Vector3.up, Vector3.down, Vector3.left, Vector3.right, Vector3.forward, Vector3.back }; for (var i = 0; i < crossOptions.Length; i++) { var crossOption = crossOptions[i]; if (Vector3.Dot(crossOption, normal) == 0) { var connection = pos + crossOption * .5f; connections.Add(connection); } } }
void Attack() { this.state = EnemyState.Attacking; this.sfx.PlayOneShot(this.attackSound); this.transform.parent = null; int idx = UnityEngine.Random.Range(0, this.attackPaths.Length - 1); PathContainer path = Instantiate(this.attackPaths[idx], this.transform.position, Quaternion.identity).GetComponent <PathContainer>(); var pathComplete = new ECEvent(); pathComplete.AddListener(() => { Destroy(path.gameObject); var backAgain = new ECEvent(); backAgain.AddListener(() => { this.state = EnemyState.Idle; this.transform.parent = enemyField; this.transform.rotation = Quaternion.LookRotation(Vector3.forward); }); this.movement.MoveToPos(enemyField, this.PositionInLine(), backAgain); }); this.movement.FollowPath(path, pathComplete); }
public void Spawn(int level, int id, PathContainer path) { this.id = id; this.state = EnemyState.Attacking; if (this.movement == null) { this.movement = this.GetComponent <EnemyMover>(); } this.movement.speed = 6.0f + Mathf.Log((float)level, 4.0f); if (id < 20) // Zako { this.fireRate = 0.2f - 6.4f / ((float)level + 31.0f); this.attackCooldownMin = 5.0f + 30.0f / (5.0f + (float)level); this.attackCooldownMax = 2.0f * this.attackCooldownMin; } else { this.fireRate = 0.25f - 6.4f / ((float)level + 30.0f); this.attackCooldownMin = 4.0f + 30.0f / (5.0f + (float)level); this.attackCooldownMax = 1.8f * this.attackCooldownMin; } var pathFinished = new UnityEvent(); // Welcome to callback hell pathFinished.AddListener( () => { var inPosition = new UnityEvent(); inPosition.AddListener( () => { this.transform.rotation = Quaternion.LookRotation(Vector3.forward); this.state = EnemyState.Idle; } ); this.movement.MoveToPos(enemyField, this.PositionInLine(), inPosition); } ); this.GetComponent <EnemyMover>().FollowPath(path, pathFinished); }
private void MainPage_Loaded(object sender, RoutedEventArgs e) { _rootVisual = Root.Visual(); _rootVisual.Size = new Vector2((float)Root.ActualWidth, (float)Root.ActualHeight); _pathContainerVisual = PathContainer.Visual(); _pathContainerVisual.Size = _rootVisual.Size; _compositor = _rootVisual.Compositor; //CreateMoreShapes(); _interactionSource = VisualInteractionSource.Create(_rootVisual); _interactionSource.PositionXSourceMode = InteractionSourceMode.EnabledWithInertia; _interactionSource.PositionYSourceMode = InteractionSourceMode.EnabledWithInertia; _interactionSource.IsPositionXRailsEnabled = false; _interactionSource.IsPositionYRailsEnabled = false; _interactionSource.ScaleSourceMode = InteractionSourceMode.EnabledWithInertia; _interactionSource.ManipulationRedirectionMode = VisualInteractionSourceRedirectionMode.CapableTouchpadOnly; _tracker = InteractionTracker.CreateWithOwner(_compositor, this); _tracker.InteractionSources.Add(_interactionSource); _tracker.MaxPosition = new Vector3(_rootVisual.Size, 0.0f) * 3.0f; _tracker.MinPosition = _tracker.MaxPosition * -1.0f; _tracker.MinScale = 0.9f; _tracker.MaxScale = 12.0f; _tracker.ScaleInertiaDecayRate = 0.96f; var positionAnimation = _compositor.CreateExpressionAnimation("-t.Position"); positionAnimation.SetReferenceParameter("t", _tracker); _pathContainerVisual.StartAnimation("Offset", positionAnimation); var scaleAnimation = _compositor.CreateExpressionAnimation("Vector2(t.Scale, t.Scale)"); scaleAnimation.SetReferenceParameter("t", _tracker); _pathContainerVisual.StartAnimation("Scale.XY", scaleAnimation); }
public void Test() { var pathContainer = new PathContainer(typeof (PathContainerTest).Assembly); var ui = pathContainer.GetObject<IUIInitialize>(templateNode, dataNode); }
public void TearDown() { container = null; }
public void FindFiles() { //Initialise existing maps if (path == null) { if (GameObject.Find("SessionManager")) { paths = GameObject.Find("SessionManager").GetComponent <PathContainer>(); } else { Debug.Log("Critical error"); } } path = new DirectoryInfo(paths.buildPath + "/Maps"); //Get all .txt files to avoid the .meta files FileInfo[] info = path.GetFiles("*.txt"); //Initialise a list of maps maps = new List <GameObject>(); //Iterate through each file foreach (FileInfo f in info) { //Initialise a new map map = new GameObject(); map.transform.parent = this.transform; map.AddComponent <Map>(); //Record which line is being read int lineIterator = 0; //Open the file reader = f.OpenText(); text = ""; //While file has a valid line while (text != null) { //Read the line into a text object text = reader.ReadLine(); if (text != null) { //Split the line into an array of strings, seperated by "," string[] lines = Regex.Split(text, ","); if (lines != null) { //If the first line, assign this line as the name if (lineIterator == 0) { map.name = lines[0]; } else if (lineIterator == 1) { //If the second line, this is the path to the texture map.GetComponent <Map>().imageTexturePath = lines[0]; } else { //The rest will either be walls or coins (or spawn points, represented by coins) if (lines.Length > 3) { map.GetComponent <Map>().addWallItem(int.Parse(lines[0]), float.Parse(lines[1]), float.Parse(lines[2]), float.Parse(lines[3]), map); } else { map.GetComponent <Map>().addCoinItem(int.Parse(lines[0]), float.Parse(lines[1]), float.Parse(lines[2]), map); } } //Iterate through the lines lineIterator++; } } } //Once the file is finished, add the map to the list maps.Add(map); //Close the reader reader.Close(); } }
public ConfigurationBuilder(IFluentContext context) { _context = context; _pathContainer = new PathContainer(); _rootConfiguration = new Configuration(context); }
public static CodeDomProvider Create(Language Lang, PathContainer Container) => Create(Lang, Container.RoslynPath);
public IUIInitialize GetUI() { var pathContainer = new PathContainer(typeof (IUIInitialize).Assembly); return pathContainer.GetObject<IUIInitialize>(templateNode, dataNode); }
private void Awake() { _lineRenderer = GetComponent <LineRenderer>(); _pathContainer = GetComponent <PathContainer>(); }
public void FollowPath(PathContainer newPath) { FollowPath(newPath, null); }
void ResetPathGroup(PathGroup pathGroup) { if (path) { pathContainer = path.GetComponent<PathContainer> (); } if (pathContainer && pathGroup == pathContainer.pathGroup) { //Debug.Log ("ResetPathGroup: "+pathHead); transform.position = pathHead.transform.position; } }
void Start() { playerHealthController = FindObjectOfType<PlayerHealthController> (); pathContainer = path.GetComponent<PathContainer> (); pathNode = pathContainer.GetClosestPath (transform.position); _sc = FindObjectOfType<SightController> (); SendMessage ("Audio_SearchingEnter"); transform.position = pathHead.transform.position; }