Inheritance: MonoBehaviour, IInteractable
Example #1
0
        public CreditSlide(Torch.Scene scene, Torch.Object parent)
            : base(scene, parent)
        {
            var font = FontManager.Get("Menu");

            Components.Add(new TextObject(Game, this)
            {
                Font = font,
                Color = Color.White,
                Value = "Steve Phillips",
                Alignment = TextObject.AlignTypes.Center,
                X = Game.GraphicsDevice.Viewport.Width / 2,
                Y = Game.GraphicsDevice.Viewport.Height / 2 - 25
            });

            Components.Add(new TextObject(Game, this)
                {
                    Font = font,
                    Color = Color.White,
                    Value = "George Emond",
                    Alignment = TextObject.AlignTypes.Center,
                    X = Game.GraphicsDevice.Viewport.Width / 2,
                    Y = Game.GraphicsDevice.Viewport.Height / 2 + 25
                });
        }
Example #2
0
        public HallsNorth(Game game, Torch.Object parent, byte[] data)
            : base(game, data)
        {
            Name = "Coliseum Halls North";
            SandbagImage = "Zones/Coliseum/Halls/north-sb";
            Sandbag = Grid.FromBitmap(Game.Services, SandbagImage);
            ImageLayers.Add(new ImageObject(Game, parent, "Zones/Coliseum/Halls/north"));
            ImageLayers.Add(new ImageObject(Game, parent, "Zones/Coliseum/pillar") { X = 393, Y = 190, DrawOrder = 248 });
            ImageLayers.Add(new ImageObject(Game, parent, "Zones/Coliseum/pillar") { X = 393, Y = 390, DrawOrder = 448 });
            ImageLayers.Add(new ImageObject(Game, parent, "Zones/Coliseum/pillar") { X = 393, Y = 590, DrawOrder = 648 });
            ImageLayers.Add(new ImageObject(Game, parent, "Zones/Coliseum/pillar") { X = 593, Y = 190, DrawOrder = 248 });
            ImageLayers.Add(new ImageObject(Game, parent, "Zones/Coliseum/pillar") { X = 593, Y = 390, DrawOrder = 448 });
            ImageLayers.Add(new ImageObject(Game, parent, "Zones/Coliseum/pillar") { X = 593, Y = 590, DrawOrder = 648 });

            Doors.Add(new Door {Location = new Rectangle(500, 715, 50, 35), Name = "halls-south", Orientation = Direction.Up });
            Doors.Add(new Door { Location = new Rectangle(455, 100, 140, 35), Name = "village", Orientation = Direction.Up });

            Objects.Add(new InteractiveObject { Interact = SimpleDoor("coliseum/halls-south", "halls-north"), Location = new Rectangle(500, 740, 50, 15) });
            Objects.Add(new InteractiveObject { Interact = SimpleDoor("village/village", "coliseum"), Location = new Rectangle(455, 90, 140, 15) });

            Objects.Add(new InteractiveObject { Interact = TestBattle("coliseum/halls"), Location = new Rectangle(400, 200, 50, 50) });
            Objects.Add(new InteractiveObject { Interact = TestBattle("coliseum/halls"), Location = new Rectangle(400, 400, 50, 50) });
            Objects.Add(new InteractiveObject { Interact = TestBattle("coliseum/halls"), Location = new Rectangle(400, 600, 50, 50) });
            Objects.Add(new InteractiveObject { Interact = TestBattle("coliseum/halls"), Location = new Rectangle(600, 200, 50, 50) });
            Objects.Add(new InteractiveObject { Interact = TestBattle("coliseum/halls"), Location = new Rectangle(600, 400, 50, 50) });
            Objects.Add(new InteractiveObject { Interact = TestBattle("coliseum/halls"), Location = new Rectangle(600, 600, 50, 50) });
        }
Example #3
0
 public void Win(Torch[] torches) {
     PlayerPrefs.SetInt("solved", Mathf.Max(PlayerPrefs.GetInt("solved"), currentLevel + 1));
     AudioSource.PlayClipAtPoint(WinSound, Camera.main.transform.position.withZ(-7));
     for (int i = 0; i < torches.Length; i++) {
         var flash = (GameObject) Instantiate(FlashPrefab, torches[i].transform.position.withZ(-5), Quaternion.identity);
     }
 }
Example #4
0
        public Village(Game game, Torch.Object parent, byte[] data)
            : base(game, data)
        {
            Name = "Desert Village";
            SandbagImage = "Zones/Village/Village/sandbag";
            Sandbag = Grid.FromBitmap(Game.Services, SandbagImage);

            ImageLayers.Add(new ImageObject(Game, parent, "Zones/Village/Village/village"));

            ImageLayers.Add(new ImageObject(Game, parent, "Zones/Village/Village/inn") { X = 840, Y = 1372, DrawOrder = 1752 });
            ImageLayers.Add(new ImageObject(Game, parent, "Zones/Village/Village/warehouse") { X = 155, Y = 1300, DrawOrder = 1918 });
            ImageLayers.Add(new ImageObject(Game, parent, "Zones/Village/Village/well") { X = 1400, Y = 863, DrawOrder = 977 });
            ImageLayers.Add(new ImageObject(Game, parent, "Zones/Village/Village/Posts1") { X = 70, Y = 1940, DrawOrder = 2100 });
            ImageLayers.Add(new ImageObject(Game, parent, "Zones/Village/Village/house") { X = 754, Y = 701, DrawOrder = 1094 });

            Objects.Add(new InteractiveObject { Interact = SimpleDoor("village/shop", "village"), Location = new Rectangle(164*6, 192*6, 80, 40) });

            Doors.Add(new Door { Location = new Rectangle(1442, 2057, 171, 37), Name = "coliseum", Orientation = Direction.Up, Zone = "coliseum/halls-north", ZoneDoor = "village" });

            Doors.Add(new Door { Location = new Rectangle(69*6, 315*6, 9*6, 2), Name = "warehouse", Orientation = Direction.Down, Zone = "village/warehouse", ZoneDoor = "entrance" });
            Doors.Add(new Door { Location = new Rectangle(69*6, 320*6, 9*6, 2), Name = "warehouse exit", Orientation = Direction.Down });

            Doors.Add(new Door { Location = new Rectangle(177 * 6, 288 * 6, 12 * 6, 2), Name = "inn", Orientation = Direction.Down, Zone = "village/inn", ZoneDoor = "entrance" });
            Doors.Add(new Door { Location = new Rectangle(177 * 6, 295 * 6, 12 * 6, 2), Name = "inn exit", Orientation = Direction.Down });
            Doors.Add(new Door { Location = new Rectangle(164 * 6, 200 * 6, 80, 40), Name = "shop", Orientation = Direction.Down });
        }
