Beispiel #1
0
        protected override void TextParagraph(JobHandle job, pointf p, ref textpara_t text)
        {
            TextBlock block = new TextBlock();

            block.Inlines.Add(text.Text);
            block.FontFamily = new FontFamily(text.FontName);
            block.FontSize   = text.fontsize;
            block.Margin     = new Thickness(p.x - text.width / 2, p.y - text.yoffset_centerline - text.height / 2, 0, 0);
            block.Height     = text.height;
            block.Width      = text.width;
            block.Foreground = GetForegroundBrush(job);
            block.Background = GetBackgroundBrush(job, false);

            switch ((char)text.just)
            {
            case 'l':
                block.TextAlignment = TextAlignment.Left;
                break;

            case 'n':
                block.TextAlignment = TextAlignment.Center;
                break;

            case 'r':
                block.TextAlignment = TextAlignment.Right;
                break;
            }

            _canvas.Children.Add(block);
        }
Beispiel #2
0
    MapTile[] getTileNeighbours(pointf pos, bool diag = false)
    {
        MapTile[] neighbours;

        if (diag)
        {
            neighbours = new MapTile[8];
        }
        else
        {
            neighbours = new MapTile[4];
        }

        if (diag)
        {
            neighbours[4] = getTile(pos.X + 1f, pos.Y - 1f);          // TOP-LEFT
            neighbours[5] = getTile(pos.X + 1f, pos.Y + 1f);          // TOP-RIGHT
            neighbours[6] = getTile(pos.X - 1f, pos.Y - 1f);          // DOWN-LEFT
            neighbours[7] = getTile(pos.X + 1f, pos.Y - 1f);          // DOWN-RIGHT
        }

        neighbours[0] = getTile(pos.X + 1f, pos.Y);        // UP
        neighbours[1] = getTile(pos.X - 1f, pos.Y);        // DOWN
        neighbours[2] = getTile(pos.X, pos.Y + 1f);        // RIGHT
        neighbours[3] = getTile(pos.X, pos.Y - 1f);        // LEFT

        return(neighbours);
    }
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey("w") || Input.GetKey("up"))
        {
            pc.Player.setAcceleration(new pointf(0, pc.Player.Speed));
            ui.Canvas.SetActive(false);
        }
        if (Input.GetKey("s") || Input.GetKey("down"))
        {
            pc.Player.setAcceleration(new pointf(0, -pc.Player.Speed));
            ui.Canvas.SetActive(false);
        }
        if (Input.GetKey("d") || Input.GetKey("right"))
        {
            pc.Player.setAcceleration(new pointf(pc.Player.Speed, 0));
            ui.Canvas.SetActive(false);
        }
        if (Input.GetKey("a") || Input.GetKey("left"))
        {
            pc.Player.setAcceleration(new pointf(-pc.Player.Speed, 0));
            ui.Canvas.SetActive(false);
        }


        if (Input.GetKeyDown("i"))
        {
            if (ui.Canvas.activeInHierarchy)
            {
                ui.Canvas.SetActive(false);
            }
            else
            {
                pointf pos     = pc.Player.getPosition();
                bool   matches = false;
                foreach (Character npc in npcs.Character)
                {
                    //Debug.Log("Test Player: "+pos.X+"|"+pos.Y);
                    // Test if th player is touching any NPC's
                    if (pos == npc.getPosition())
                    {
                        if (npc.Interactable == true)
                        {
                            ui.Canvas.SetActive(true);



                            ui.setText(npc.Talk + "\n" + TextGen.ramble());
                            matches = true;
                        }
                    }
                }
                if (matches == false)
                {
                    ui.Canvas.SetActive(false);
                }
            }
        }
    }
Beispiel #4
0
 // Update is called once per frame
 void Update()
 {
     if (player != null)
     {
         pointf pos = Player.getPosition();
         pgo.transform.position         = new Vector3(pos.X, pos.Y, 0);
         Camera.main.transform.position = new Vector3(pos.X, pos.Y, Camera.main.transform.position.z);
     }
 }
Beispiel #5
0
 public WpfDeviceEngine()
     : base("wpf:wpf")
 {
     unsafe
     {
         Features->flags            = DeviceFeatures.DoesTrueColor;
         Features->default_margin   = new pointf(0, 0);
         Features->default_pagesize = new pointf(612, 792);
         Features->default_dpi      = new pointf(72, 72);
     }
 }
