private void OnTriggerEnter(Collider other)
    {
        if (fuse != null)
        {
            return;
        }
        Fuse f = other.gameObject.GetComponent <Fuse>();

        if (f != null)
        {
            fuse     = f;
            isMoving = true;
            t        = 0.0f;
            // Ungrab si es un grabbable
            GrabableObj grabbable = fuse.gameObject.GetComponent <GrabableObj>();
            if (grabbable != null)
            {
                Grabber hand = grabbable.GetGrabber();
                if (hand != null)
                {
                    hand.Ungrab();               // No es force ungrab porque no lo cogemos con la otra mano
                }
            }
            // Desactivar rigidbody (recordar que el ungrab lo activa)
            fuse.gameObject.GetComponent <Rigidbody>().isKinematic = true;
            // Impedir que pueda ser agarrado de nuevo
            GrabableObj gro = fuse.gameObject.GetComponent <GrabableObj>();
            gro.CanBeGrabbed        = false;
            gro.IsDistanceGrabbable = false;
        }
    }
        public FuseOperationsTests()
        {
            _mountPoint = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
            Directory.CreateDirectory(_mountPoint);

            _mount = Fuse.Mount(_mountPoint, new FileSystem());
        }
Example #3
0
 public Process StartFuse(string[] arguments, bool redirect, bool hide)
 {
     return(Fuse.Start(
                new ProcessStartInfo
     {
         Arguments = arguments.Select(
             s =>
         {
             if (s.EndsWith("\\"))
             {
                 return "\"" + s + " \"";
             }
             else
             {
                 return "\"" + s + "\"";
             }
         }).Join(" "),
         WindowStyle = hide ? ProcessWindowStyle.Hidden : ProcessWindowStyle.Normal,
         CreateNoWindow = hide,
         UseShellExecute = !redirect,
         RedirectStandardInput = redirect,
         RedirectStandardError = redirect,
         RedirectStandardOutput = redirect
     }));
 }
Example #4
0
        public async Task Unmount_Timeout()
        {
            // Mount the file system
            DummyFileSystem dummyFileSystem = new DummyFileSystem();
            string          mountPoint      = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

            Directory.CreateDirectory(mountPoint);
            IFuseMount mount = Fuse.Mount(mountPoint, dummyFileSystem);

            // Open a file and try to unmount
            FileStream openedFile = File.OpenRead(Path.Combine(mountPoint, "filename"));
            long       startTime  = Stopwatch.GetTimestamp();
            const int  timeout    = 1000;
            bool       unmounted  = await mount.UnmountAsync(timeout);

            long endTime = Stopwatch.GetTimestamp();

            // Unmounting times out.
            Assert.False(unmounted);
            Assert.True((1000 * (endTime - startTime)) / Stopwatch.Frequency >= timeout);

            // Close the file and try to unmount
            openedFile.Close();
            // Unmounting succeeds.
            unmounted = await mount.UnmountAsync();

            Assert.True(unmounted);
        }
Example #5
0
        public void MountFail_DisposesFileSystem_And_ThrowsFuseException()
        {
            DummyFileSystem dummyFileSystem = new DummyFileSystem();

            Assert.Throws <FuseException>(() => Fuse.Mount("/tmp/no_such_mountpoint", dummyFileSystem));
            Assert.Equal(1, dummyFileSystem.DisposeCount);
        }
Example #6
0
 private void btnClearActivity_Click(object sender, EventArgs e)
 {
     this.lbxFuseStream.Items.Clear();
     ActivityCount = 0;
     f             = new Fuse(
         (Fuse.FuseBehavior)Enum.Parse(typeof(Fuse.FuseBehavior), this.cbxFuseBehaviorType.Items[this.cbxFuseBehaviorType.SelectedIndex].ToString()),
         (int)this.nudHitThreshold.Value, (int)this.nudVolThreshold.Value,
         new TimeSpan(0, 0, 0, 0, (int)this.nudTimeframeMs.Value), this.chkAutoReset.Checked);
 }
 /// <summary>
 /// Decode network data.
 /// </summary>
 /// <param name="br"></param>
 public override void Decode(BinaryReader br)
 {
     isDirty = true;
     base.Decode(br);
     warhead  = ( Warhead )br.ReadUInt16();
     fuse     = ( Fuse )br.ReadUInt16();
     quantity = br.ReadUInt16();
     rate     = br.ReadUInt16();
 }