Example #5
0
 public ImageObject(Microsoft.Xna.Framework.Game game, Torch.Object parent, string imageName)
     : base(game, parent)
 {
     Content = (ContentManager)(Game.Services.GetService(typeof (ContentManager)));
     _imageName = imageName;
     _image = Content.Load<Texture2D>(imageName);
     SourceRectangle = new Rectangle(0, 0, _image.Width, _image.Height);
 }
Example #6
0
        public TorchTensor forward(TorchTensor tensor)
        {
            var res = THSNN_LayerNorm_forward(handle.DangerousGetHandle(), tensor.Handle);

            if (res == IntPtr.Zero)
            {
                Torch.CheckForErrors();
            }
            return(new TorchTensor(res));
        }
Example #7
0
        static public Flatten Flatten(long startDim = 1, long endDim = -1)
        {
            var handle = THSNN_Flatten_ctor(startDim, endDim, out var boxedHandle);

            if (handle == IntPtr.Zero)
            {
                Torch.CheckForErrors();
            }
            return(new Flatten(handle, boxedHandle));
        }
Example #8
0
        /// <summary>
        /// Continuously Differentiable Exponential Linear Unit
        /// </summary>
        /// <param name="alpha">The α value for the CELU formulation. Default: 1.0</param>
        /// <param name="inPlace">Do the operation in-place. Default: False</param>
        /// <returns></returns>
        static public CELU CELU(double alpha = 1.0, bool inPlace = false)
        {
            var handle = THSNN_CELU_ctor(alpha, inPlace, out var boxedHandle);

            if (handle == IntPtr.Zero)
            {
                Torch.CheckForErrors();
            }
            return(new CELU(handle, boxedHandle));
        }
Example #9
0
        public TorchTensor ifft(long n = -1, long dim = -1, FFTNormType norm = FFTNormType.Backward)
        {
            var res = THSTensor_ifft(handle, n, dim, (sbyte)norm);

            if (res == IntPtr.Zero)
            {
                Torch.CheckForErrors();
            }
            return(new TorchTensor(res));
        }
Example #10
0
        static public TransformerEncoderLayer TransformerEncoderLayer(long d_model = 512, long nhead = 8, long dim_feedforward = 2048, double dropout = 0.1, Transformer.Activations activation = NN.Transformer.Activations.ReLU)
        {
            var res = THSNN_TransformerEncoderLayer_ctor(d_model, nhead, dim_feedforward, dropout, (long)activation, out var boxedHandle);

            if (res == IntPtr.Zero)
            {
                Torch.CheckForErrors();
            }
            return(new TransformerEncoderLayer(res, boxedHandle));
        }
Example #11
0
        /// <summary>
        /// Randomized Rectified Linear Unit
        /// </summary>
        /// <param name="lower">Lower bound of the uniform distribution. Default: 1/8</param>
        /// <param name="upper">Upper bound of the uniform distribution. Default: 1/3</param>
        /// <param name="inPlace">Do the operation in-place. Default: False</param>
        /// <returns></returns>
        static public RReLU RReLU(double lower = one_eighth, double upper = one_third, bool inPlace = false)
        {
            var handle = THSNN_RReLU_ctor(lower, upper, inPlace, out var boxedHandle);

            if (handle == IntPtr.Zero)
            {
                Torch.CheckForErrors();
            }
            return(new RReLU(handle, boxedHandle));
        }
Example #12
0
        public TorchTensor forward(TorchTensor input1, TorchTensor input2)
        {
            var res = THSNN_PairwiseDistance_forward(handle, input1.Handle, input2.Handle);

            if (res == IntPtr.Zero)
            {
                Torch.CheckForErrors();
            }
            return(new TorchTensor(res));
        }
Example #13
0
        /// <summary>
        /// Reverses the PixelShuffle operation by rearranging elements in a tensor of shape (*, C, H * r, W * r) to a tensor of shape (*, C * r^2, H, W), where r is an downscale factor.
        /// </summary>
        /// <param name="downscaleFactor">Factor to increase spatial resolution by</param>
        /// <returns></returns>
        static public PixelUnshuffle PixelUnshuffle(long downscaleFactor)
        {
            var handle = THSNN_PixelUnshuffle_ctor(downscaleFactor, out var boxedHandle);

            if (handle == IntPtr.Zero)
            {
                Torch.CheckForErrors();
            }
            return(new PixelUnshuffle(handle, boxedHandle));
        }
Example #14
0
        /// <summary>
        /// Forward pass.
        /// </summary>
        /// <param name="tensor">Input tensor</param>
        /// <returns></returns>
        public override TorchTensor forward(TorchTensor tensor)
        {
            var res = THSNN_PixelUnshuffle_forward(handle, tensor.Handle);

            if (res == IntPtr.Zero)
            {
                Torch.CheckForErrors();
            }
            return(new TorchTensor(res));
        }
Example #15
0
        static public GRU GRU(long inputSize, long hiddenSize, long numLayers = 1, bool bias = true, bool batchFirst = false, double dropout = 0.0, bool bidirectional = false)
        {
            var res = THSNN_GRU_ctor(inputSize, hiddenSize, numLayers, bias, batchFirst, dropout, bidirectional, out var boxedHandle);

            if (res == IntPtr.Zero)
            {
                Torch.CheckForErrors();
            }
            return(new GRU(res, boxedHandle));
        }