Beispiel #6
0
 // Update is called once per frame
 void Update()
 {
     for (int i = 0; i < npc.Length; i++)
     {
         if (npc[i] != null)
         {
             pointf pos = npc[i].getPosition();
             pgo[i].transform.position = new Vector3(pos.X, pos.Y, 0);
             pgo[i].name = "NPC" + i;
             //Debug.Log("Displaying NPC: "+i+" Pos:"+pos.X+":"+pos.Y);
         }
     }
 }
Beispiel #7
0
        protected override void Ellipse(JobHandle job, pointf[] ps, bool filled)
        {
            pointf center = ps[0];
            pointf corner = ps[1];

            Ellipse ellipse = new Ellipse();

            ellipse.Width  = 2 * (corner.x - center.x);
            ellipse.Height = 2 * (center.y - corner.y);
            ellipse.Margin = new Thickness(2 * center.x - corner.x, corner.y, 0, 0);

            ApplyShapeStyle(ellipse, job, filled);

            _canvas.Children.Add(ellipse);
        }
Beispiel #8
0
        public DeviceEngine(string type)
        {
            this._initialize = Initialize;
            this._format     = Format;
            this._finalize   = Finalize;

            unsafe
            {
                gvdevice_engine_t *deviceEngine = (gvdevice_engine_t *)Marshal.AllocHGlobal(Marshal.SizeOf(typeof(gvdevice_engine_t)));
                _deviceEngine = new SafeMarshalHGlobalHandle((IntPtr)deviceEngine, true);

                *deviceEngine = new gvdevice_engine_t();
                deviceEngine->initialize = Marshal.GetFunctionPointerForDelegate(_initialize);
                deviceEngine->format     = Marshal.GetFunctionPointerForDelegate(_format);
                deviceEngine->finalize   = Marshal.GetFunctionPointerForDelegate(_finalize);

                gvdevice_features_t *deviceFeatures = (gvdevice_features_t *)Marshal.AllocHGlobal(Marshal.SizeOf(typeof(gvdevice_features_t)));
                _deviceFeatures = new SafeMarshalHGlobalHandle((IntPtr)deviceFeatures, true);

                *deviceFeatures = new gvdevice_features_t();
                deviceFeatures->flags            = DeviceFeatures.None;
                deviceFeatures->default_margin   = new pointf(36, 36);
                deviceFeatures->default_pagesize = new pointf(612, 792);
                deviceFeatures->default_dpi      = new pointf(72, 72);

                gvplugin_installed_t *installedPluginData = (gvplugin_installed_t *)Marshal.AllocHGlobal(2 * Marshal.SizeOf(typeof(gvplugin_installed_t)));
                _installedPluginData = new SafeMarshalHGlobalHandle((IntPtr)installedPluginData, true);
                _engineType          = new SafeMarshalHGlobalHandle(Marshal.StringToHGlobalAnsi(type), true);

                installedPluginData->id       = 0;
                installedPluginData->type     = (byte *)_engineType.DangerousGetHandle();
                installedPluginData->quality  = 0;
                installedPluginData->engine   = deviceEngine;
                installedPluginData->features = deviceFeatures;
                installedPluginData[1]        = new gvplugin_installed_t();
            }
        }
Beispiel #9
0
 public MapTile(float x, float y, TileType t = TileType.GRASS, bool collide = false)
 {
     pos        = new pointf(x, y);
     type       = t;
     collidable = collide;
 }
Beispiel #10
0
 protected virtual void TextParagraph(JobHandle job, pointf p, ref textpara_t text)
 {
 }
Beispiel #11
0
 public MapTile getTile(pointf coords)
 {
     // should add a check to make sure a tile exists at this location, else reurn null
     return(map[(int)coords.X, (int)coords.Y]);
 }
Beispiel #12
0
 public void moveCharacter(float delta)
 {
     pos = pos + (acceleration * delta);
 }
Beispiel #13
0
 public void setAcceleration(pointf a)
 {
     acceleration = a;
 }
Beispiel #14
0
 public void setPosition(float x, float y)
 {
     pos = new pointf(x, y);
 }