Daily Archives

Articles indexed Sunday March 18 2012

Page 20/21 | < Previous Page | 16 17 18 19 20 21  | Next Page >

  • Efficient solution for multiplayer space partioning?

    - by DevilWithin
    This question is a little tricky, but I will try to make it clear, Lets say I am building an online game, not in a mmo scale, but gladly supporting as many players as possible, in a authoritative server approach, and I want really big worlds with lots of AI simulated enemies. I am aware of a few strategies to save server's CPU by subdividing the space and not processing what doesn't need processing. I 've already split the world by regions, that will require loading times and small transitions, which i think is important to mantain the quality of gameplay when playing locally (alone or even with a couple of friends) because the players won't normally be in more than one or two regions. But even a region can become pretty big, and have a lot of NPC simulating at a time, how do I handle this without screwing the player's experience? Approaches like one server per region and alike are not in the table. I am mainly looking for data structures to hold hordes of enemies, and even peaceful NPC. To finalize the question, please note that vehicles exist, therefore its considerably fast to travel within a region, influencing the "when" to cull areas. Sorry for the confusing question, thanks

    Read the article

  • How should game objects with fixed positions in the world be positioned?

    - by mars
    I have some game objects that are always at the same position in my game world as they make up some of the scenery of my puzzle game. At the moment, their positions are sort of hard coded in and some of their positions are calculated relative to the hard coded positions of other objects at the time of game initialization. This has been hard to maintain because whenever I've decided to change the position of these scenery objects as the game design evolved, I have to go and rewrite parts of the code that place the created objects and calculate their positions in the world. Is there a more maintainable way of handling the positioning of fixed game objects?

    Read the article

  • How to add event receiver to SharePoint2010 content type programmatically

    - by ybbest
    Today , I’d like to show how to add event receiver to How to add event receiver to SharePoint2010 content type programmatically. 1. Create empty SharePoint Project and add a class called ItemContentTypeEventReceiver and make it inherit from SPItemEventReceiver and implement your logic as below public class ItemContentTypeEventReceiver : SPItemEventReceiver { private bool eventFiringEnabledStatus; public override void ItemAdded(SPItemEventProperties properties) { base.ItemAdded(properties); UpdateTitle(properties); } private void UpdateTitle(SPItemEventProperties properties) { SPListItem addedItem = properties.ListItem; string enteredTitle = addedItem["Title"] as string; addedItem["Title"] = enteredTitle + " Updated"; DisableItemEventsScope(); addedItem.Update(); EnableItemEventsScope(); } public override void ItemUpdated(SPItemEventProperties properties) { base.ItemUpdated(properties); UpdateTitle(properties); } private void DisableItemEventsScope() { eventFiringEnabledStatus = EventFiringEnabled; EventFiringEnabled = false; } private void EnableItemEventsScope() { eventFiringEnabledStatus = EventFiringEnabled; EventFiringEnabled = true; } } 2.Create a Site or Web(depending or your requirements) scoped feature and implement your feature event handler as below: public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPWeb web = GetFeatureWeb(properties); //http://karinebosch.wordpress.com/walkthroughs/event-receivers-theory/ string assemblyName =  System.Reflection.Assembly.GetExecutingAssembly().FullName; const string className = "YBBEST.AddEventReceiverToContentType.ItemContentTypeEventReceiver"; SPContentType contentType= web.ContentTypes["Item"]; AddEventReceiverToContentType(className, contentType, assemblyName, SPEventReceiverType.ItemAdded, SPEventReceiverSynchronization.Asynchronous); AddEventReceiverToContentType(className, contentType, assemblyName, SPEventReceiverType.ItemUpdated, SPEventReceiverSynchronization.Asynchronous); contentType.Update(); } protected static void AddEventReceiverToContentType(string className, SPContentType contentType, string assemblyName, SPEventReceiverType eventReceiverType, SPEventReceiverSynchronization eventReceiverSynchronization) { if (className == null) throw new ArgumentNullException("className"); if (contentType == null) throw new ArgumentNullException("contentType"); if (assemblyName == null) throw new ArgumentNullException("assemblyName"); SPEventReceiverDefinition eventReceiver = contentType.EventReceivers.Add(); eventReceiver.Synchronization = eventReceiverSynchronization; eventReceiver.Type = eventReceiverType; eventReceiver.Assembly = assemblyName; eventReceiver.Class = className; eventReceiver.Update(); } 3.Deploy your solution and now you have a event receiver that attached to the Item contentType. You can download the complete source code here.You can also check how to add event receiver to a list using SharePoint event receiver item in Visual Studio2010 in my previous blog.

    Read the article

  • How to create a folder in SharePoint2010 root folder and set permission to it

    - by ybbest
    If you need to create a folder in SharePoint2010 root folder and set permission to it, here is piece of code that does it. In the script, I have created a folder called Temp in Logs folder under SharePoint2010 root and then I grant read/write access to the Windows group WSS_WPG and full access to the group WSS_ADMIN_WPG for that folder. $Folder=New-Item "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\LOGS\temp" -Type Directory -force $acl = Get-Acl $Folder ##The following line has been commented out , if you like to break the permission inheritance from the parent floder , uncommented the code. #$acl.SetAccessRuleProtection($True, $False) $rule = New-Object System.Security.AccessControl.FileSystemAccessRule("WSS_ADMIN_WPG","FullControl", "ContainerInherit, ObjectInherit", "None", "Allow") $acl.AddAccessRule($rule) $rule = New-Object System.Security.AccessControl.FileSystemAccessRule("WSS_WPG","Modify", "ContainerInherit, ObjectInherit", "None", "Allow") $acl.AddAccessRule($rule) Set-Acl $Folder $acl References: http://technet.microsoft.com/en-us/library/ff730951.aspx http://msdn.microsoft.com/en-us/library/tbsb79h3.aspx http://blogs.technet.com/b/josebda/archive/2010/11/12/how-to-handle-ntfs-folder-permissions-security-descriptors-and-acls-in-powershell.aspx http://chrisfederico.wordpress.com/2008/02/01/setting-acl-on-a-file-or-directory-in-powershell/

    Read the article

  • How to create item in SharePoint2010 document library using SharePoint Web service

    - by ybbest
    Today, I’d like to show you how to create item in SharePoint2010 document library using SharePoint Web service. Originally, I thought I could use the WebSvcLists(list.asmx) that provides methods for working with lists and list data. However, after a bit Googling , I realize that I need to use the WebSvcCopy (copy.asmx).Here are the code used private const string siteUrl = "http://ybbest"; private static void Main(string[] args) { using (CopyWSProxyWrapper copyWSProxyWrapper = new CopyWSProxyWrapper(siteUrl)) { copyWSProxyWrapper.UploadFile("TestDoc2.pdf", new[] {string.Format("{0}/Shared Documents/TestDoc2.pdf", siteUrl)}, Resource.TestDoc, GetFieldInfos().ToArray()); } } private static List<FieldInformation> GetFieldInfos() { var fieldInfos = new List<FieldInformation>(); //The InternalName , DisplayName and FieldType are both required to make it work fieldInfos.Add(new FieldInformation { InternalName = "Title", Value = "TestDoc2.pdf", DisplayName = "Title", Type = FieldType.Text }); return fieldInfos; } Here is the code for the proxy wrapper. public class CopyWSProxyWrapper : IDisposable { private readonly string siteUrl; public CopyWSProxyWrapper(string siteUrl) { this.siteUrl = siteUrl; } private readonly CopySoapClient proxy = new CopySoapClient(); public void UploadFile(string testdoc2Pdf, string[] destinationUrls, byte[] testDoc, FieldInformation[] fieldInformations) { using (CopySoapClient proxy = new CopySoapClient()) { proxy.Endpoint.Address = new EndpointAddress(String.Format("{0}/_vti_bin/copy.asmx", siteUrl)); proxy.ClientCredentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials; proxy.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation; CopyResult[] copyResults = null; try { proxy.CopyIntoItems(testdoc2Pdf, destinationUrls, fieldInformations, testDoc, out copyResults); } catch (Exception e) { System.Console.WriteLine(e); } if (copyResults != null) System.Console.WriteLine(copyResults[0].ErrorMessage); System.Console.ReadLine(); } } public void Dispose() { proxy.Close(); } } You can download the source code here . ******Update********** It seems to be a bug that , you can not set the contentType when create a document item using Copy.asmx. In sp2007 the field type was Choice, however, in sp2010 it is actually Computed. I have tried using the Computed field type with no luck. I have also tried sending the ContentTypeId and this does not work.You might have to write your own web services to handle this.You can check my previous blog on how to get started with you own custom WCF in SP2010 here. References: SharePoint 2010 Web Services SharePoint2007 Web Services SharePoint MSDN Forum

    Read the article

  • How to fix “Cannot connect to the configuration database.”

    - by ybbest
    The problem: When I browse to a SharePoint site, I got the Server Error in ‘/’ Application, Cannot connect to the configuration database. The Analysis: The reason you get the message is that SharePoint WFE cannot connect to the SQL database, you need to check the weather SQL server service is started as shown below. Solution: When checking the SQL Server service, I see it is not started. After starting the service, it works like a charm.

    Read the article

  • Customize SharePoint list using InfoPath2010 form Part4

    - by ybbest
    Customize SharePoint list using InfoPath2010 form Part1 Customize SharePoint list using InfoPath2010 form Part2 Customize SharePoint list using InfoPath2010 form Part3 In this post, I’d like to show you how to create print functionality in InfoPath for SharePoint list. The print functionality is provided out of box in InfoPath form library; however it is not available in SharePoint list. Here are the steps to create the print functionality.You can download the new form here. 1. Create print page in the list by first copy and paste the displayifs.aspx and rename the file to Printifs.aspx. 2. Open the page in the SharePoint designer and copy the following javascript to the PlaceHolderTitleAreaClass ContentPlaceHolder. <script type="text/javascript"> $(document).ready(function(){ $("[id^='Ribbon']").hide(); $(".s4-title").hide(); $("[id='s4-leftpanel']").hide(); $("[id='s4-ribbonrow']").hide(); $("[id='s4-titlerow']").hide(); $("[id='s4-titlerow']").css("height", "0px"); $("body").css("background-color", "white"); $("body").css("zoom", "135%"); $("[id='MSO_ContentTable']").css("margin-left", "0px"); $("[id='MT-BodyContent']").css("width", "900px"); $(".MT-BodyArea").css("width", "900px"); $("[id='MT-Layout']").css("width", "900px"); $(".ms-bodyareacell").css("width", "900px"); $(".s4-wpTopTable").css("border", "none"); $("[id$='XmlFormView']").css("margin-left", "-80px"); $("body").css("margin-top", "-30px"); $(":contains('CAPEX')").css("border", "5px solid #FFCC00"); window.print(); }); </script> 3. Open InfoPath form for the list and create a field called PrintLink 4. Set the default value of printLink that points to the print page I just created before with the query string id.You can download the formula for the default value here. 5. Add a new image that looks like Print button on the display view, then I can set the url to the Print link Field. (The reason I did not use button is that you cannot set the navigate url for the button). 6.Set the url of the image to the PrintLInk field. 7.Next , create the print view. 8. Copy the contents from the display view to print view 9. Finally, go to the printifs.aspx and edit the InfoPath web part to set the view to PrintView. 9. Republish you form you will see the form as shown below 10. If you click the Print button, you will see the print page and print dialog,you can also add the company logo in the print page using css as well. 11.To deploy the customization,you can use the backup and restore content database approach , you can get more details from my previous blog post here.

    Read the article

  • Create simple jQuery plugin

    - by ybbest
    In the last post, I have shown you how to add the function to jQuery. In this post, I will show you how to create plugin to achieve this. 1. You need to wrap your code in the following construct, this is because you should not use $ directly as $ is global variable, it could have clash with some other library which also use $.Basically, you can pass in jQuery object into the function, so that $ is made available inside the function. (JavaScript use function to create scope, so you can make sure $ is referred to jQuery inside the function ) (function($){ //Your code goes here. }; })(jQuery); 2. Put your code into the construct above. (function ($) { $.getParameterByName = function (name) { name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); var regexS = "[\\?&]" + name + "=([^&#]*)"; var regex = new RegExp(regexS); var results = regex.exec(window.location.search); if (results == null) return ""; else return decodeURIComponent(results[1].replace(/\+/g, " ")); }; })(jQuery); 3. Now you can reference the code into you project and you can call the method in you JavaScript References: Provides scope for variables Variables are scoped at the function level in javascript. This is different to what you might be used to in a language like C# or Java where the variables are scoped to the block. What this means is if you declare a variable inside a loop or an if statement, it will be available to the entire function. If you ever find yourself needing to explicitly scope a variable inside a function you can use an anonymous function to do this. You can actually create an anonymous function and then execute it straight away and all the variables inside will be scoped to the anonymous function: (function() { var myProperty = "hello world"; alert(myProperty); })(); alert(typeof(myProperty)); // undefined How does an anonymous function in JavaScript work? Building Your First jQuery Plugin A Plugin Development Pattern

    Read the article

  • How to retrieve the value of querystring from url using Javascript

    - by ybbest
    The following is a Javascript function I found on the internet , I keep here just in case I need to use it again. function getParameterByName(name) { name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); var regexS = "[\\?&]" + name + "=([^&#]*)"; var regex = new RegExp(regexS); var results = regex.exec(window.location.search); if(results == null) return ""; else return decodeURIComponent(results[1].replace(/\+/g, " ")); } You can also add this method to jquery as below. $.getParameterByName = function (name) { name = name.replace( /[\[]/ , "\\\[").replace( /[\]]/ , "\\\]"); var regexS = "[\\?&]" + name + "=([^&#]*)"; var regex = new RegExp(regexS); var results = regex.exec(window.location.search); if (results == null) return ""; else return decodeURIComponent(results[1].replace( /\+/g , " ")); }; $(document).ready(function () { alert($.getParameterByName("id")); }); References: http://stackoverflow.com/questions/901115/get-query-string-values-in-javascript http://blog.jeremymartin.name/2008/02/building-your-first-jquery-plugin-that.html http://stackoverflow.com/questions/7541218/writing-jquery-static-util-methods http://api.jquery.com/category/utilities/

    Read the article

  • How to find out which process actually locks your dll when SharePoint Solution deployment failed

    - by ybbest
    When your SharePoint Solution package include third party or external dlls , you will often see your solution fail to deploy due to the locking of the dlls. Today I will show you how to find which process locks your dlls using Process Explorer. 1. Here is an example that your solution fails to deploy due to dll being locked. 2. Start the explorer by double click the procexp.exe 3. From the find tab click Find Handle or DLL 4.Type the your dll name and click Search 5. I can see all the processes that use my dlls at the moment, it looks like the iis , visual studio and SharePoint timer services might be the trouble. From my experience , it could be Visual studio. 6. Close visual studio and redeploy my solution, it works like charm. Re-search the dll, you can see Visual studio is not in the results.

    Read the article

< Previous Page | 16 17 18 19 20 21  | Next Page >