Example #16
0
        public (TorchTensor, TorchTensor) forward(TorchTensor input, TorchTensor?h0 = null)
        {
            var res = THSNN_GRU_forward(handle, input.Handle, h0?.Handle ?? IntPtr.Zero, out IntPtr hN);

            if (res == IntPtr.Zero || hN == IntPtr.Zero)
            {
                Torch.CheckForErrors();
            }
            return(new TorchTensor(res), new TorchTensor(hN));
        }
Example #17
0
        public TorchTensor Forward(TorchTensor tensor)
        {
            var res = THSNN_AdaptiveAvgPool2d_forward(handle.DangerousGetHandle(), tensor.Handle);

            if (res == IntPtr.Zero)
            {
                Torch.CheckForErrors();
            }
            return(new TorchTensor(res));
        }
Example #18
0
        /// <summary>
        /// Softmin
        /// </summary>
        /// <param name="dim">A dimension along which Softmin will be computed (so every slice along dim will sum to 1)</param>
        /// <returns></returns>
        static public Softmin Softmin(long dim)
        {
            var handle = THSNN_Softmin_ctor(dim, out var boxedHandle);

            if (handle == IntPtr.Zero)
            {
                Torch.CheckForErrors();
            }
            return(new Softmin(handle, boxedHandle));
        }
Example #19
0
        static public Dropout Dropout(double probability = 0.5)
        {
            var handle = THSNN_Dropout_ctor(probability, out var boxedHandle);

            if (handle == IntPtr.Zero)
            {
                Torch.CheckForErrors();
            }
            return(new Dropout(handle, boxedHandle));
        }
Example #20
0
        static public PairwiseDistance PairwiseDistance(double p = 2.0, double eps = 1e-6, bool keep_dim = false)
        {
            var handle = THSNN_PairwiseDistance_ctor(p, eps, keep_dim, out var boxedHandle);

            if (handle == IntPtr.Zero)
            {
                Torch.CheckForErrors();
            }
            return(new PairwiseDistance(handle, boxedHandle));
        }
Example #21
0
        /// <summary>
        /// Sigmoid-Weighted Linear Unit
        /// </summary>
        /// <returns></returns>
        /// <remarks>The native libreary does not take an 'inplace' option, even though the PyTorch documentation mentions the parameter.</remarks>
        static public SiLU SiLU()
        {
            var handle = THSNN_SiLU_ctor(out var boxedHandle);

            if (handle == IntPtr.Zero)
            {
                Torch.CheckForErrors();
            }
            return(new SiLU(handle, boxedHandle));
        }
Example #22
0
        /// <summary>
        /// Pads the input tensor boundaries with zero.
        /// </summary>
        /// <param name="padding">The size of the padding.</param>
        /// <returns></returns>
        static public ReflectionPad1d ReflectionPad1d(long padding)
        {
            var handle = THSNN_ReflectionPad1d_ctor(padding, out var boxedHandle);

            if (handle == IntPtr.Zero)
            {
                Torch.CheckForErrors();
            }
            return(new ReflectionPad1d(handle, boxedHandle));
        }
Example #23
0
        /// <summary>
        /// Randomly zero out entire channels (a channel is a 2D feature map, e.g., the jj -th channel of the ii -th sample in the batched input is a 2D tensor \text{input}[i, j]input[i,j] ).
        /// Each channel will be zeroed out independently on every forward call with probability p using samples from a Bernoulli distribution.
        /// </summary>
        /// <param name="probability">Probability of an element to be zeroed. Default: 0.5</param>
        /// <param name="inPlace">If set to true, will do this operation in-place. Default: false</param>
        /// <returns></returns>
        static public AlphaDropout AlphaDropout(double probability = 0.5, bool inPlace = false)
        {
            var handle = THSNN_AlphaDropout_ctor(probability, inPlace, out var boxedHandle);

            if (handle == IntPtr.Zero)
            {
                Torch.CheckForErrors();
            }
            return(new AlphaDropout(handle, boxedHandle));
        }
Example #24
0
        public override TorchTensor forward(TorchTensor input)
        {
            var res = THSNN_Embedding_forward(handle, input.Handle);

            if (res == IntPtr.Zero)
            {
                Torch.CheckForErrors();
            }
            return(new TorchTensor(res));
        }
Example #25
0
        /// <summary>
        /// Continuously Differentiable Exponential Linear Unit
        /// </summary>
        /// <param name="negativeSlope">The α value for the LeakyReLU formulation. Default: 1.0</param>
        /// <param name="inPlace">Do the operation in-place. Default: False</param>
        /// <returns></returns>
        static public LeakyReLU LeakyReLU(double negativeSlope = 1.0, bool inPlace = false)
        {
            var handle = THSNN_LeakyReLU_ctor(negativeSlope, inPlace, out var boxedHandle);

            if (handle == IntPtr.Zero)
            {
                Torch.CheckForErrors();
            }
            return(new LeakyReLU(handle, boxedHandle));
        }
Example #26
0
        /// <summary>
        /// Pads the input tensor boundaries with zero.
        /// </summary>
        /// <param name="padding">The size of the padding.</param>
        /// <returns></returns>
        static public ZeroPad2d ZeroPad2d(long padding)
        {
            var handle = THSNN_ZeroPad2d_ctor(padding, out var boxedHandle);

            if (handle == IntPtr.Zero)
            {
                Torch.CheckForErrors();
            }
            return(new ZeroPad2d(handle, boxedHandle));
        }
Example #27
0
        public override TorchTensor forward(TorchTensor tensor)
        {
            var res = THSNN_ConvTranspose3d_forward(handle, tensor.Handle);

            if (res == IntPtr.Zero)
            {
                Torch.CheckForErrors();
            }
            return(new TorchTensor(res));
        }