Example #8
0
        static async Task Main(string[] args)
        {
            string type = args.Length > 0 ? args[0] : "hello";

            if (!Fuse.CheckDependencies())
            {
                Console.WriteLine(Fuse.InstallationInstructions);
                return;
            }

            IFuseFileSystem fileSystem;

            if (type == "hello")
            {
                fileSystem = new HelloFileSystem();
            }
            else if (type == "memory")
            {
                fileSystem = new MemoryFileSystem();
            }
            else if (type == "pokemon")
            {
                fileSystem = new PokemonFileSystem();
            }
            else
            {
                System.Console.WriteLine("Unknown file system type");
                return;
            }

            string mountPoint = $"/tmp/{type}fs";

            System.Console.WriteLine($"Mounting filesystem at {mountPoint}");

            Fuse.LazyUnmount(mountPoint);

            // Ensure mount point directory exists
            Directory.CreateDirectory(mountPoint);

            try
            {
                using (var mount = Fuse.Mount(mountPoint, fileSystem))
                {
                    await mount.WaitForUnmountAsync();
                }
            }
            catch (FuseException fe)
            {
                Console.WriteLine($"Fuse throw an exception: {fe}");

                Console.WriteLine("Try unmounting the file system by executing:");
                Console.WriteLine($"fuser -kM {mountPoint}");
                Console.WriteLine($"sudo umount -f {mountPoint}");
            }
        }
Example #9
0
    public static int Ping(string host)
    {
        Fuse fuse = new Fuse();

        fuse.Host(host);
        fuse.Connect();
        int time = Environment.TickCount;

        fuse.Push("ping");
        return(Environment.TickCount - time);
    }
Example #10
0
    void Start()
    {
        Log("Start");

        instance = this;

        input  = new Queue <string>();
        output = new Queue <string>();

        thread = new Thread(PushAsync);
        thread.Start();
    }
Example #11
0
    private void Update()
    {
        const float distanceThreshold = 5;
        const float fuseIncrement     = 1f / Fuse.FuseTicksPerSecond;
        const float fuseTimeMax       = 10f;

        if (currentTarget == null)
        {
            return;             // not active
        }
        if (!Input.GetMouseButton(0))
        {
            currentTarget = null;
            return;             // released LMB
        }

        // get mouse movement
        Vector3 newMousePos = Input.mousePosition;
        Vector3 mouseDelta  = newMousePos - prevMousePos;
        float   delta       = mouseDelta.x + mouseDelta.y + mouseDelta.z;
        float   distance    = Mathf.Abs(delta);

        if (distance > distanceThreshold)
        {
            // calculate fuse time change
            int   increments = Mathf.FloorToInt(distance / distanceThreshold);
            float change     = increments * fuseIncrement * Mathf.Sign(delta);

            // update fuse
            float prevFuseTime = currentTarget.timeToDetonate;
            float newFuseTime  = Mathf.Clamp(prevFuseTime + change, 0, fuseTimeMax);
            if (newFuseTime != prevFuseTime)
            {
                if (prevFuseTime <= 0)
                {
                    currentTarget.GetComponent <Bomb>()?.fuseSparkleEffect.SetActive(true);
                    SimulationState.Instance.OnBombFused();
                }
                else if (newFuseTime <= 0)
                {
                    currentTarget.GetComponent <Bomb>()?.fuseSparkleEffect.SetActive(false);
                    SimulationState.Instance.OnBombDefused();
                }

                UiSoundFx.GetOrCreate().PlayAdjustFuse();
                currentTarget.SetTimeToDetonate(newFuseTime);
            }

            // update recorded mouse position, carrying over any remainder
            prevMousePos    = newMousePos;
            prevMousePos.x -= (distance % distanceThreshold) * Mathf.Sign(delta);
        }
    }
