private string fromString(string line)
 {
     if (checkPreproccess(line))
     {
         return(string.Empty);
     }
     return(Insertion.Replace(line, (Match m) =>
     {
         string value = m.Value.Substring(1, m.Value.Length - 2);
         if (value.Contains(":"))
         {
             string[] splits = value.Split(":");
             if (splits.Length <= 1)
             {
                 throw new IllegalPipeException();
             }
             string result = Values.ContainsKey(splits[0]) ? (string)Values[splits[0]] : splits[0];
             System.Diagnostics.Debug.WriteLineIf(Values.ContainsKey(result), Values.Where(kv => kv.Key == result).Select(kv => kv.Value).FirstOrDefault());
             foreach (string pipeId in splits.Skip(1))
             {
                 string[] pipeAndArg = pipeId.Split(',');
                 if (!Pipes.ContainsKey(pipeAndArg[0]))
                 {
                     throw new IllegalPipeException(pipeAndArg[0]);
                 }
                 result = Pipes[pipeAndArg[0]](result, pipeAndArg.Skip(1).ToArray());
             }
             System.Diagnostics.Debug.WriteLine(result);
             return result;
         }
         else
         {
             if (Values.ContainsKey(value))
             {
                 if (Values[value] is DateTime dt)
                 {
                     if (Values.ContainsKey("dateTimeFormat"))
                     {
                         return dt.ToString((string)Values["dateTimeFormat"]);
                     }
                     return dt.ToShortDateString();
                 }
                 return Values[value].ToString();
             }
             return value;
         }
     }));
 }
Exemplo n.º 2
0
    void FollowPipe(Pipes chosenPipe)
    {
        //playerObject.transform.position = chosenPipe.endLocation.position;

        //for(int i = 0; i < chosenPipe.followPoints.Count; i++)
        //{
        //    Vector3 positionPoints = chosenPipe.followPoints[i].position;
        //    if(move)
        //    {
        //        if(stepsTaken < amountSteps)
        //        {
        //            Debug.Log("Loop");
        //            playerObject.transform.position = new Vector3(Mathf.Lerp(playerObject.transform.position.x, positionPoints.x, lerpSpeed),
        //                Mathf.Lerp(playerObject.transform.position.y, positionPoints.y, lerpSpeed),
        //                playerObject.transform.position.z);
        //            stepsTaken++;
        //        }
        //        else
        //        {
        //            move = false;
        //            stepsTaken = 0;
        //        }
        //    }
        //}
    }
        // Reloads the level and reinitializes Mario to his default state.
        public void Reset()
        {
            Enemies.Clear();
            Blocks.Clear();
            Pipes.Clear();
            Coins.Clear();
            Checkpoints.Clear();
            Flagpoles.Clear();
            levelData.Clear();

            InvisibleBarrier = new InvisibleBarrier(Vector2.Zero);
            CoinRoomPosition = Vector2.Zero;

            DynamicObjects.Clear();
            StaticObjects.Clear();

            PowerUpState = false;

            Mario.Instance.ResetPlayer();

            SoundManager.Instance.gameOverPlayOnce = true;

            levelData = ParseLevelCSV(fileName);
            BuildLevel(levelData);
        }
Exemplo n.º 4
0
        public static void TestPipeArgDeserialization()
        {
            var jsonV1 = new PipeArgs(new[] { new PipeArg("cancel", ArgMode.Inject, 2) }).ToJson(Pipes.ArgJCfg);
            var jsonV0 = @"{
  ""$type"": ""Mutuo.Etl.Pipe.PipeArg[], Mutuo.Etl"",
  ""$values"": [
    {
      ""$type"": ""Mutuo.Etl.Pipe.PipeArg, Mutuo.Etl"",
      ""name"": ""options"",
      ""value"": {
        ""$type"": ""YtReader.UpdateOptions, YtReader""
      }
    },
    {
      ""$type"": ""Mutuo.Etl.Pipe.PipeArg, Mutuo.Etl"",
      ""name"": ""cancel"",
      ""argMode"": 2
    }
  ]
}".ParseJObject();

            var v2 = Pipes.LoadInArgs(jsonV0);

            v2.Version.Should().Be(PipeArgs.Versions.V1);
            v2.Values.First(v => v.Name == "cancel").ArgMode.Should().Be(ArgMode.Inject);
        }