Example #28
0
        /// <summary>
        /// Forward pass.
        /// </summary>
        /// <param name="tensor">Input tensor</param>
        /// <returns></returns>
        public TorchTensor forward(TorchTensor tensor)
        {
            var res = THSNN_ZeroPad2d_forward(handle, tensor.Handle);

            if (res == IntPtr.Zero)
            {
                Torch.CheckForErrors();
            }
            return(new TorchTensor(res));
        }
Example #29
0
        /// <summary>
        /// Applies Softmax over features to each spatial location
        /// </summary>
        /// <returns></returns>
        static public Softmax2d Softmax2d()
        {
            var handle = THSNN_Softmax2d_ctor(out var boxedHandle);

            if (handle == IntPtr.Zero)
            {
                Torch.CheckForErrors();
            }
            return(new Softmax2d(handle, boxedHandle));
        }
Example #30
0
        static public TransformerDecoder TransformerDecoder(TransformerDecoderLayer decoder_layer, long num_layers)
        {
            var res = THSNN_TransformerDecoder_ctor(decoder_layer.handle, num_layers, out var boxedHandle);

            if (res == IntPtr.Zero)
            {
                Torch.CheckForErrors();
            }
            return(new TransformerDecoder(res, boxedHandle));
        }
Example #31
0
        /// <summary>
        /// Rectified Linear Unit
        ///
        /// This ReLU version caps positive values at 6.
        /// </summary>
        /// <param name="inPlace">Do the operation in-place. Default: False</param>
        /// <returns></returns>
        static public ReLU6 ReLU6(bool inPlace = false)
        {
            var handle = THSNN_ReLU6_ctor(inPlace, out var boxedHandle);

            if (handle == IntPtr.Zero)
            {
                Torch.CheckForErrors();
            }
            return(new ReLU6(handle, boxedHandle));
        }
Example #32
0
        /// <summary>
        /// Pads the input tensor using replication of the input boundary.
        /// </summary>
        /// <param name="padding">The size of the padding.</param>
        /// <param name="value"></param>
        /// <returns></returns>
        static public ConstantPad2d ConstantPad2d(long padding, double value)
        {
            var handle = THSNN_ConstantPad2d_ctor(value, padding, out var boxedHandle);

            if (handle == IntPtr.Zero)
            {
                Torch.CheckForErrors();
            }
            return(new ConstantPad2d(handle, boxedHandle));
        }
Example #33
0
        /// <summary>
        /// Computes the arccosine of the elements of input.
        /// </summary>
        /// <returns></returns>
        public TorchTensor acos_()
        {
            var res = THSTensor_acos_(handle);

            if (res == IntPtr.Zero)
            {
                Torch.CheckForErrors();
            }
            return(new TorchTensor(res));
        }
Example #34
0
        /// <summary>
        /// Element-wise arctangent of input / other with consideration of the quadrant.
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public TorchTensor atan2_(TorchTensor other)
        {
            var res = THSTensor_atan2_(handle, other.Handle);

            if (res == IntPtr.Zero)
            {
                Torch.CheckForErrors();
            }
            return(new TorchTensor(res));
        }
Example #35
0
        static public Conv2d Conv2d(long inputChannel, long outputChannel, long kernelSize, long stride = 1, long padding = 0, long dilation = 1, PaddingModes paddingMode = PaddingModes.Zeros, long groups = 1, bool bias = true)
        {
            var res = THSNN_Conv2d_ctor(inputChannel, outputChannel, kernelSize, stride, padding, dilation, (long)paddingMode, groups, bias, out var boxedHandle);

            if (res == IntPtr.Zero)
            {
                Torch.CheckForErrors();
            }
            return(new Conv2d(res, boxedHandle));
        }
Example #36
0
        public Warehouse(Game game, Torch.Object parent, byte[] data)
            : base(game, data)
        {
            Name = "Village Warehouse";
            SandbagImage = "Zones/Village/Warehouse/sandbag";
            Sandbag = Grid.FromBitmap(Game.Services, SandbagImage);

            ImageLayers.Add(new ImageObject(Game, parent, "Zones/Village/Warehouse/warehouse"));

            Doors.Add(new Door { Location = new Rectangle(56*6, 130*6, 10*6, 1), Name = "entrance", Orientation = Direction.Up, Zone = "village/village", ZoneDoor = "warehouse exit"});
        }
Example #37
0
        public Inn(Game game, Torch.Object parent, byte[] data)
            : base(game, data)
        {
            Name = "Village Inn";
            SandbagImage = "Zones/Village/Inn/sandbag";
            Sandbag = Grid.FromBitmap(Game.Services, SandbagImage);
            ImageLayers.Add(new ImageObject(Game, parent, "Zones/Village/Inn/inn"));
            Doors.Add(new Door { Location = new Rectangle(63*6, 93*6, 13*6, 2), Zone = "village/village", ZoneDoor = "inn exit", Name = "entrance", Orientation = Direction.Up });
            Doors.Add(new Door { Location = new Rectangle(215, 265, 75, 75), Name = "save", Orientation = Direction.Down });

            AddSavepoint(215, 265);
        }
Example #38
0
        public HallsEast(Game game, Torch.Object parent, byte[] data)
            : base(game, data)
        {
            Name = "Coliseum Halls East";
            SandbagImage = "Zones/Coliseum/Halls/east-sb";
            Sandbag = Grid.FromBitmap(Game.Services, SandbagImage);
            ImageLayers.Add(new ImageObject(Game, parent, "Zones/Coliseum/Halls/east"));

            Doors.Add(new Door {Location = new Rectangle(60, 450, 35, 50), Name = "halls-south", Orientation = Direction.Right });

            Objects.Add(new InteractiveObject { Interact = SimpleDoor("coliseum/halls-south", "halls-east"), Location = new Rectangle(50, 450, 15, 50) });
        }