Example #12
0
        /// <summary>
        /// Interpolate a stream using a specified interpolator at interpolation points
        /// given by a clock stream.
        /// </summary>
        /// <typeparam name="T">Type of source messages.</typeparam>
        /// <typeparam name="TClock">Type of messages on the clock stream.</typeparam>
        /// <typeparam name="TInterpolation">Type of the interpolation result.</typeparam>
        /// <param name="source">Source stream.</param>
        /// <param name="clock">Clock stream that dictates the interpolation points.</param>
        /// <param name="interpolator">Interpolator to use for generating results.</param>
        /// <param name="sourceDeliveryPolicy">An optional delivery policy for the source stream.</param>
        /// <param name="clockDeliveryPolicy">An optional delivery policy for the clock stream.</param>
        /// <returns>Output stream.</returns>
        public static IProducer <TInterpolation> Interpolate <T, TClock, TInterpolation>(
            this IProducer <T> source,
            IProducer <TClock> clock,
            Interpolator <T, TInterpolation> interpolator,
            DeliveryPolicy sourceDeliveryPolicy = null,
            DeliveryPolicy clockDeliveryPolicy  = null)
        {
            var fuse = new Fuse <TClock, T, TInterpolation, TInterpolation>(source.Out.Pipeline, interpolator, (clk, data) => data[0]);

            clock.PipeTo(fuse.InPrimary, clockDeliveryPolicy);
            source.PipeTo(fuse.InSecondaries[0], sourceDeliveryPolicy);
            return(fuse);
        }
Example #13
0
 public Process StartFuse(string command, params string[] commandArgs)
 {
     return(Fuse.Start(
                new ProcessStartInfo()
     {
         Arguments = command + " " + commandArgs.Select(s => "\"" + s + "\"").Join(" "),
         UseShellExecute = false,
         CreateNoWindow = true,
         WindowStyle = ProcessWindowStyle.Hidden,
         RedirectStandardOutput = true,
         RedirectStandardError = true,
         RedirectStandardInput = true
     }));
 }
Example #14
0
 private void btnStartActivity_Click(object sender, EventArgs e)
 {
     ControlEnabling(true);
     if (f == null)
     {
         f = new Fuse(
             (Fuse.FuseBehavior)Enum.Parse(typeof(Fuse.FuseBehavior), this.cbxFuseBehaviorType.Items[this.cbxFuseBehaviorType.SelectedIndex].ToString()),
             (int)this.nudHitThreshold.Value, (int)this.nudVolThreshold.Value,
             new TimeSpan(0, 0, 0, 0, (int)this.nudTimeframeMs.Value), this.chkAutoReset.Checked);
     }
     tmrActivityMaker.Interval = (int)this.nudActivityIntervalMs.Value;
     tmrActivityMaker.Enabled  = true;
     tmrActivityMaker.Start();
 }
Example #15
0
        public async Task Unmount_DisposesFileSystem()
        {
            DummyFileSystem dummyFileSystem = new DummyFileSystem();
            string          mountPoint      = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

            Directory.CreateDirectory(mountPoint);

            IFuseMount mount = Fuse.Mount(mountPoint, dummyFileSystem);

            bool unmounted = await mount.UnmountAsync(1000);

            Assert.True(unmounted);

            Assert.Equal(1, dummyFileSystem.DisposeCount);
        }