Exemplo n.º 5
0
        public void SwitchingPipes()
        {
            //checks if each pipe is out of the screen and resets it with diffrent highet

            if (Canvas.GetLeft(pipeDown1._img) < -100)
            {
                borad.Children.Remove(pipeDown1._img);
                borad.Children.Remove(pipeUp1._img);
                RandomHieghtPipes(out hieghtPipeDown, out hieghtPipeUp);
                pipeUp1   = new Pipes(0, 1960, "ms-appx:///Assets/pipeUP.png", hieghtPipeUp, 100);
                pipeDown1 = new Pipes(700 - hieghtPipeDown, 1960, "ms-appx:///Assets/pipeDown.png", hieghtPipeDown, 100);
                pipeDown1.Addtocanvas(borad);
                pipeUp1.Addtocanvas(borad);
                isOverPipeDown1 = false;
            }
            if (Canvas.GetLeft(pipeDown1._img) < -100)
            {
                borad.Children.Remove(pipeDown1._img);
                borad.Children.Remove(pipeUp1._img);
                RandomHieghtPipes(out hieghtPipeDown, out hieghtPipeUp);
                pipeUp1   = new Pipes(0, 1960, "ms-appx:///Assets/pipeUP.png", hieghtPipeUp, 100);
                pipeDown1 = new Pipes(700 - hieghtPipeDown, 1960, "ms-appx:///Assets/pipeDown.png", hieghtPipeDown, 100);
                pipeDown1.Addtocanvas(borad);
                pipeUp1.Addtocanvas(borad);
                isOverPipeDown1 = false;
            }
            if (Canvas.GetLeft(pipeDown2._img) < -100)
            {
                borad.Children.Remove(pipeDown2._img);
                borad.Children.Remove(pipeUp2._img);
                RandomHieghtPipes(out hieghtPipeDown, out hieghtPipeUp);
                pipeUp2   = new Pipes(0, 1960, "ms-appx:///Assets/pipeUP.png", hieghtPipeUp, 100);
                pipeDown2 = new Pipes(700 - hieghtPipeDown, 1960, "ms-appx:///Assets/pipeDown.png", hieghtPipeDown, 100);
                pipeDown2.Addtocanvas(borad);
                pipeUp2.Addtocanvas(borad);
                isOverPipeDown2 = false;
            }
            if (Canvas.GetLeft(pipeDown3._img) < -100)
            {
                borad.Children.Remove(pipeDown3._img);
                borad.Children.Remove(pipeUp3._img);
                RandomHieghtPipes(out hieghtPipeDown, out hieghtPipeUp);
                pipeUp3   = new Pipes(0, 1960, "ms-appx:///Assets/pipeUP.png", hieghtPipeUp, 100);
                pipeDown3 = new Pipes(700 - hieghtPipeDown, 1960, "ms-appx:///Assets/pipeDown.png", hieghtPipeDown, 100);
                pipeDown3.Addtocanvas(borad);
                pipeUp3.Addtocanvas(borad);
                isOverPipeDown3 = false;
            }
            if (Canvas.GetLeft(pipeDown4._img) < -100)
            {
                borad.Children.Remove(pipeDown4._img);
                borad.Children.Remove(pipeUp4._img);
                RandomHieghtPipes(out hieghtPipeDown, out hieghtPipeUp);
                pipeUp4   = new Pipes(0, 1960, "ms-appx:///Assets/pipeUP.png", hieghtPipeUp, 100);
                pipeDown4 = new Pipes(700 - hieghtPipeDown, 1960, "ms-appx:///Assets/pipeDown.png", hieghtPipeDown, 100);
                pipeDown4.Addtocanvas(borad);
                pipeUp4.Addtocanvas(borad);
                isOverPipeDown4 = false;
            }
        }
Exemplo n.º 6
0
        public static void Main()
        {
            Pipes waterPipes = new Pipes();

            Pipes.ManualInput(waterPipes);
            waterPipes.Game();
        }
Exemplo n.º 7
0
        public void LoadWorld(string levelName, Game1 game, bool clearMario = true)
        {
            var state = (game.Mario == null) ? null : game.Mario.State;

            game.LevelName = levelName;
            game.Map       = null;
            game.Mario     = null;
            Items.Clear();
            Enemies.Clear();
            Fireballs.Clear();
            Pipes.Clear();
            Background.Clear();
            Texts.Clear();
            MovingTexts.Clear();
            Achievements.Clear();
            Game1.Camera.Position = Vector2.Zero;
            LevelName             = levelName;
            string level = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName) + "\\Content\\Levels\\" + levelName + ".csv";

            new LevelLoader(game, level);
            if (!clearMario)
            {
                if (state.Name == "Big")
                {
                    game.Mario.ToBig();
                }
                else if (state.Name == "Fire")
                {
                    game.Mario.ToFire();
                }
            }
        }
Exemplo n.º 8
0
        private void CheckForCollisions()
        {
            if (Bird.IsOnGround())
            {
                GameOver();
            }

            // 1. Check for a pipe in the middle
            var centeredPipe = Pipes.FirstOrDefault(p => p.IsCentered());

            // 2. If there is a pipe, check for collisions with:
            if (centeredPipe != null)
            {
                bool hasCollidedWithBottom = Bird.DistanceFromGround < centeredPipe.GapBottom - 150;
                bool hasCollidedWithTop    = Bird.DistanceFromGround + 45 > centeredPipe.GapTop - 150;

                if (hasCollidedWithBottom || hasCollidedWithTop)
                {
                    GameOver();
                }
            }

            // 2a. Bottom pipe
            // 2b. Top pipe
        }