Example #39
0
        public KeyboardInput(Torch.Scene scene, Torch.Object parent)
            : base(scene, parent)
        {
            var keyboard = ((InputManager) scene.Game.Services.GetService(typeof (IInputService))).GetKeyboard();
            keyboard.KeyPressed += HandleKeyDown;

            _controls.Add("left", Keys.A);
            _controls.Add("right", Keys.D);
            _controls.Add("up", Keys.W);
            _controls.Add("down", Keys.S);
            _controls.Add("party menu", Keys.Tab);
            _controls.Add("config menu", Keys.Escape);
            _controls.Add("interact", Keys.E);
        }
Example #40
0
        public static Zone Factory(Game game, Torch.Object parent, string name)
        {
            var data = ((SRPGGame) game).ZoneData.ContainsKey(name) ? ((SRPGGame)game).ZoneData[name] : new byte[] {};
            Zone zone;

            switch(name)
            {
                case "kakariko/village":
                    zone =  new Zones.Kakariko.Village(game, parent, data);
                    break;
                case "kakariko/bombshop":
                    zone =  new Zones.Kakariko.Bombshop(game, parent, data);
                    break;
                case "kakariko/inn":
                    zone =  new Zones.Kakariko.Inn(game, parent, data);
                    break;

                case "village/village":
                    zone =  new Zones.Village.Village(game, parent, data);
                    break;
                case "village/warehouse":
                    zone =  new Zones.Village.Warehouse(game, parent, data);
                    break;
                case "village/inn":
                    zone =  new Zones.Village.Inn(game, parent, data);
                    break;
                case "village/shop":
                    zone = new Zones.Village.Shop(game, parent, data);
                    break;

                case "coliseum/cell":
                    zone =  new Zones.Coliseum.Cell(game, parent, data);
                    break;
                case "coliseum/halls-south":
                    zone =  new Zones.Coliseum.HallsSouth(game, parent, data);
                    break;
                case "coliseum/halls-north":
                    zone =  new Zones.Coliseum.HallsNorth(game, parent, data);
                    break;
                case "coliseum/halls-east":
                    zone =  new Zones.Coliseum.HallsEast(game, parent, data);
                    break;

                default:
                    throw new ZoneException(String.Format("Unable to generate unknown zone '{0}'.", name));
            }

            zone.Key = name;
            return zone;
        }
Example #41
0
        public Village(Game game, Torch.Object parent, byte[] data)
            : base(game, data)
        {
            Name = "Kakariko Village";
            SandbagImage = "Zones/Kakariko/village/sandbag";
            Sandbag = Grid.FromBitmap(Game.Services, SandbagImage);
            ImageLayers = new List<ImageObject>
                {
                    new ImageObject(Game, parent, "Zones/Kakariko/Village/village") {DrawOrder = -1},
                    new ImageObject(Game, parent, "Zones/Kakariko/Village/arch") {X = 2568, Y = 2784, DrawOrder = 2925},
                    new ImageObject(Game, parent, "Zones/Kakariko/Village/house_1") {X = 1728, Y = 336, DrawOrder = 587},
                    new ImageObject(Game, parent, "Zones/Kakariko/Village/mailbox") {X = 483, Y = 1152, DrawOrder = 1224},
                    new ImageObject(Game, parent, "Zones/Kakariko/Village/cave") {X = 534, Y = 565, DrawOrder = 660},
                    new ImageObject(Game, parent, "Zones/Kakariko/Village/bombshop") {X = 240, Y = 2544, DrawOrder = 2750},
                };

            Objects = new List<InteractiveObject>();

            // mailbox
            var obj = new InteractiveObject { Location = new Rectangle(486, 1200, 36, 24) };
            obj.Interact += SimpleDialog("kakariko/town", "mailbox");
            Objects.Add(obj);

            // statue
            obj = new InteractiveObject { Location = new Rectangle(1512, 1224, 96, 96) };
            obj.Interact += SimpleDialog("kakariko/town", "statue");
            Objects.Add(obj);

            // cliff
            obj = new InteractiveObject { Location = new Rectangle(268, 445, 312 - 268, 5) };
            obj.Interact += SimpleDialog("kakariko/town", "cliff");
            Objects.Add(obj);

            // inn
            obj = new InteractiveObject {Location = new Rectangle(1895, 2009, 48, 7)};
            obj.Interact += SimpleDoor("kakariko/inn", "entrance");
            Objects.Add(obj);

            // merchant
            obj = new InteractiveObject {Location = new Rectangle(1941, 2736, 54, 12)};
            obj.Interact += SimpleMerchant("kakariko/town", "merchant");
            Objects.Add(obj);

            Doors = new List<Door>
                {
                    new Door { Location = new Rectangle(312, 2725, 48, 8), Name = "bombshop", Orientation = Direction.Down, Zone = "kakariko/bombshop", ZoneDoor = "entrance" },
                    new Door { Location = new Rectangle(2664, 2997, 48, 32), Name = "arch", Orientation = Direction.Up },
                    new Door { Location = new Rectangle(1895, 2030, 48, 7), Name = "inn", Orientation = Direction.Down }
                };
        }
Example #42
0
    public void Player_AttemptingToPickUpItemTwice_DoesntIncreaseInventorySize()
    {
        Torch torch = new Torch();
        GameBuilder.CreateGame()
            .WithRoom("room1")
                .WithItems(torch);
        var game = GameBuilder.Build();
        int previousInventorySize = game.Player.Inventory.Count;

        game.PickUpItem(torch);
        game.PickUpItem(torch);

        Assert.AreEqual(previousInventorySize + 1, game.Player.Inventory.Count);
    }
Example #43
0
        public DialogLayer(Torch.Scene scene, Dialog dialog)
        {
            InitializeComponent();

            _dialog = dialog;

            _keyboard = ((InputManager)scene.Game.Services.GetService(typeof(IInputService))).GetKeyboard();
            _keyboard.KeyPressed += OnKeyPress;

            _optionsList.SelectionChanged += (s, a) =>
                    _dialog.SetOption(_optionsList.SelectedItems.Count > 0 ? _optionsList.SelectedItems[0] : -1);

            _nextButton.Pressed += (s, a) => OnKeyPress(Keys.E);

            InitializeDialog();
        }