Example #16
0
 private void OnTriggerExit(Collider other)
 {
     // Ver si el que ha salido es el fusible que tiene
     if (fuse != null && other.gameObject.GetInstanceID() == fuse.gameObject.GetInstanceID())
     {
         GrabableObj gro = fuse.gameObject.GetComponent <GrabableObj>();
         // Activar rigidbody solo si no se esta cogiendo
         if (gro.GetGrabber() == null)
         {
             fuse.gameObject.GetComponent <Rigidbody>().isKinematic = false;
         }
         gro.IsDistanceGrabbable = gro.DG;
         fuse = null;
     }
 }
Example #17
0
    private void SaveFuseSettings()
    {
        ClearFuseSettings();

        Transform root = GetBombs().transform;

        for (int i = 0; i < root.childCount; ++i)
        {
            Fuse fuse = root.GetChild(i).GetComponent <Fuse>();
            if (fuse == null || fuse.timeToDetonate <= 0 || fuse.forbidPlayerInteraction)
            {
                continue;
            }
            fuseSettings.Add(i, fuse.timeToDetonate);
        }
    }
Example #18
0
    public void ResetEditing()
    {
        Debug.Assert(CurrentMode == Mode.Edit);

        Transform root = GetBombs().transform;

        for (int i = 0; i < root.childCount; ++i)
        {
            Fuse fuse = root.GetChild(i).GetComponent <Fuse>();
            if (fuse != null && fuse.timeToDetonate > 0 && !fuse.forbidPlayerInteraction)
            {
                fuse.timeToDetonate = 0;
            }
        }

        LoadLevel(Mode.Edit, null);
    }
Example #19
0
        public void ExampleUsage1()
        {
            // Example copied from the docu of https://github.com/kurozael/Fuse.NET
            var input = new List <Book>();

            input.Add(new Book {
                title = "The Code of The Wooster", author = "Bob James"
            });
            input.Add(new Book {
                title = "The Wooster Code", author = "Rick Martin"
            });
            input.Add(new Book {
                title = "The Code", author = "Jimmy Charles"
            });
            input.Add(new Book {
                title = "Old Man's War", author = "John Scalzi"
            });
            input.Add(new Book {
                title = "The Lock Artist", author = "Steve Hamilton"
            });

            var opt = new FuseOptions();

            opt.includeMatches = true;
            opt.includeScore   = true;
            // Here we search through a list of `Book` types but you could search through just a list of strings.
            var fuse = new Fuse <Book>(input, opt);

            fuse.AddKey("title");
            fuse.AddKey("author");
            var searchResult = fuse.Search("woo");

            searchResult.ForEach((FuseResult <Book> res) => {
                Log.d(res.item.title + ": " + res.item.author);
                Log.d("Search Result Score: " + res.score);

                if (res.matches != null)
                {
                    res.matches.ForEach((b) => {
                        Log.d("{Match}");
                        Log.d(b.key + ": " + b.value + " (Indicies: " + b.indicies.Count + ")");
                    });
                }
            });
        }
Example #20
0
    // Start is called before the first frame update
    void Start()
    {
        explosion_point = transform.Find("explosion_point");
        anim            = GetComponent <Animator>();
        explode_hash    = Animator.StringToHash("Explode");
        fuse            = transform.parent.GetComponentInChildren <Fuse>();
        if (fuse)
        {
            fuse.FuseFinishEvent += Explode;
        }

        rb                  = GetComponent <Rigidbody2D>();
        rb.isKinematic      = true;
        rb.interpolation    = RigidbodyInterpolation2D.Interpolate;
        end                 = transform.Find("end");
        dir                 = (end.position - transform.position).normalized;
        transform.parent.up = dir;
        rb.velocity         = dir * speed;
    }
Example #21
0
    void CheckFuseCollision(Collider2D collision)
    {
        if (!actionActivated)
        {
            return;
        }

        if (!collision.gameObject.CompareTag("Fuse"))
        {
            return;
        }

        Fuse fuse = collision.gameObject.GetComponent <Fuse>();

        if (fuse)
        {
            fuse.Activate();
        }
    }
