예제 #1
0
    public void bossDead()
    {
        isFighting   = false;
        this.enabled = false;

        PipePair pp = BossPipeLine.GetComponent <PipeLine>().pipes[0];

        pp.initPipes(0.5f, 0.5f);
        pp.open(2);



        BossPipeLine.GetComponent <BoxCollider2D>().isTrigger = true;
//		Vector2 off = BossPipeLine.GetComponent<BoxCollider2D>().offset;
//		off.y = 2.95f;
//		BossPipeLine.GetComponent<BoxCollider2D>().offset = off;
        GameObject.Find("Player").transform.parent = arenaPipeLine.transform;

        GameObject.Find("Background").GetComponent <BoxCollider2D>().enabled          = true;
        GameObject.Find("Background").GetComponent <PipeLineGenerator>().lastPipeLine = BossPipeLine;
        GameObject.Find("Background").GetComponent <Menu>().firstPipeline             = BossPipeLine;

        BossPipeLine.GetComponent <PipeLine>().speed = GameObject.Find("Background").GetComponent <PipeLineGenerator>().currentSpeed;
        arenaPipeLine.transform.parent = BossPipeLine.transform;
        arenaPipeLine.GetComponent <Animation>().Play("startLevelUp");

        isFighting = false;
        Boss.GetComponent <Boss>().canFire = false;
        this.enabled = false;
    }
예제 #2
0
        void RunPipeWorker(PipePair pipePair)
        {
            var writer = new BinaryWriter(pipePair.OutPipe, Encoding.ASCII, true);
            var reader = new BinaryReader(pipePair.InPipe, Encoding.ASCII, true);

            // The only way to shut down grpc server right now is by throwing an exception.
            // Note that the pipes throw EndOfStreamException when the client shuts down.
            for (;;)
            {
                // Read the RPC name.
                int    rpcNameSize  = reader.ReadInt32();
                byte[] rpcNameBytes = reader.ReadBytes(rpcNameSize);
                string rpcName      = Encoding.ASCII.GetString(rpcNameBytes);

                // Read the request.
                int    requestSize  = reader.ReadInt32();
                byte[] requestBytes = reader.ReadBytes(requestSize);

                // Call the handler.
                IProcessMessage processor;
                if (!messageProcessors.TryGetValue(rpcName, out processor))
                {
                    throw new Exception($"Unknown rpc '{rpcName}'");
                }

                byte[] responseBytes = responseBytes = processor.Process(requestBytes);

                // Send the response back.
                writer.Write(responseBytes.Length);
                writer.Write(responseBytes);
            }
        }
예제 #3
0
        public PipeServiceBinder(string[] inPipeHandles, string[] outPipeHandles)
        {
            Debug.Assert(inPipeHandles.Length == outPipeHandles.Length);
            int numPipes = inPipeHandles.Length;

            pipePairs = new PipePair[numPipes];
            for (int n = 0; n < numPipes; ++n)
            {
                pipePairs[n] = new PipePair(inPipeHandles[n], outPipeHandles[n]);
            }
        }
예제 #4
0
        public PipeCallInvoker(int numPipePairs)
        {
            pipePairs          = new PipePair[numPipePairs];
            availablePipePairs = new ConcurrentBag <PipePair>();
            for (int n = 0; n < numPipePairs; ++n)
            {
                pipePairs[n] = new PipePair();
                availablePipePairs.Add(pipePairs[n]);
            }

            // Allow pipePairs.Length threads to run concurrently, so that each one can pick its
            // own pipe.
            pipeLock = new SemaphoreSlim(pipePairs.Length, pipePairs.Length);
        }
예제 #5
0
    private void InitializePipes()
    {
        for (int i = 0; i < this.arrayOfPipePairs.Length; i++)
        {
            GameObject pipeParent = new GameObject("Pipe_" + i);
            Transform pipeParentTrans = pipeParent.transform;
            pipeParentTrans.parent = this.localTransform;

            BoxCollider boxColl = pipeParent.AddComponent<BoxCollider>();
            boxColl.isTrigger = true;
            boxColl.tag = "ScoreZone";
            boxColl.size = (Vector3.one * 0.6f) + (Vector3.up * 5f);

            GameObject upperPipe = Instantiate(this.UpperPipeObj) as GameObject;
            GameObject lowerPipe = Instantiate(this.LowerPipeObj) as GameObject;

            PipePair pair = new PipePair(pipeParentTrans, upperPipe.transform, lowerPipe.transform);
            this.arrayOfPipePairs[i] = pair;
            this.arrayOfPipePairs[i].SetActive(false);
        }
    }
예제 #6
0
        public override async Task Update(TimeSpan dt)
        {
            // update timer for pipe spawning
            timer = timer + dt.TotalSeconds;

            // spawn a new pipe pair every second and a half
            if (timer > 2)
            {
                // modify the last Y coordinate we placed so pipe gaps aren't too far apart
                // no higher than 10 pixels below the top edge of the screen,
                // and no lower than a gap length (90 pixels) from the bottom
                var y = Math.Max(-PipeHeight + 10, Math.Min(lastY + FiftyBird.Instance.Random.Next(-20, 20 + 1), Game.Instance.VirtualHeight));
                lastY = y;

                // add a new pipe pair at the end of the screen at our new Y
                var pipePair = new PipePair(y);
                await pipePair.Load();

                pipePairs.Add(pipePair);

                // reset timer
                timer = 0;
            }

            // for every pair of pipes..
            foreach (var pair in pipePairs)
            {
                // score a point if the pipe has gone past the bird to the left all the way
                // be sure to ignore it if it's already been scored
                if (!pair.Scored)
                {
                    if (pair.X + PipeWidth < bird.X)
                    {
                        score++;
                        pair.Scored = true;
                        await FiftyBird.Instance.Sounds["score"].Play();
                    }
                }

                // Update posiiton of pair
                pair.Update(dt);
            }

            // we need this second loop, rather than deleting in the previous loop, because
            // modifying the table in-place without explicit keys will result in skipping the
            // next pipe, since all implicit keys (numerical indices) are automatically shifted
            // down after a table removal
            pipePairs.RemoveAll(pair => pair.Remove);

            // simple collision between bird and all pipes in pairs
            foreach (var pair in pipePairs)
            {
                foreach (var pipe in pair.Pipes.Values)
                {
                    if (bird.Collides(pipe))
                    {
                        await FiftyBird.Instance.Sounds["explosion"].Play();
                        await FiftyBird.Instance.Sounds["hurt"].Play();

                        await FiftyBird.Instance.StateMachine.Change("score", new Dictionary <string, object>
                        {
                            ["score"] = score
                        });
                    }
                }
            }

            // update bird based on gravity and input
            bird.Update(dt);

            // reset if we get to the ground
            if (bird.Y > FiftyBird.Instance.VirtualHeight - 15)
            {
                await FiftyBird.Instance.Sounds["explosion"].Play();
                await FiftyBird.Instance.Sounds["hurt"].Play();

                await FiftyBird.Instance.StateMachine.Change("score", new Dictionary <string, object>
                {
                    ["score"] = score
                });
            }
        }
예제 #7
0
 void RemovePipe(PipePair pipe)
 {
     pipes.Remove(pipe);
 }