Exemplo n.º 9
0
        private void Load(string fileName)
        {
            Processors.Clear();
            Pipes.Clear();

            try
            {
                //var serializer = new XmlSerializer(typeof(Pipeline));
                using (var stream = new FileStream(fileName, FileMode.Open))
                {
                    Model = _serializer.ReadObject(stream) as Pipeline ?? new Pipeline();

                    foreach (var target in Model.Targets)
                    {
                        AddNode(target);
                    }

                    BuildPipeViewModels(Model);
                }
            }
            catch (Exception e)
            {
                ExceptionMessageBox.ShowException(e, String.Format("Could not load pipeline. {0}.", e.Message));
            }

            Name = fileName;
        }
Exemplo n.º 10
0
        public void CheckForCollisions()
        {
            //check if the bird is on the ground
            if (Bird.IsOnGround())
            {
                GameOver();
            }

            //the first pipe in pipes that has a value of true for IsCentered() (otherwise var is null value)
            var centeredPipe = Pipes.FirstOrDefault(p => p.IsCentered());

            //if there is a pipe in the center collision zone...
            if (centeredPipe != null)
            {
                //true if the bottom of the bird's distance to ground is beneath the bottom of the gap minus the height of the ground
                bool hasCollidedWithBottom = Bird.DistanceFromGround < centeredPipe.GapBottom - 150;
                //true if the top of the bird's distance to the ground is greater than the top of the gap minus the ground height
                bool hasCollidedWithTop = Bird.DistanceFromGround + 45 > centeredPipe.GapTop - 150;

                if (hasCollidedWithBottom || hasCollidedWithTop)
                {
                    GameOver();
                }
            }
        }
Exemplo n.º 11
0
 public void pipeSettings()
 {
     isBegining = true;
     #region Pipe settings
     RandomHieghtPipes(out hieghtPipeDown, out hieghtPipeUp);
     pipeUp1   = new Pipes(0, 1260, "ms-appx:///Assets/pipeUP.png", hieghtPipeUp, 100);
     pipeDown1 = new Pipes(700 - hieghtPipeDown, 1260, "ms-appx:///Assets/pipeDown.png", hieghtPipeDown, 100);
     pipeDown1.Addtocanvas(borad);
     pipeUp1.Addtocanvas(borad);
     RandomHieghtPipes(out hieghtPipeDown, out hieghtPipeUp);
     pipeUp2   = new Pipes(0, 1760, "ms-appx:///Assets/pipeUP.png", hieghtPipeUp, 100);
     pipeDown2 = new Pipes(700 - hieghtPipeDown, 1760, "ms-appx:///Assets/pipeDown.png", hieghtPipeDown, 100);
     pipeDown2.Addtocanvas(borad);
     pipeUp2.Addtocanvas(borad);
     RandomHieghtPipes(out hieghtPipeDown, out hieghtPipeUp);
     pipeUp3   = new Pipes(0, 2260, "ms-appx:///Assets/pipeUP.png", hieghtPipeUp, 100);
     pipeDown3 = new Pipes(700 - hieghtPipeDown, 2260, "ms-appx:///Assets/pipeDown.png", hieghtPipeDown, 100);
     pipeDown3.Addtocanvas(borad);
     pipeUp3.Addtocanvas(borad);
     RandomHieghtPipes(out hieghtPipeDown, out hieghtPipeUp);
     pipeUp4   = new Pipes(0, 2760, "ms-appx:///Assets/pipeUP.png", hieghtPipeUp, 100);
     pipeDown4 = new Pipes(700 - hieghtPipeDown, 2760, "ms-appx:///Assets/pipeDown.png", hieghtPipeDown, 100);
     pipeDown4.Addtocanvas(borad);
     pipeUp4.Addtocanvas(borad);
     #endregion
 }
Exemplo n.º 12
0
 public PipeGroup Copy()
 {
     return(new PipeGroup {
         Pipes = Pipes?.Select(x => x.Copy()).ToArray(),
         Zone = Zone,
         AvgElevation = AvgElevation,
         InputAvgPressure = InputAvgPressure,
         InFlow = InFlow,
         Usage = Usage,
         AnhydrouAmount = AnhydrouAmount,
         Col6 = Col6,
         Col7 = Col7,
         Col8 = Col8,
         Col9 = Col9,
         RuptureLeakage = RuptureLeakage,
         Leakage = Leakage,
         MinPressure = MinPressure,
         MaxPressure = MaxPressure,
         AvgPressure = AvgPressure,
         StDevPressure = StDevPressure,
         MinVelocity = MinVelocity,
         MaxVelocity = MaxVelocity,
         AvgVelocity = AvgVelocity,
         StDevVelocity = StDevVelocity,
     });
 }