Example #22
0
    private void LoadFuseSettings()
    {
        Transform root = GetBombs().transform;

        foreach (var pair in fuseSettings)
        {
            Fuse fuse = root.GetChild(pair.Key).GetComponent <Fuse>();
            fuse.SetTimeToDetonate(pair.Value);
        }

        foreach (var fuse in GetBombs().GetComponentsInChildren <Fuse>())
        {
            if (fuse.timeToDetonate > 0)
            {
                fuse.GetComponent <Bomb>()?.fuseSparkleEffect.SetActive(true);
            }
        }

        playState.fusedBombs = fuseSettings.Count;
    }
Example #23
0
            // Append a game object to the scene
            static public void Append(GameObject prefab)
            {
                if (sInstance != null && prefab != null)
                {
                    GameObject go = Instantiate(prefab) as GameObject;
                    if (go != null)
                    {
                        // Mark fuse animation complete when any new prefab is added
                        foreach (GameObject anim in sInstance.mAnimations)
                        {
                            if (anim != null)
                            {
                                Fuse f = anim.GetComponent <Fuse>();
                                if (f != null)
                                {
                                    f.isComplete = true;
                                }
                            }
                        }

                        // Put game object in hierarchy and fit it to the scene
                        go.transform.parent   = sInstance.transform;
                        go.transform.position = sInstance.transform.position;
                        Vector3 p = go.transform.position;
                        p.y += sInstance.offset;
                        go.transform.position = p;
                        go.transform.rotation = sInstance.transform.localRotation * go.transform.localRotation;
                        Vector3 s = sInstance.mScale;
                        s.x *= go.transform.localScale.x;
                        s.y *= go.transform.localScale.y;
                        s.z *= go.transform.localScale.z;
                        go.transform.localScale = s;

                        // Add the new game object to our list of animations
                        sInstance.mAnimations.Add(go);
                    }
                }
            }
Example #24
0
    public void SetState()
    {
        SceneState ss = new SceneState();

        if (sceneState_dic.ContainsKey(current_scene_name))
        {
            sceneState_dic.TryGetValue(current_scene_name, out ss);
        }

        for (int i = 0; i < parent.childCount; i++)
        {
            Fuse  fuse  = parent.GetChild(i).GetComponent <Fuse>();
            Box   box   = parent.GetChild(i).GetComponent <Box>();
            Light light = parent.GetChild(i).GetComponent <Light>();
            if (fuse != null)
            {
                int a = int.Parse(parent.GetChild(i).name);
                ss.fuseState[a].num        = fuse.num;
                ss.fuseState[a].volume_num = fuse.volume_num;
                ss.fuseState[a].isPlay     = fuse.isPlay;
                ss.fuseState[a].isVolume   = fuse.isVolume;
            }
            if (box != null)
            {
                int a = int.Parse(parent.GetChild(i).name);
                ss.boxState[a].num        = box.num;
                ss.boxState[a].volume_num = box.volume_num;
                ss.boxState[a].isPlay     = box.isPlay;
                ss.boxState[a].isVolume   = box.isVolume;
                ss.boxState[a].isStart    = box.isStart;
            }
            if (light != null)
            {
                ss.lightState.num    = light.curremt_num;
                ss.lightState.isPlay = light.isPlay;
            }
        }
    }
Example #25
0
    public void BeginInteraction(Fuse fuse)
    {
        if (SimulationState.Instance.CurrentMode != SimulationState.Mode.Edit)
        {
            return;
        }

        if (currentTarget != null)
        {
            return;
        }

        if (fuse.timeToDetonate <= 0 && !SimulationState.Instance.CanFuseBomb)
        {
            fuse.GetComponent <Bomb>()?.PlayNoFuseFx();
            return;
        }

        currentTarget = fuse;
        prevMousePos  = Input.mousePosition;

        fuse.GetComponent <Bomb>()?.PlaySelectFx();
    }