Example #44
0
        public HallsSouth(Game game, Torch.Object parent, byte[] data)
            : base(game, data)
        {
            Name = "Coliseum Halls South";
            SandbagImage = "Zones/Coliseum/Halls/south-sb";
            Sandbag = Grid.FromBitmap(Game.Services, SandbagImage);
            ImageLayers.Add(new ImageObject(Game, parent, "Zones/Coliseum/Halls/south"));

            Doors.Add(new Door {Location = new Rectangle(345, 550, 50, 35), Name = "cell", Orientation = Direction.Up });
            Doors.Add(new Door { Location = new Rectangle(100, 100, 50, 35), Name = "halls-north", Orientation = Direction.Down });
            Doors.Add(new Door { Location = new Rectangle(660, 300, 35, 50), Name = "halls-east", Orientation = Direction.Left });

            Objects.Add(new InteractiveObject { Interact = SimpleDoor("coliseum/cell", "halls"), Location = new Rectangle(345, 585, 50, 25) });
            Objects.Add(new InteractiveObject { Interact = SimpleDoor("coliseum/halls-north", "halls-south"), Location = new Rectangle(100, 90, 50, 15) });
            Objects.Add(new InteractiveObject { Interact = SimpleDoor("coliseum/halls-east", "halls-south"), Location = new Rectangle(700, 300, 15, 50) });
        }
Example #45
0
        public BattleBoardLayer(Torch.Scene scene, Torch.Object parent)
            : base(scene, parent)
        {
            _gui = new GuiManager(
                (GraphicsDeviceManager)Game.Services.GetService(typeof(IGraphicsDeviceManager)),
                (IInputService)Game.Services.GetService(typeof(IInputService))
            );
            _gui.DrawOrder = 0;
            _gui.Initialize();

            _gui.Visualizer = FlatGuiVisualizer.FromFile(Game.Services, "Content/Gui/main_gui.xml");
            ((FlatGuiVisualizer)_gui.Visualizer).RendererRepository.AddAssembly(typeof(FlatGridCellControlRenderer).Assembly);

            Components.Add(_gui);

            ((IInputService)Game.Services.GetService(typeof(IInputService))).GetMouse().MouseButtonPressed += OnMouseButtonPressed;
        }
Example #46
0
    public static void Register(Torch torch)
    {
        if (initialized == false) {
            Torches.Initialize();
        }

        foreach (var group in torch.groups) {
            if (Torches.groups.ContainsKey(group) == false) {
                Torches.groups.Add(group, new HashSet<Torch> {
                    torch
                });
            }
            else {
                Torches.groups[group].Add(torch);
            }
        }
    }
Example #47
0
        public Bombshop(Game game, Torch.Object parent, byte[] data)
            : base(game, data)
        {
            Name = "Kakariko Shop";
            SandbagImage = "Zones/Kakariko/Bombshop/sandbag";
            Sandbag = Grid.FromBitmap(Game.Services, SandbagImage);
            ImageLayers = new List<ImageObject>
                {
                    new ImageObject(Game, parent, "Zones/Kakariko/Bombshop/bombshop") {DrawOrder = -1},
                };

            Objects = new List<InteractiveObject>();

            Doors = new List<Door>
                {
                    new Door { Location = new Rectangle(264, 457, 48, 14), Name = "entrance", Orientation = Direction.Up, Zone = "kakariko/village", ZoneDoor = "bombshop" }
                };
        }
Example #48
0
        public Inn(Game game, Torch.Object parent, byte[] data)
            : base(game, data)
        {
            Name = "Kakariko Inn";
            SandbagImage = "Zones/Kakariko/Inn/sandbag";
            Sandbag = Grid.FromBitmap(Game.Services, SandbagImage);
            ImageLayers = new List<ImageObject>
                {
                    new ImageObject(Game, parent, "Zones/Kakariko/Inn/inn") { DrawOrder = -1},
                };

            Objects = new List<InteractiveObject>();

            Doors = new List<Door>
                {
                    new Door { Location = new Rectangle(258, 456, 59, 23), Name = "entrance", Orientation = Direction.Up, Zone = "kakariko/village", ZoneDoor = "inn" }
                };
        }