Exemplo n.º 13
0
        public async Task Connect()
        {
            _serverAliveCheck = new Timer((s) =>
            {
                if (ServerProcessUtil.IsServerDown(_pid) == false)
                {
                    return;
                }

                Console.WriteLine($"RavenDB server process PID {_pid} exited.");
                _exitCode = 1;
                Stop();
            }, null, 0, ServerAliveCheckInterval);

            try
            {
                var pipeName = Pipes.GetPipeName(Pipes.LogStreamPipePrefix, _pid);
                _client = new NamedPipeClientStream(pipeName);
                WorkaroundSetPipePathForPosix(_client, pipeName);
                try
                {
                    _client.Connect(3000);
                }
                catch (Exception ex)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(Environment.NewLine + "Couldn't connect to " + pipeName);
                    Console.ResetColor();
                    Console.WriteLine();
                    Console.WriteLine(ex);
                    Environment.Exit(2);
                }

                Console.WriteLine("Connected to RavenDB server. Tailing logs...");

                var reader = new StreamReader(_client);
                var buffer = new char[8192];
                var stdOut = Console.Out;
                while (true)
                {
                    var readCount = await reader.ReadAsync(buffer, 0, buffer.Length);

                    if (readCount > 0)
                    {
                        await stdOut.WriteAsync(buffer, 0, readCount);
                    }
                }
            }
            catch (ObjectDisposedException)
            {
                // closing
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Exemplo n.º 14
0
 private void BuildPipeViewModels(Pipeline pipeline)
 {
     foreach (var source in pipeline.Targets)
     {
         foreach (var target in source.Targets)
         {
             Pipes.Add(new PipeViewModel(source, target));
         }
     }
 }
Exemplo n.º 15
0
        public ProcessTreeContext(Guid payloadGuid, SafeHandle reportPipe, ArraySegment <byte> payload, string dllNameX64, string dllNameX86, LoggingContext loggingContext)
        {
            // We cannot create this object in a wow64 process
            Contract.Assume(
                !ProcessUtilities.IsWow64Process(),
                "ProcessTreeContext:ctor - Cannot run injection server in a wow64 32 bit process");
            SafeFileHandle childHandle = null;

            m_loggingContext = loggingContext;

            // This object will be the server for the tree. CreateSourceFile the pipe server.
            try
            {
                SafeFileHandle injectorHandle;

                // Create a pipe for the requests
                Pipes.CreateInheritablePipe(Pipes.PipeInheritance.InheritWrite, Pipes.PipeFlags.ReadSideAsync, out injectorHandle, out childHandle);

                // Create the injector. This will duplicate the handles.
                Injector = ProcessUtilities.CreateProcessInjector(payloadGuid, childHandle, reportPipe, dllNameX86, dllNameX64, payload);

                // Create the request reader. We don't start listening until requested
                var injectionRequestFile = AsyncFileFactory.CreateAsyncFile(
                    injectorHandle,
                    FileDesiredAccess.GenericRead,
                    ownsHandle: true,
                    kind: FileKind.Pipe);
                m_injectionRequestReader = new AsyncPipeReader(injectionRequestFile, InjectCallback, Encoding.Unicode, BufferSize);
            }
            catch (Exception exception)
            {
                if (Injector != null)
                {
                    Injector.Dispose();
                    Injector = null;
                }

                if (m_injectionRequestReader != null)
                {
                    m_injectionRequestReader.Dispose();
                    m_injectionRequestReader = null;
                }

                throw new BuildXLException("Process Tree Context injector could not be created", exception);
            }
            finally
            {
                // Release memory. Since the child handle is duplicated, it can be released

                if (childHandle != null && !childHandle.IsInvalid)
                {
                    childHandle.Dispose();
                }
            }
        }
Exemplo n.º 16
0
        private void ManagePipes()
        {
            if (!Pipes.Any() || Pipes.Last().DistanceFromLeft < GameWidth / 2)
            {
                Pipes.Add(new PipeModel(GameWidth));
            }

            if (Pipes.First().IsOffScreen())
            {
                Pipes.Remove(Pipes.First());
            }
        }
Exemplo n.º 17
0
        private void ManagePipes()
        {
            if (Pipes.Count == 0 || Pipes.Last().DistanceFromLeft <= 250)
            {
                Pipes.Add(new PipeModel());
            }

            if (Pipes[0].IsOffScreen())
            {
                Pipes.Remove(Pipes[0]);
            }
        }
Exemplo n.º 18
0
        void ManagePipes()
        {
            if (!Pipes.Any() || Pipes.Last().DistanceFromleft <= 250)
            {
                Pipes.Add(new PipeModel());
            }

            if (Pipes.First().IsOffScreen())
            {
                Pipes.Remove(Pipes.First());
            }
        }
 private void Awake()
 {
     pipes = new Pipes[pipeCount];
     for (int i = 0; i < pipes.Length; i++)
     {
         Pipes pipe = pipes[i] = Instantiate <Pipes>(pipePrefab);
         pipe.transform.SetParent(transform, false);
         if (i > 0)
         {
             pipe.AlignWith(pipes[i - 1]);
         }
     }
 }
Exemplo n.º 20
0
 public void Dispose()
 {
     GC.SuppressFinalize(this);
     if (Pipes != null)
     {
         Pipes.DeletePipes();
     }
     if (WebSocket != null)
     {
         WebSocket.Close();
         WebSocket = null;
     }
 }
    public void AlignWith(Pipes pipe)
    {
        float relativeRotation =
            Random.Range(0, curveSegmentCount) * 360f / pipeSegmentCount;

        transform.SetParent(pipe.transform, false);
        transform.localPosition = Vector3.zero;
        transform.localRotation = Quaternion.Euler(0f, 0f, -pipe.curveAngle);
        transform.Translate(0f, pipe.curveRadius, 0f);
        transform.Rotate(relativeRotation, 0f, 0f);
        transform.Translate(0f, -curveRadius, 0f);
        transform.SetParent(pipe.transform.parent);
    }
Exemplo n.º 22
0
        private void GeneratePipes()
        {
            var newPipes = pipes.Where(p => !p.IsAlive).FirstOrDefault();

            if (newPipes == null)
            {
                newPipes = new Pipes(this);
                pipes.Add(newPipes);
            }
            var pipesY = (int)(rnd.NextDouble() * 200 - 100);

            newPipes.Reset(width + 20, pipesY);
        }
Exemplo n.º 23
0
        public void MoveObjects()
        {
            //make the Bird fall
            Bird.Fall(_gravity);
            //make the Pipe mode
            //Pipe.Move(_speed);

            //Move each pipe in the collection of pipes
            //foreach(var pipe in Pipes)
            //{
            //    pipe.Move(_speed);
            //}
            Pipes.ForEach(x => x.Move(_speed)); //shorthand
        }
Exemplo n.º 24
0
 public void Dispose()
 {
     GC.SuppressFinalize(this);
     if (Pipes != null)
     {
         Pipes.DeletePipes();
     }
     if (WebSockets.Count > 0)
     {
         foreach (var webSocket in WebSockets)
         {
             webSocket.Close();
         }
     }
 }
Exemplo n.º 25
0
        internal void AddPipe(BaseProcessor source, BaseProcessor target)
        {
            var sourceHasTarget = source.Targets.Any(t => Equals(t, target));
            var targetHasSource = target.Sources.Any(s => Equals(s, source));

            // Do not pipe only once
            if (sourceHasTarget && targetHasSource)
            {
                return;
            }

            source.Targets.Add(target);
            target.Sources.Add(source);

            Pipes.Add(new PipeViewModel(source, target));
        }
Exemplo n.º 26
0
    void Start()
    {
        Menu.menu.scorePanel = scorePanel;
        Menu.menu.scoreText  = menuScoreText;

        _randomSpawn = GetComponent <RandomSpawn>();

        _tower          = GameObject.Find("Tower");
        _towerComponent = _tower.GetComponent <Tower>();
        _pipeDirection  = _tower.GetComponent <PipeDirectionController>();
        _pipes          = _tower.GetComponent <Pipes>();

        _towerComponent.SetScore(0);

        Spawn();
    }
Exemplo n.º 27
0
 public void Run(object aCommandReceived)
 {
     LastRun = DateTime.Now;
     CommandReceivedDelegate CommandReceived = (CommandReceivedDelegate) aCommandReceived;
     for (Running = true; Running; )
     {
         itsPipes = new Pipes(
             new System.IO.Pipes.NamedPipeClientStream(".", "XervBackup.Pipe.Out", System.IO.Pipes.PipeDirection.In),
             new System.IO.Pipes.NamedPipeClientStream(".", "XervBackup.Pipe.In", System.IO.Pipes.PipeDirection.Out));
         while (Running && !itsPipes.Out.IsConnected)
         {
             try { itsPipes.Out.Connect(10000); } //1000); }
             catch { }
         }
         itsPipes.In.Connect();
         itsWriter = new System.IO.StreamWriter(itsPipes.Out);
         itsWriter.AutoFlush = true; // !!
         Debug.WriteLine("CONNECTED");
         if (ConnectedChanged != null) ConnectedChanged(IsConnected);
         System.Media.SystemSounds.Beep.Play();
         using (System.Timers.Timer KeepAlive = new System.Timers.Timer(1000))
         using (System.IO.StreamReader Reader = new System.IO.StreamReader(itsPipes.In))
         {
             KeepAlive.Elapsed += new System.Timers.ElapsedEventHandler(
                 delegate(object sender, System.Timers.ElapsedEventArgs e)
                 {
                     SendCommand(string.Empty);  // Send empty keepalive
                 });
             while (Running && itsPipes.In.IsConnected)
             {
                 try
                 {
                     string Line = Reader.ReadLine();
                     if (!string.IsNullOrEmpty(Line)) // Keepalive is empty
                         CommandReceived(Line);
                 }
                 catch (Exception Ex)
                 {
                     Debug.WriteLine(Ex);
                 }
             }
             itsPipes.Close();
         }
         Debug.WriteLine("Exiting pipe thread");
         if (ConnectedChanged != null) ConnectedChanged(IsConnected);
     }
 }
Exemplo n.º 28
0
    void SpawnNewPipes()
    {
        spawnTimer -= Time.deltaTime;

        if (spawnTimer > 0f)
        {
            return;
        }

        centerHeight = Random.Range(0.3f, 3.0f);
        Pipes newPipe = Instantiate(pipePrefab, transform.position, Quaternion.identity);

        newPipe.transform.Translate(Vector3.up * centerHeight);

        pipes.Add(newPipe);
        spawnTimer = secondsBetweenSpawns;
    }
Exemplo n.º 29
0
        public void ManagePipes()
        {
            //if the list of pipes don't have any objects in it...
            //OR if the last pipe in the list is halfway across the screen...
            if (!Pipes.Any() || Pipes.Last().DistanceFromLeft <= 250)
            {
                //add another pipe to the list
                Pipes.Add(new PipeModel());
            }

            //if it is true that the first pipe in the list if off the screen...
            if (Pipes.First().IsOffScreen())
            {
                //remove the pipe from the list of pipes
                Pipes.Remove(Pipes.First());
            }
        }
Exemplo n.º 30
0
        private void OnStrokeCollected(SenderAwareEventArgs e)
        {
            var container = e.Sender as FrameworkElement;
            var eventArgs = e.OriginalEventArgs as StrokeEventArgs;

            Debug.Assert(eventArgs != null, "event args need to be != null");

            var pg = PathGeometry.CreateFromGeometry(eventArgs.Stroke.GetGeometry());

            var elementsInGeometry = HitTestHelper.GetElementsInGeometry <PipeView>(pg, container);

            var linksToDelete = elementsInGeometry.Select(view => view.DataContext).OfType <PipeViewModel>().ToArray();

            // As user if pipes should be deleted.
            if (linksToDelete.Any())
            {
                var deletePipes = MessageBox.Show("Do you want to delete pipes?", "Delete Pipes", MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (deletePipes != MessageBoxResult.Yes)
                {
                    return;
                }
            }

            // TODO: add method to model, which is capable of deleting more than one link safely
            foreach (var vm in linksToDelete)
            {
                var source = vm.Source as BaseProcessor;
                var target = vm.Target as BaseProcessor;

                if (source != null)
                {
                    source.Targets.Remove(target);
                }

                if (target != null)
                {
                    target.Sources.Remove(source);
                }

                Pipes.Remove(vm);
            }
        }
Exemplo n.º 31
0
        void CheckForCollisions()
        {
            if (Bird.IsOnGround())
            {
                GameOver();
            }

            var centeredPipe = Pipes.FirstOrDefault(p => p.IsCentered());

            if (centeredPipe != null)
            {
                bool hasColidedWithBottom = Bird.DistanceFromGround < centeredPipe.GapBottom - 150;
                bool hasColidedWithTop    = Bird.DistanceFromGround + 45 > centeredPipe.GapTop - 150;

                if (hasColidedWithBottom || hasColidedWithTop)
                {
                    GameOver();
                }
            }
        }
Exemplo n.º 32
0
 public static SystemCallResults WaitOnPipeCreate(Pipes.PipeClasses Class, Pipes.PipeSubclasses Subclass, out int NewPipeId)
 {
     uint Return1 = 0;
     uint Return2 = 0;
     uint Return3 = 0;
     uint Return4 = 0;
     Call(SystemCallNumbers.WaitOnPipeCreate, (uint)Class, (uint)Subclass, 0, ref Return1, ref Return2, ref Return3, ref Return4);
     NewPipeId = (int)Return2;
     return (SystemCallResults)Return1;
 }
Exemplo n.º 33
0
        /// <summary>
        /// Gets the number of available outpoints of the specified class and subclass.
        /// </summary>
        /// <param name="numOutpoints">Out : The number of outpoints (correct iff SysCallResult is OK).</param>
        /// <param name="SysCallResult">Out : The result of the system call. Check this is set to OK.</param>
        /// <param name="Class">The class of pipe to search for.</param>
        /// <param name="Subclass">The subclass of pipe to search for.</param>
        public static void GetNumPipeOutpoints(out int numOutpoints, out SystemCallResults SysCallResult, Pipes.PipeClasses Class, Pipes.PipeSubclasses Subclass)
        {
            SysCallResult = SystemCalls.GetNumPipeOutpoints(Class, Subclass, out numOutpoints);
            switch (SysCallResult)
            {
                case SystemCallResults.Unhandled:
                    //BasicConsole.WriteLine("BasicServerHelpers > GetNumPipeOutpoints: Unhandled!");
                    break;
                case SystemCallResults.Fail:
                    //BasicConsole.WriteLine("BasicServerHelpers > GetNumPipeOutpoints: Failed!");
                    break;
                case SystemCallResults.OK:
                    //BasicConsole.WriteLine("BasicServerHelpers > GetNumPipeOutpoints: Succeeded.");

                    //BasicConsole.Write("BasicServerHelpers > Num pipe outpoints: ");
                    //BasicConsole.WriteLine(numOutpoints);
                    break;
                default:
                    //BasicConsole.WriteLine("BasicServerHelpers > GetNumPipeOutpoints: Unexpected system call result!");
                    break;
            }
        }
Exemplo n.º 34
0
 public virtual bool CanPushIMessage(Pipes.Interfaces.IMessage item)
 {
     return true;
 }
Exemplo n.º 35
0
 public static SystemCallResults ReadPipe(Pipes.ReadPipeRequest* Request, out int BytesRead)
 {
     uint Return1 = 0;
     uint Return2 = 0;
     uint Return3 = 0;
     uint Return4 = 0;
     Call(SystemCallNumbers.ReadPipe, (uint)Request, 0, 0, ref Return1, ref Return2, ref Return3, ref Return4);
     BytesRead = (int)Return2;
     return (SystemCallResults)Return1;
 }
Exemplo n.º 36
0
 public void Install(Pipes.StreamString pipeStream)
 {
     Thread installThread = new Thread(new ParameterizedThreadStart(InstallCallback));
     installThread.Name = "Installation Thread";
     installThread.IsBackground = true;
     installThread.Priority = ThreadPriority.Normal;
     installThread.Start(pipeStream);
 }
Exemplo n.º 37
0
 public void Setup()
 {
     _pipes = new Pipes();
 }
Exemplo n.º 38
0
 private void InstallComponent(int index, Pipes.StreamString pipeStream)
 {
     pipeStream.WriteString("[Component]" + components[index].Name);
     // Subscribe to the ProgressUpdate event, and update the installer pages' progress bar
     components[index].ProgressUpdate += delegate(object sender, ProgressUpdateEventArgs e)
     {
         pipeStream.WriteString("[Progress]" + e.Percent);
     };
     components[index].StatusUpdate += delegate(object sender, StatusUpdateEventArgs e)
     {
         pipeStream.WriteString("[Status]" + e.Status);
     };
     components[index].InstallComplete += delegate(object sender, EventArgs e)
     {
         if (index + 1 < components.Count) {
             InstallComponent(index + 1, pipeStream);
         } else {
             if (InstallComplete != null)
                 InstallComplete(this, EventArgs.Empty);
         }
     };
     switch (Mode) {
         case InstallMode.Install: {
                 components[index].Install();
             }
             break;
         case InstallMode.Repair: {
                 components[index].Repair(destinationDirectory);
             }
             break;
     }
 }
Exemplo n.º 39
0
 public static SystemCallResults WritePipe(Pipes.WritePipeRequest* Request)
 {
     uint Return1 = 0;
     uint Return2 = 0;
     uint Return3 = 0;
     uint Return4 = 0;
     Call(SystemCallNumbers.WritePipe, (uint)Request, 0, 0, ref Return1, ref Return2, ref Return3, ref Return4);
     return (SystemCallResults)Return1;
 }
Exemplo n.º 40
0
 public static SystemCallResults CreatePipe(uint OutProcessId, Pipes.CreatePipeRequest* RequestPtr)
 {
     uint Return1 = 0;
     uint Return2 = 0;
     uint Return3 = 0;
     uint Return4 = 0;
     Call(SystemCallNumbers.CreatePipe, OutProcessId, (uint)RequestPtr, 0, ref Return1, ref Return2, ref Return3, ref Return4);
     return (SystemCallResults)Return1;
 }
Exemplo n.º 41
0
 public void Setup()
 {
     _pipes = new Pipes();
     _selected = _pipes as ISelectedCollection<IPipe>;
 }
Exemplo n.º 42
0
        /// <summary>
        /// Gets the outpoint desciptors of the available outpoints of the specified class and subclass.
        /// </summary>
        /// <param name="numOutpoints">The known number of available outpoints. Use GetNumPipeOutpoints to obtain this number.</param>
        /// <param name="SysCallResult">Out : The result of the system call. Check this is set to OK.</param>
        /// <param name="OutpointDescriptors">Out : The array of outpoint descriptors.</param>
        /// <param name="Class">The class of pipe to search for.</param>
        /// <param name="Subclass">The subclass of pipe to search for.</param>
        public static void GetOutpointDescriptors(int numOutpoints, out SystemCallResults SysCallResult, out Pipes.PipeOutpointDescriptor[] OutpointDescriptors, Pipes.PipeClasses Class, Pipes.PipeSubclasses Subclass)
        {
            OutpointDescriptors = new Pipes.PipeOutpointDescriptor[numOutpoints];

            Pipes.PipeOutpointsRequest* RequestPtr = (Pipes.PipeOutpointsRequest*)Heap.AllocZeroed((uint)sizeof(Pipes.PipeOutpointsRequest), "BasicServerHelpers : Alloc PipeOutpointsRequest");
            if (RequestPtr != null)
            {
                try
                {
                    RequestPtr->MaxDescriptors = numOutpoints;
                    RequestPtr->Outpoints = (Pipes.PipeOutpointDescriptor*)((byte*)Utilities.ObjectUtilities.GetHandle(OutpointDescriptors) + FOS_System.Array.FieldsBytesSize);
                    if (RequestPtr->Outpoints != null)
                    {
                        SysCallResult = SystemCalls.GetPipeOutpoints(Class, Subclass, RequestPtr);
                        switch (SysCallResult)
                        {
                            case SystemCallResults.Unhandled:
                                //BasicConsole.WriteLine("BasicServerHelpers > GetPipeOutpoints: Unhandled!");
                                break;
                            case SystemCallResults.Fail:
                                //BasicConsole.WriteLine("BasicServerHelpers > GetPipeOutpoints: Failed!");
                                break;
                            case SystemCallResults.OK:
                                //BasicConsole.WriteLine("BasicServerHelpers > GetPipeOutpoints: Succeeded.");
                                break;
                            default:
                                //BasicConsole.WriteLine("BasicServerHelpers > GetPipeOutpoints: Unexpected system call result!");
                                break;
                        }
                    }
                    else
                    {
                        SysCallResult = SystemCallResults.Fail;
                        //BasicConsole.WriteLine("BasicServerHelpers > RequestPtr->Outpoints null! No memory allocated.");
                        ExceptionMethods.Throw(new FOS_System.Exceptions.ArgumentException("BasicServerHelpers : Couldn't allocate memory outpoints list in outpoints request!"));
                    }
                }
                finally
                {
                    Heap.Free(RequestPtr);
                }
            }
            else
            {
                SysCallResult = SystemCallResults.Fail;
                //BasicConsole.WriteLine("BasicServerHelpers > RequestPtr null! No memory allocated.");
                ExceptionMethods.Throw(new FOS_System.Exceptions.ArgumentException("BasicServerHelpers : Couldn't allocate memory get outpoints request!"));
            }
        }
Exemplo n.º 43
0
 private void BeginConnect()
 {
     itsPipes = new Pipes();
     itsPipes.Out.BeginWaitForConnection(new AsyncCallback(Connected), null);
 }
Exemplo n.º 44
0
 public static SystemCallResults RegisterPipeOutpoint(Pipes.PipeClasses Class, Pipes.PipeSubclasses Subclass, int MaxConnections)
 {
     uint Return1 = 0;
     uint Return2 = 0;
     uint Return3 = 0;
     uint Return4 = 0;
     Call(SystemCallNumbers.RegisterPipeOutpoint, (uint)Class, (uint)Subclass, (uint)MaxConnections, ref Return1, ref Return2, ref Return3, ref Return4);
     return (SystemCallResults)Return1;
 }
Exemplo n.º 45
0
 public static SystemCallResults GetNumPipeOutpoints(Pipes.PipeClasses Class, Pipes.PipeSubclasses Subclass, out int NumOutpoints)
 {
     uint Return1 = 0;
     uint Return2 = 0;
     uint Return3 = 0;
     uint Return4 = 0;
     Call(SystemCallNumbers.GetNumPipeOutpoints, (uint)Class, (uint)Subclass, 0, ref Return1, ref Return2, ref Return3, ref Return4);
     NumOutpoints = (int)Return2;
     return (SystemCallResults)Return1;
 }
Exemplo n.º 46
0
 public static SystemCallResults GetPipeOutpoints(Pipes.PipeClasses Class, Pipes.PipeSubclasses Subclass, Pipes.PipeOutpointsRequest* RequestPtr)
 {
     uint Return1 = 0;
     uint Return2 = 0;
     uint Return3 = 0;
     uint Return4 = 0;
     Call(SystemCallNumbers.GetPipeOutpoints, (uint)Class, (uint)Subclass, (uint)RequestPtr, ref Return1, ref Return2, ref Return3, ref Return4);
     return (SystemCallResults)Return1;
 }