Example #26
0
        public static void Main(string[] args)
        {
            LoadComputer loadComputer = new LoadComputer();

            var var1 = Variable.GaussianFromMeanAndVariance(1, 4);
            var var2 = Variable.GaussianFromMeanAndVariance(1, 9);

            Fuse fuse1 = new Fuse(Variable.Bernoulli(1));
            Fuse fuse2 = new Fuse(Variable.Bernoulli(1));
            Fuse fuse3 = new Fuse(Variable.Bernoulli(1));

            Cable cable1 = new Cable();

            cable1.Load = Variable.GaussianFromMeanAndVariance(10, 0.64);
            fuse1.Cable = cable1;

            Cable cable2 = new Cable();

            cable2.Load = Variable.GaussianFromMeanAndVariance(10, 0.64);
            fuse2.Cable = cable2;

            Cable cable3 = new Cable();

            cable3.Load = Variable.GaussianFromMeanAndVariance(10, 0.64);
            fuse3.Cable = cable3;
            PointMass <double> d = new PointMass <double>(0);


            Substation substation = new Substation(Variable.GaussianFromMeanAndVariance(0, 0.001), fuse1, fuse2, fuse3);

            loadComputer.ComputeLoad(substation);

            var loadValue = (Gaussian)loadComputer.InferenceEngine.Infer(substation.Load);

            Console.WriteLine("Load: " + loadValue);
        }