Example #49
0
 public TextObject(Microsoft.Xna.Framework.Game game, Torch.Object parent)
     : base(game, parent)
 {
 }
        /// <summary>
        /// Builds a patch using given paths for the target and upgrade packages.
        /// </summary>
        /// <param name="targetPath">The path to the target MSI.</param>
        /// <param name="upgradePath">The path to the upgrade MSI.</param>
        /// <param name="name">The name of the patch to build.</param>
        /// <param name="version">Optional version for the bundle.</param>
        /// <returns>The path to the patch.</returns>
        private string BuildPatch(string targetPath, string upgradePath, string name, string version)
        {
            // Get the name of the calling method.
            StackTrace stack = new StackTrace();
            string caller = stack.GetFrame(1).GetMethod().Name;

            // Create paths.
            string source = Path.Combine(this.TestContext.TestDataDirectory, String.Concat(name, ".wxs"));
            string rootDirectory = FileUtilities.GetUniqueFileName();
            string objDirectory = Path.Combine(rootDirectory, Settings.WixobjFolder);
            string msiDirectory = Path.Combine(rootDirectory, Settings.MsiFolder);
            string wixmst = Path.Combine(objDirectory, String.Concat(name, ".wixmst"));
            string wixmsp = Path.Combine(objDirectory, String.Concat(name, ".wixmsp"));
            string package = Path.Combine(msiDirectory, String.Concat(name, ".msp"));

            // Add the root directory to be cleaned up.
            this.TestArtifacts.Add(new DirectoryInfo(rootDirectory));

            // Compile.
            Candle candle = new Candle();
            candle.Extensions.AddRange(DependencyExtensionTests.Extensions);
            candle.OtherArguments = String.Concat("-dTestName=", caller);
            if (!String.IsNullOrEmpty(version))
            {
                candle.OtherArguments = String.Concat(candle.OtherArguments, " -dVersion=", version);
            }
            candle.OutputFile = String.Concat(objDirectory, @"\");
            candle.SourceFiles.Add(source);
            candle.WorkingDirectory = this.TestContext.TestDataDirectory;
            candle.Run();

            // Make sure the output directory is cleaned up.
            this.TestArtifacts.Add(new DirectoryInfo(objDirectory));

            // Link.
            Light light = new Light();
            light.Extensions.AddRange(DependencyExtensionTests.Extensions);
            light.ObjectFiles = candle.ExpectedOutputFiles;
            light.OutputFile = wixmsp;
            light.SuppressMSIAndMSMValidation = true;
            light.WorkingDirectory = this.TestContext.TestDataDirectory;
            light.Run();

            // Make sure the output directory is cleaned up.
            this.TestArtifacts.Add(new DirectoryInfo(msiDirectory));

            // Torch.
            Torch torch = new Torch();
            torch.TargetInput = Path.ChangeExtension(targetPath, "wixpdb");
            torch.UpdatedInput = Path.ChangeExtension(upgradePath, "wixpdb");
            torch.PreserveUnmodified = true;
            torch.XmlInput = true;
            torch.OutputFile = wixmst;
            torch.WorkingDirectory = this.TestContext.TestDataDirectory;
            torch.Run();

            // Pyro.
            Pyro pyro = new Pyro();
            pyro.Baselines.Add(torch.OutputFile, name);
            pyro.InputFile = light.OutputFile;
            pyro.OutputFile = package;
            pyro.WorkingDirectory = this.TestContext.TestDataDirectory;
            pyro.SuppressWarnings.Add("1079");
            pyro.Run();

            return pyro.OutputFile;
        }
Example #51
0
        public static Item Create(int type, int amount = -1, Entity owner = null)
        {
            Item newItem;
            if (GameData.GameItems[type] is Gun)
                newItem = new Gun(type, amount, owner);
            else if (GameData.GameItems[type] is Melee)
                newItem = new Melee(type, amount, owner);
            else if (GameData.GameItems[type] is Goggles)
                newItem = new Goggles(type, owner);
            else if (GameData.GameItems[type] is Torch)
                newItem = new Torch(type, owner);
            else if (GameData.GameItems[type] is SmartPhone)
                newItem = new SmartPhone(type, owner);
            else if (GameData.GameItems[type] is Togglable)
                newItem = new Togglable(type, owner);
            else
                newItem = new Item(type, amount, owner);

            return newItem;
        }
Example #52
0
        public Cell(Game game, Torch.Object parent, byte[] data)
            : base(game, data)
        {
            Name = "Coliseum Slave Cells";
            SandbagImage = "Zones/Coliseum/Cell/sandbag";
            Sandbag = Grid.FromBitmap(Game.Services, SandbagImage);
            ImageLayers.Add(new ImageObject(Game, parent, "Zones/Coliseum/Cell/cell"));
            ImageLayers.Add(new ImageObject(Game, parent, "Zones/Coliseum/Cell/bars") { X = 50, Y = 300, DrawOrder = 350 });
            ImageLayers.Add(new ImageObject(Game, parent, "Zones/Coliseum/Cell/bars") { X = 50, Y = 500, DrawOrder = 550 });
            Doors.Add(new Door { Location = new Rectangle(100, 650, 7*6, 8*6), Name = "bed", Orientation = Direction.Right });
            Doors.Add(new Door { Location = new Rectangle(905, 200, 45, 25), Name = "halls", Orientation = Direction.Down });

            Objects.Add(new InteractiveObject { Interact = SimpleDoor("coliseum/halls-south", "cell"), Location = new Rectangle(905, 190, 45, 15) });
            #if DEBUG
            Objects.Add(new InteractiveObject
                {Interact = TestBattle("coliseum/halls"), Location = new Rectangle(230, 550, 10, 50)});
            #endif
            var propsSprite = new SpriteObject(Game, parent, "Zones/Coliseum/Cell/props");
            propsSprite.AddAnimation("barrel1", new SpriteAnimation { FrameRate = 1, FrameCount = 1, Size = new Rectangle(0, 0, 41, 51), StartRow = 63, StartCol = 99 });
            propsSprite.AddAnimation("barrel2", new SpriteAnimation { FrameRate = 1, FrameCount = 1, Size = new Rectangle(0, 0, 41, 50), StartRow = 63, StartCol = 140 });
            propsSprite.AddAnimation("bed1", new SpriteAnimation { FrameRate = 1, FrameCount = 1, Size = new Rectangle(0, 0, 94, 50), StartRow = 0, StartCol = 161 });
            propsSprite.AddAnimation("bed1-r", new SpriteAnimation { FrameRate = 1, FrameCount = 1, Size = new Rectangle(0, 0, 94, 50), StartRow = 0, StartCol = 161 });
            propsSprite.AddAnimation("bed2", new SpriteAnimation { FrameRate = 1, FrameCount = 1, Size = new Rectangle(0, 0, 47, 87), StartRow = 0, StartCol = 52 });
            propsSprite.AddAnimation("bone", new SpriteAnimation { FrameRate = 1, FrameCount = 1, Size = new Rectangle(0, 0, 29, 16), StartRow = 95, StartCol = 0 });
            propsSprite.AddAnimation("boots", new SpriteAnimation { FrameRate = 1, FrameCount = 1, Size = new Rectangle(0, 0, 33, 33), StartRow = 50, StartCol = 218 });
            propsSprite.AddAnimation("bucket", new SpriteAnimation { FrameRate = 1, FrameCount = 1, Size = new Rectangle(0, 0, 30, 34), StartRow = 83, StartCol = 218 });
            propsSprite.AddAnimation("chest1", new SpriteAnimation { FrameRate = 1, FrameCount = 1, Size = new Rectangle(0, 0, 52, 95), StartRow = 0, StartCol = 0 });
            propsSprite.AddAnimation("pillar", new SpriteAnimation { FrameRate = 1, FrameCount = 1, Size = new Rectangle(0, 0, 62, 63), StartRow = 0, StartCol = 99 });
            propsSprite.AddAnimation("skull", new SpriteAnimation { FrameRate = 1, FrameCount = 1, Size = new Rectangle(0, 0, 30, 28), StartRow = 87, StartCol = 52 });
            propsSprite.AddAnimation("stool", new SpriteAnimation { FrameRate = 1, FrameCount = 1, Size = new Rectangle(0, 0, 37, 36), StartRow = 50, StartCol = 181 });

            // bottom left room props
            ImageLayers.Add(propsSprite.Clone("bed2", 50, 550, 550));
            ImageLayers.Add(propsSprite.Clone("bed1-r", 145, 700, 150));
            ImageLayers.Add(propsSprite.Clone("bucket", 60, 700, 60));
            ImageLayers.Add(propsSprite.Clone("stool", 175, 640, 60));

            // bottom middle room props
            ImageLayers.Add(propsSprite.Clone("bed2", 260, 550, 550));
            ImageLayers.Add(propsSprite.Clone("bed2", 440, 550, 550));
            ImageLayers.Add(propsSprite.Clone("bucket", 270, 700, 270));
            ImageLayers.Add(propsSprite.Clone("boots", 450, 640, 270));

            // bottom right room props
            ImageLayers.Add(propsSprite.Clone("bed2", 510, 550, 550));
            ImageLayers.Add(propsSprite.Clone("bed1-r", 515, 700, 150));
            ImageLayers.Add(propsSprite.Clone("skull", 665, 710, 60));
            ImageLayers.Add(propsSprite.Clone("bucket", 655, 660, 60));

            // top left room props
            ImageLayers.Add(propsSprite.Clone("bed2", 50, 100, 100));
            ImageLayers.Add(propsSprite.Clone("bed1-r", 50, 300, 150));
            ImageLayers.Add(propsSprite.Clone("bucket", 200, 100, 150));

            // top middle room props
            ImageLayers.Add(propsSprite.Clone("bed2", 260, 100, 100));
            ImageLayers.Add(propsSprite.Clone("bed2", 440, 100, 100));
            ImageLayers.Add(propsSprite.Clone("bucket", 270, 250, 270));
            ImageLayers.Add(propsSprite.Clone("boots", 450, 190, 190));

            // top right room props
            ImageLayers.Add(propsSprite.Clone("barrel1", 650, 100, 100));
            ImageLayers.Add(propsSprite.Clone("bed1", 515, 100, 100));

            // outside the cells
            ImageLayers.Add(propsSprite.Clone("chest1", 50, 380, 50));

            Characters.Add("guard", Avatar.GenerateAvatar(game, null, "enemy"));

            if (data.Length == 0) data = new byte[1];

            if (data[0] == 0x00)
            {
                Characters["guard"].Location.X = 150;
                Characters["guard"].Location.Y = 440;
            } else
            {
                Characters["guard"].Location.X = 97;
                Characters["guard"].Location.Y = 440;
                Characters["guard"].UpdateVelocity(1, 0);
                Characters["guard"].UpdateVelocity(0, 0);

                _guardMoved = true;
            }

            Characters["guard"].Interact = TalkToGuard;
        }
Example #53
0
 public BackgroundLayer(Scene scene, Torch.Object parent, string image)
     : base(scene, parent)
 {
     Components.Add(new ImageObject(Game, this, image));
 }
Example #54
0
	public void removeTorch(Torch torch) {
		torches.Remove (torch);
		Debug.Log ("Removing torch:" + torch.torchValue);
	}
Example #55
0
	public void addTorch(Torch torch) {
		torches.Add (torch);
		Debug.Log ("Adding torch:" + torch.torchValue);
	}
Example #56
0
 public SpriteObject(Microsoft.Xna.Framework.Game game, Torch.Object parent, string image)
     : base(game, parent, image)
 {
 }
Example #57
0
 public Environment(Torch.Scene scene, Torch.Object parent)
     : base(scene, parent)
 {
 }
Example #58
0
 public HUD(Torch.Scene scene, Torch.Object parent)
     : base(scene, parent)
 {
     _interactIcon = new ImageObject(Game, this, "HUD/interacticon");
 }
Example #59
0
 public TextureObject(Microsoft.Xna.Framework.Game game, Torch.Object parent)
     : base(game, parent)
 {
     _texture = new Texture2D(GraphicsDevice, 1, 1);
 }
Example #60
0
        /// <summary>
        /// Adds a torch to the maze from the given position in the given direction
        /// </summary>
        public void AddTorch(Vector2 fromPosition, int dir)
        {
            // Get the position in relation to the maze
                Vector2 fromTilePosition = (fromPosition - position) / GameVariables.TileSize;
                fromTilePosition = new Vector2((int)fromTilePosition.X, (int)fromTilePosition.Y);

            // Check if wall at current position and if not move in the given direction
                if (tiles[(int)fromTilePosition.X][(int)fromTilePosition.Y])
                {
                    // Change the position depending on the direction
                        if (dir == 0)
                            fromTilePosition.Y--;
                        else if (dir == 1)
                            fromTilePosition.X--;
                        else if (dir == 2)
                            fromTilePosition.X++;
                        else if (dir == 3)
                            fromTilePosition.Y++;
                }

            // Create a torch with the position and add it to the torch list and movables list
                Torch torch = new Torch(fromTilePosition* GameVariables.TileSize+position);
                Moveables.Add(torch);
                torches.Add(torch);
        }