Example #27
0
File: Fuse.cs Project: tinspin/fuse
    // ------------- EXAMPLE USAGE -------------
    public static void Main()
    {
        try {
            Log("Ping: " + Ping("fuse.rupy.se"));

            string key = "TvaaS3cqJhQyK6sn";
            string salt = null;

            Fuse fuse = new Fuse();
            fuse.Start();
            fuse.Host("fuse.rupy.se");

            //Thread.Sleep(100);

            Log("Time: " + fuse.Time());
            Log("Date: " + fuse.Date());

            // if no key is stored try
        /*
            try {
                key = fuse.User("fuse");
                Log("User: "******"F9hG7K7Jwe1SmtiQ";
            //key = "yt4QACtL2uzbyUTT";

            //if(key != null) {
                try {
                    salt = fuse.SignNameKey("fuse", key);
                }
                catch(Exception e) {
                    Log(e.Message);
                    return;
                }
            //}

            Log("Sign: " + salt);

            if(salt != null) {
                fuse.Pull(salt);

                // Very important to sleep a bit here
                // Use coroutines to send fuse.Game("race");
                // in Unity. Or send it on the first "noop" in Update()!
                Thread.Sleep(100);

                fuse.Game("race");

                Thread.Sleep(100);

                Thread thread = new Thread(FakeLoop);
                thread.Start();

                Thread.Sleep(500);

                fuse.Chat("root", "hello");

                Thread.Sleep(500);

                Log("Room: " + fuse.Room("race", 4));

                Thread.Sleep(500);

                string[] list = fuse.ListRoom();

                if(list != null) {
                    Log("List: " + list.Length);

                    for(int i = 0; i < list.Length; i++) {
                        string[] room = list[i].Split(',');
                        Log("      " + room[0] + " " + room[1] + " " + room[2]);
                    }
                }

                Thread.Sleep(500);

                fuse.Chat("root", "hello");

                Thread.Sleep(500);

                fuse.Send("white+0+0");
            }
        }
        catch(Exception e) {
            Log(e.ToString());
        }
    }
Example #28
0
 private void Start()
 {
     _fuse        = transform.GetChild(0).GetComponentInChildren <Fuse>();
     _bombTrigger = GetComponentInChildren <BombTrigger>();
 }
Example #29
0
        public void GeneratePrison(Vector2 position, GameData data)
        {
            const float doorSize      = 96;
            const float doorAscent    = 64;
            const float prisonWidth   = 576;
            const float prisonHeight  = 576;
            const float halfWidth     = prisonWidth / 2;
            const float halfHeight    = prisonHeight / 2;
            const float wallWidth     = 16;
            const float wallHalfWidth = wallWidth / 2;

            const float doorTopHeight         = doorSize + doorAscent;
            const float wallAboveDoorSize     = (prisonHeight - (doorAscent + doorSize));
            const float halfWallAboveDoorSize = wallAboveDoorSize / 2;

            const float cellSize           = prisonWidth / 3;
            const float cellDoorSize       = 96;
            float       internalWallHeight = position.Y + halfHeight - cellSize - wallHalfWidth;
            float       internalWallSize   = cellSize - cellDoorSize;

            //floor
            EntList.Add(new BldgFloor(position, new Vector2(prisonWidth, prisonHeight)));

            //solid walls
            EntList.Add(new BldgWall(position + new Vector2(0, halfHeight + wallHalfWidth), new Vector2(prisonWidth + 2 * wallWidth, wallWidth), 0));
            EntList.Add(new BldgWall(position - new Vector2(0, halfHeight + wallHalfWidth), new Vector2(prisonWidth + 2 * wallWidth, wallWidth), 0));
            EntList.Add(new BldgWall(position + new Vector2(halfWidth + wallHalfWidth, 0), new Vector2(prisonHeight, wallWidth), 3 * MathHelper.PiOver2));

            //wall w/ entrance
            EntList.Add(new BldgWall(position - new Vector2(halfWidth + wallHalfWidth, halfHeight - (doorAscent / 2)), new Vector2(doorAscent, wallWidth), MathHelper.PiOver2));
            EntList.Add(new BldgWall(position - new Vector2(halfWidth + wallHalfWidth, halfHeight - doorTopHeight - halfWallAboveDoorSize), new Vector2(wallAboveDoorSize, wallWidth), MathHelper.PiOver2));

            //internal walls
            EntList.Add(new BldgWall(new Vector2(position.X - halfWidth + cellDoorSize + (internalWallSize / 2), internalWallHeight), new Vector2(cellSize - cellDoorSize, wallWidth), 0));
            EntList.Add(new BldgWall(new Vector2(position.X - halfWidth + cellSize + cellDoorSize + (internalWallSize / 2), internalWallHeight), new Vector2(cellSize - cellDoorSize, wallWidth), 0));
            EntList.Add(new BldgWall(new Vector2(position.X - halfWidth + 2 * cellSize + cellDoorSize + (internalWallSize / 2), internalWallHeight), new Vector2(cellSize - cellDoorSize, wallWidth), 0));
            EntList.Add(new BldgWall(new Vector2(position.X - halfWidth + cellSize - wallHalfWidth, internalWallHeight + (cellSize / 2) + wallHalfWidth), new Vector2(cellSize, wallWidth), 3 * MathHelper.PiOver2));
            EntList.Add(new BldgWall(new Vector2(position.X - halfWidth + 2 * cellSize - wallHalfWidth, internalWallHeight + (cellSize / 2) + wallHalfWidth), new Vector2(cellSize, wallWidth), 3 * MathHelper.PiOver2));

            //key
            if (!data.PrisonKeyFound)
            {
                DoorKey prisonKey = new DoorKey(position + new Vector2(halfWidth, -halfHeight) - new Vector2(32, -32), "prison door key");
                PickupTriggers.Add(new TriggerPickup(prisonKey.Position, new Vector2(64, 64), prisonKey));
                EntList.Add(prisonKey);
            }

            Note n = new Note(position - new Vector2(halfWidth, halfHeight) + new Vector2(64, 64));

            EntList.Add(n);
            ReadingTriggers.Add(new TriggerReading(n.Position, new Vector2(64, 64), Notes.PrisonNote));

            //doors
            Door prisonDoor = new Door(new Vector2(position.X - halfWidth + (cellDoorSize / 2), internalWallHeight), 0, "prison door");

            if (!data.PrisonDoorOpened)
            {
                EntList.Add(prisonDoor);
            }
            else
            {
                prisonDoor.Unload();
            }
            EntList.Add(new Door(new Vector2(position.X - halfWidth + cellSize + (cellDoorSize / 2), internalWallHeight), 0));
            EntList.Add(new Door(new Vector2(position.X - halfWidth + cellSize * 2 + (cellDoorSize / 2), internalWallHeight), 0));

            DoorOpenTriggers.Add(new TriggerDoorOpen(prisonDoor.Position, new Vector2(96, 96), prisonDoor, "prison door key"));

            //fuse
            if (!data.FuseFound)
            {
                Fuse f = new Fuse(new Vector2(position.X - halfWidth + (cellSize / 2), internalWallHeight + (cellSize / 2)));
                EntList.Add(f);
                PickupTriggers.Add(new TriggerPickup(f.Position, new Vector2(64, 64), f));
            }
        }
Example #30
0
File: Fuse.cs Project: tinspin/fuse
 public static int Ping(string host)
 {
     Fuse fuse = new Fuse();
     fuse.Host(host);
     fuse.Connect();
     int time = Environment.TickCount;
     fuse.Push("ping");
     return Environment.TickCount - time;
 }
Example #31
0
File: Fuse.cs Project: tinspin/fuse
    void Start()
    {
        Log("Start");

        instance = this;

        input = new Queue<string>();
        output = new Queue<string>();

        thread = new Thread(PushAsync);
        thread.Start();
    }
Example #32
0
 public void Initialize(Fuse pairedFuse, int fuseIndex, int pairedFuseIndex)
 {
     this.pairedFuse = pairedFuse;
     FuseIndex       = fuseIndex;
     PairedFuseIndex = pairedFuseIndex;
 }
Example #33
0
            private void Update()
            {
                // Fade in the background music
                if (mAudioSource != null)
                {
                    mAudioSource.volume = mStartTime > 0.0f ? Mathf.Clamp((Time.realtimeSinceStartup - mStartTime) / audioFadeDuration, 0.0f, 1.0f) * mVolume : 0.0f;
                }

                // This value controls the interpolation of the scene
                // tracking so it won't appear to jump around
                const float speed = 0.5f;

                // Align the scene with the plane anchor values set by ARController
                transform.position      = Vector3.Lerp(transform.position, mPosition, speed);
                transform.localRotation = Quaternion.Slerp(transform.localRotation, mRotation, speed);
                Vector3 s = mScale;

                s.x *= mScaleOrigin.x;
                s.y *= mScaleOrigin.y;
                s.z *= mScaleOrigin.z;
                transform.localScale = Vector3.Lerp(transform.localScale, s, speed);

                // Walk through animations and determine what needs to be removed
                if (mAnimations != null)
                {
                    List <GameObject> completed = new List <GameObject>();
                    foreach (GameObject go in mAnimations)
                    {
                        if (go != null)
                        {
                            Animator anim     = go.GetComponent <Animator>();
                            Firework firework = go.GetComponent <Firework>();
                            Fuse     fuse     = go.GetComponent <Fuse>();
                            if ((firework != null && firework.isComplete) ||
                                (fuse != null && fuse.isComplete))
                            {
                                completed.Add(go);
                            }
                            else if (anim != null)
                            {
                                int i = anim.GetLayerIndex("Play");
                                if (i >= 0)
                                {
                                    AnimatorStateInfo asi = anim.GetCurrentAnimatorStateInfo(i);
                                    if (asi.normalizedTime >= 1.0f)
                                    {
                                        completed.Add(go);
                                    }
                                }
                            }
                        }
                    }
                    for (int i = 0; i < completed.Count; i++)
                    {
                        GameObject go = completed[i];
                        if (go != null && mAnimations.Contains(go))
                        {
                            go.transform.parent = null;
                            mAnimations.Remove(go);
                            Destroy(go);
                        }
                    }
                }
            }