Jump to content
  • Advertisement

Search the Community

Showing results for tags 'C#'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Categories

  • Audio
    • Music and Sound FX
  • Business
    • Business and Law
    • Career Development
    • Production and Management
  • Game Design
    • Game Design and Theory
    • Writing for Games
    • UX for Games
  • Industry
    • Interviews
    • Event Coverage
  • Programming
    • Artificial Intelligence
    • General and Gameplay Programming
    • Graphics and GPU Programming
    • Engines and Middleware
    • Math and Physics
    • Networking and Multiplayer
  • Visual Arts
  • Archive

Categories

  • Audio
  • Visual Arts
  • Programming
  • Writing

Categories

  • Game Dev Loadout
  • Game Dev Unchained

Categories

  • Game Developers Conference
    • GDC 2017
    • GDC 2018
  • Power-Up Digital Games Conference
    • PDGC I: Words of Wisdom
    • PDGC II: The Devs Strike Back
    • PDGC III: Syntax Error

Forums

  • Audio
    • Music and Sound FX
  • Business
    • Games Career Development
    • Production and Management
    • Games Business and Law
  • Game Design
    • Game Design and Theory
    • Writing for Games
  • Programming
    • Artificial Intelligence
    • Engines and Middleware
    • General and Gameplay Programming
    • Graphics and GPU Programming
    • Math and Physics
    • Networking and Multiplayer
  • Visual Arts
    • 2D and 3D Art
    • Critique and Feedback
  • Community
    • GameDev Challenges
    • GDNet+ Member Forum
    • GDNet Lounge
    • GDNet Comments, Suggestions, and Ideas
    • Coding Horrors
    • Your Announcements
    • Hobby Project Classifieds
    • Indie Showcase
    • Article Writing
  • Affiliates
    • NeHe Productions
    • AngelCode
  • Topical
    • Virtual and Augmented Reality
    • News
  • Workshops
    • C# Workshop
    • CPP Workshop
    • Freehand Drawing Workshop
    • Hands-On Interactive Game Development
    • SICP Workshop
    • XNA 4.0 Workshop
  • Archive
    • Topical
    • Affiliates
    • Contests
    • Technical
  • GameDev Challenges's Topics
  • For Beginners's Forum

Calendars

  • Community Calendar
  • Games Industry Events
  • Game Jams
  • GameDev Challenges's Schedule

Blogs

There are no results to display.

There are no results to display.

Product Groups

  • Advertisements
  • GameDev Gear

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


About Me


Website


Role


Twitter


Github


Twitch


Steam

Found 439 results

  1. Unity is a cross-platform game engine developed by Unity Technologies, first announced and released in June 2005 at Apple Inc.'s Worldwide Developers Conference as an OS X-exclusive game engine. As of 2018, the engine has been extended to support 27 platforms. I have started a video tutorial on A Complete Game Development course using Unity3d on YouTube. It is completely a beginner to advance course so any on can visit and learn to code and design game from beginning. Course will be updated daily. Visit here for more information. https://www.youtube.com/channel/UCJjDIEeBxUT8VxBVnMXHkDQ
  2. Brizzler

    UWP Indie Game Review

    Hey Everyone, I'd like to review some of your indies games! I'm interested in games made for the Universal Windows Platform (UWP). Reply to this post if your interested in having your games reviewed and youtubed on my channel: UWPdeveloper Cheers, B
  3. Hi there, So i'm an inexperienced student learning games dev at college and im studying c#, in my spare time im trying to work on a text adventure game with a narrative. My issue is that i dont know how to make the decisions, well not simply anyhow. I could write out 50 variables for each decision to read from the player but that would become very tedious and too messy to even comprehend when im adding content. I was thinking of adding functions to hold each decision or area but im at a lack of knowledge on how to jump to a function or if it's even a good solution. I know i could use an array and each decision be a number but that just doesn't seem like a good solution to me either. Any advice would be appreciated and this whole topic might sound dumb to a professional so be understanding please haha. Thanks, Luke
  4. Okay, looking for some constructive feedback/criticism here... What follows is the code of my c# UDP Socket Class. I've written this based on a number of online examples and a few distant memories from the past, so I really have no idea how "bad" the code is/could be in a 100+ concurrent connection scenario(my dev environment is just two machines at the moment)... It works, I know that, it is fairly stable(I can't break it when using it normally), and it behaves how I believe I want it to. It is a dual purpose class for handling both Servers and Clients. It uses an asynchronous receive and synchronous send(I may switch to async send if it proves beneficial later on). My servers use Client sockets to communicate with each other and to perform internal connection tests in a multiple server, "single shard" type environment. I'll be devising some heavy load testing methods a little further down the line, but I'm hoping to fish out most of the major gotchas before I get there. So, please, let me know how to fix it up if it smells terribly to you, or if not, that's even better... Sorry for the large code dump, but THANKS for checking it out! using System; using System.Collections.Generic; using System.Net; using System.Net.Sockets; using System.Text; using UWAvatarServerData; namespace UWAvatarServer { public class UDPSocket : IDisposable { //Some simple string length counters and averages to get a rough idea of generated traffic. public int sndMax = 0; public MovingAverage sndAvg = new MovingAverage(); public int csndMax = 0; public MovingAverage csndAvg = new MovingAverage(); public int rcvMax = 0; public MovingAverage rcvAvg = new MovingAverage(); //Constant for configuring the prevention of ICMP connection resets private const int SIO_UDP_CONNRESET = -1744830452; //UDP socket private Socket _socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); //Buffer Size Constant private const int bufSize = 8 * 1024; //Raw string data from client packets private Dictionary<EndPoint, Queue<string>> messageDictionary; //Queue for holding raw string data from server packets when in client mode. private Queue<string> cQ; //Referece to the data store used by the server(for access to the current game time clock) private UWDataStore dataStore; //Time code storage for last sent/received messages private double lastSentMessage = 0; private double lastReceivedMessage = 0; //Boolean to determine which mode we're in so received messages get put in the right place. private bool clientMode = false; //Max string lenght allowed by the servers. private int maxMessageLength = 1450; //IDisposable stuff public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } protected virtual void Dispose(bool disposing) { if (disposing) { // free managed resources if (_socket != null) { _socket.Dispose(); _socket = null; } } } //State class for async receive. public class State { public byte[] buffer = new byte[bufSize]; public EndPoint epFrom = new IPEndPoint(IPAddress.Any, 0); } //Server "Mode" public UDPSocket(Dictionary<EndPoint, Queue<string>> msgsDict, UWDataStore DATASTORE) { clientMode = false; messageDictionary = msgsDict; dataStore = DATASTORE; lastSentMessage = dataStore.UWServerSeconds; } //Client "Mode" public UDPSocket(Queue<string> mq, UWDataStore DATASTORE) { clientMode = true; cQ = mq; dataStore = DATASTORE; lastSentMessage = dataStore.UWServerSeconds; } public void CloseSocket() { _socket.Close(); } //Internal connection status checking public int SendHowStale() { if (lastSentMessage == 0) lastSentMessage = dataStore.UWServerSeconds; return (int)(dataStore.UWServerSeconds - lastSentMessage); } //Internal connection status checking public int ReceiveHowStale() { if (lastReceivedMessage == 0) lastReceivedMessage = dataStore.UWServerSeconds; return (int)(dataStore.UWServerSeconds - lastReceivedMessage); } //Start/Bind a Server. public void Server(string address, int port) { //In case restarting uncleanly, dunno if this actually does anything.. _socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.ReuseAddress, true); //Ensure all async packets contain endpoint info and etc. _socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.PacketInformation, true); //Ignore ICMP port unreachable exceptions. _socket.IOControl((IOControlCode)SIO_UDP_CONNRESET, new byte[] { 0, 0, 0, 0 }, null); //Bind to port. if (address == "all") { _socket.Bind(new IPEndPoint(IPAddress.Any, port)); } else { _socket.Bind(new IPEndPoint(IPAddress.Parse(address), port)); } //Start receive callback process. Receive(); } //Setup a Client to Server socket. public void Client(string address, int port) { //Dunno if these two options do anything for client sockets, but they don't seem to break anything. _socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.PacketInformation, true); _socket.IOControl((IOControlCode)SIO_UDP_CONNRESET, new byte[] { 0, 0, 0, 0 }, null); _socket.Connect(IPAddress.Parse(address), port); //Start receive callback. Receive(); } //ServerSend sends to any EndPoint from THIS server. public void ServerSend(string text, EndPoint ep) { try { byte[] data = Encoding.ASCII.GetBytes(text); _socket.SendTo(data, ep); lastSentMessage = dataStore.UWServerSeconds; if (text.Length > sndMax) sndMax = text.Length; sndAvg.ComputeAverage((float)text.Length); //Console.WriteLine("TO NET: " + text); } catch (Exception ex) { Console.WriteLine("ServerSend Exception: " + ex.Message); } } //Client Send only sends to the connected Server. public void cSend(string text) { try { byte[] data = Encoding.ASCII.GetBytes(text); _socket.Send(data); lastSentMessage = dataStore.UWServerSeconds; if (text.Length > sndMax) sndMax = text.Length; sndAvg.ComputeAverage((float)text.Length); //Console.WriteLine("TO NET: " + text); } catch (Exception ex) { Console.WriteLine("cSend Exception: " + ex.Message); } } //Setup Async Callback private void Receive() { try { State so = new State(); _socket.BeginReceiveFrom(so.buffer, 0, bufSize, SocketFlags.None, ref so.epFrom, new AsyncCallback(_Receive), so); } catch (Exception) { } } //Receive Callback private void _Receive(IAsyncResult ar) { try { State so = (State)ar.AsyncState; int bytes = _socket.EndReceiveFrom(ar, ref so.epFrom); lastReceivedMessage = dataStore.UWServerSeconds; string smessage = Encoding.ASCII.GetString(so.buffer, 0, bytes); //Console.WriteLine("FROM NET: " + text); if (smessage.Length < maxMessageLength) { if (smessage.Length > rcvMax) rcvMax = smessage.Length; rcvAvg.ComputeAverage((float)smessage.Length); if (clientMode) { cQ.Enqueue(smessage); } else { if (!messageDictionary.ContainsKey(so.epFrom)) { messageDictionary.Add(so.epFrom, new Queue<string> { }); } messageDictionary[so.epFrom].Enqueue(smessage); } } _socket.BeginReceiveFrom(so.buffer, 0, bufSize, SocketFlags.None, ref so.epFrom, new AsyncCallback(_Receive), so); } catch (Exception) { } } } } Generally speaking I use it as such: public static bool running = true; static void UDPServer() { using (s = new UDPSocket(MessageDictionary, UWDataStore)) { s.Server("all", 37373); while(running) { //Servery Stuff Goes Here. //Like reiteratively dequeuing the Message Dictionary Queues and processing/replying to all commands/etc... } } } All processing of individual messages from clients is handled with Task.Factory tasks, and a reference to the server's socket varible (s), and the client's EndPoint is sent along the ride for use in replying to clients. There's no game logic and there are no client replies that happen directly from within the UDP server's main while loop, mostly just connection status checking and reorganizing of the Message Queues into Tasks. Thanks again for making it this far.
  5. I'm creating a textbox for my UI, and I found a way to place the cursor where the user clicks on the text. Here is all of my code: using System; using System.Collections.Generic; using System.Timers; using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; namespace TextEditorTest { public class Cursor { public int CharacterIndex = 0; public string Symbol = "|"; public Vector2 Position = new Vector2(0, 0); public int LineIndex = 0; public bool Visible = true; } /// <summary> /// This is the main type for your game. /// </summary> public class Game1 : Game { GraphicsDeviceManager graphics; SpriteBatch spriteBatch; private GapBuffer<string> m_Text = new GapBuffer<string>(); //private List<Vector2> m_CharacterPositions = new List<Vector2>(); private Dictionary<int, Vector2> m_CharacterPositions = new Dictionary<int, Vector2>(); private List<Rectangle> m_HitBoxes = new List<Rectangle>(); private bool m_UpdateCharPositions = true; private const int NUM_CHARS_IN_LINE = 10; private Vector2 m_TextEditPosition = new Vector2(50, 0), m_TextEditSize = new Vector2(250, 320); private SpriteFont m_Font; private Timer m_CursorVisibilityTimer = new Timer(); private Cursor m_Cursor = new Cursor(); private InputHelper m_Input = new InputHelper(); private int m_NumLinesInText = 1; private bool m_HasFocus = true; private bool m_MultiLine = true; private bool m_CapitalLetters = false; //For how long has a key been presseed? private DateTime m_DownSince = DateTime.Now; private float m_TimeUntilRepInMillis = 100f; private int m_RepsPerSec = 15; private DateTime m_LastRep = DateTime.Now; private Keys? m_RepChar; //A character currently being pressed (repeated). private Vector2 m_TextPosition = new Vector2(0, 0); //Coordinate for anchoring the text. public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; m_Cursor.Position = m_TextEditPosition; m_CursorVisibilityTimer = new Timer(100); m_CursorVisibilityTimer.Enabled = true; m_CursorVisibilityTimer.Elapsed += CursorVisibilityTimer_Elapsed; m_CursorVisibilityTimer.Start(); IsMouseVisible = true; Window.TextInput += Window_TextInput; m_TextPosition = m_TextEditPosition; } private void CursorVisibilityTimer_Elapsed(object sender, ElapsedEventArgs e) { if (m_HasFocus) { if (m_Cursor.Visible) m_Cursor.Visible = false; else m_Cursor.Visible = true; } } /// <summary> /// The text in this TextEditor instance, containing "\n". /// </summary> private string TextWithLBreaks { get { string Text = ""; foreach (string Str in m_Text) Text += Str; return Text; } } /// <summary> /// Returns a line of text. /// </summary> /// <param name="LineIndex">The index of the line of text to get.</param> /// <returns>The line of text, as indicated by the line index.</returns> private string GetLine(int LineIndex) { try { if (TextWithLBreaks.Contains("\n")) return TextWithLBreaks.Split("\n".ToCharArray())[LineIndex]; } catch(Exception) { return ""; } return TextWithLBreaks; } /// <summary> /// Make sure cursor's index is valid and in range. /// </summary> private void FixCursorIndex() { if (m_Cursor.CharacterIndex < 0) m_Cursor.CharacterIndex = 0; if (m_Cursor.CharacterIndex == m_Text.Count) m_Cursor.CharacterIndex = m_Text.Count - 1; } /// <summary> /// Make sure cursor's position is valid and in range. /// </summary> private void FixCursorPosition() { if (m_Cursor.Position.X < m_TextEditPosition.X) m_Cursor.Position.X = m_TextEditPosition.X; m_UpdateCharPositions = true; UpdateCharacterPositions(); UpdateHitboxes(); //Find the curor's real character index. int RealCharIndex = m_Cursor.CharacterIndex; RealCharIndex = (RealCharIndex < m_CharacterPositions.Count) ? //Make sure it doesn't overflow. RealCharIndex : m_CharacterPositions.Count - 1; if (RealCharIndex < 0) RealCharIndex = 0; //Make sure it doesn't underflow. //Adjust the character's position based on the real character index. if (m_Text.Count > 0) { Vector2 IndexPosition = m_CharacterPositions[(RealCharIndex > 0) ? RealCharIndex : 0]; if (m_Cursor.Position.X < IndexPosition.X) m_Cursor.Position.X = IndexPosition.X; if (m_Cursor.Position.Y != IndexPosition.Y) m_Cursor.Position.Y = IndexPosition.Y; } } /// <summary> /// The text in this TextEditor instance, without \n /// (except for those explicitly added by pressing backspace). /// </summary> public string Text { get { string Text = ""; foreach (string Str in m_Text) Text += Str; return Text.Replace("\n", ""); } } /// <summary> /// Returns the width of a character in this font. /// </summary> /// <returns>The width of the character in floating point numbers.</returns> private float CharacterWidth { get { return m_Font.MeasureString("a").X; } } /// <summary> /// Returns the width of a capitalized character in this font. /// </summary> /// <returns>The width of the capitalized character in floating point numbers.</returns> private float CapitalCharacterWidth { get { return m_Font.MeasureString("A").X; } } /// <summary> /// Returns the height of a character in this font. /// </summary> /// <returns>The height of the character in floating point numbers.</returns> private float CharacterHeight { get { return m_Font.MeasureString("a").Y; } } /// <summary> /// Returns the height of a capitalized character in this font. /// </summary> /// <returns>The height of the capitalized character in floating point numbers.</returns> private float CapitalCharacterHeight { get { return m_Font.MeasureString("A").Y; } } /// <summary> /// Returns the last line of text in the gap buffer. /// </summary> /// <returns></returns> private string CurrentLine { get { if (m_Text.Count > 1) { if (TextWithLBreaks.Contains("\n")) { string[] Lines = TextWithLBreaks.Split("\n".ToCharArray()); return Lines[Lines.Length - 1]; } else return TextWithLBreaks; } if (m_Text.Count > 0) return m_Text[0]; else return ""; } } /// <summary> /// The control received text input. /// </summary> private void Window_TextInput(object sender, TextInputEventArgs e) { if (e.Character != (char)Keys.Back) { int Index = TextWithLBreaks.LastIndexOf("\n", m_Cursor.CharacterIndex); if (Index == -1) //No occurence was found!! { if (Text.Length <= NUM_CHARS_IN_LINE) { AddText((m_CapitalLetters == true) ? e.Character.ToString().ToUpper() : e.Character.ToString()); m_CapitalLetters = false; m_UpdateCharPositions = true; return; } else { if (m_MultiLine) { AddNewline(); return; } } } if ((m_Cursor.CharacterIndex - Index) <= NUM_CHARS_IN_LINE) { //If the cursor has moved away from the end of the text... if (m_Cursor.CharacterIndex < (m_Text.Count - (1 + m_NumLinesInText))) { //... insert it at the cursor's position. m_Text.Insert(m_Cursor.CharacterIndex, (m_CapitalLetters == true) ? e.Character.ToString().ToUpper() : e.Character.ToString()); m_CapitalLetters = false; m_UpdateCharPositions = true; } else { AddText((m_CapitalLetters == true) ? e.Character.ToString().ToUpper() : e.Character.ToString()); //... just add the text as usual. m_CapitalLetters = false; m_UpdateCharPositions = true; } } else { if(m_MultiLine) AddNewline(); } } } /// <summary> /// Adds a string to m_Text, and updates the cursor. /// </summary> /// <param name="Text">The string to add.</param> private void AddText(string Text) { m_Text.Add(Text); m_Cursor.CharacterIndex++; m_Cursor.Position.X += CharacterWidth; } //Can the cursor move further down or has it reached the end of the textbox? private bool m_CanMoveCursorDown = true; /// <summary> /// Adds a newline to m_Text, and updates the cursor. /// </summary> private void AddNewline() { m_Text.Add("\n"); m_Cursor.CharacterIndex++; m_Cursor.Position.X = m_TextEditPosition.X; m_Cursor.LineIndex++; //Scroll the text up if it's gone beyond the borders of the control. if ((m_TextEditPosition.Y - TextSize().Y) < (m_TextEditPosition.Y - m_TextEditSize.Y)) { m_TextPosition.Y -= CapitalCharacterHeight; m_CanMoveCursorDown = false; m_UpdateCharPositions = true; } if (m_CanMoveCursorDown) m_Cursor.Position.Y += CapitalCharacterHeight; m_NumLinesInText++; } /// <summary> /// Removes text from m_Text. /// </summary> private void RemoveText() { FixCursorIndex(); FixCursorPosition(); if (m_Cursor.Position.X > m_TextEditPosition.X) { m_Text.RemoveAt(m_Cursor.CharacterIndex); m_Cursor.CharacterIndex--; m_Cursor.Position.X -= CharacterWidth; } if (m_Cursor.Position.X <= m_TextEditPosition.X) { if (m_Cursor.LineIndex != 0) { m_Cursor.Position.X = m_TextEditPosition.X + m_Font.MeasureString(GetLine(m_Cursor.LineIndex - 1)).X; if (m_MultiLine) { m_Cursor.Position.Y -= CapitalCharacterHeight; m_Cursor.LineIndex--; m_NumLinesInText--; if (m_TextPosition.Y < m_TextEditPosition.Y) m_TextPosition.Y += m_Font.LineSpacing; } } } } /// <summary> /// Moves m_Cursor left. /// </summary> private void MoveCursorLeft() { if (m_Cursor.Position.X > m_TextEditPosition.X) { m_Cursor.CharacterIndex -= (((NUM_CHARS_IN_LINE + 1) - GetLine(m_Cursor.LineIndex).Length) + GetLine(m_Cursor.LineIndex).Length); m_Cursor.Position.X -= CapitalCharacterHeight; } //Scroll the text right if the cursor is at the beginning of the control. if (m_Cursor.Position.X == m_TextEditPosition.X) { if (m_TextPosition.X > m_TextEditPosition.X) m_TextPosition.X -= m_Font.LineSpacing; } } /// <summary> /// Moves m_Cursor right. /// </summary> private void MoveCursorRight() { if (m_Cursor.Position.X < (m_TextEditPosition.X + m_TextEditSize.X)) { m_Cursor.CharacterIndex += (((NUM_CHARS_IN_LINE + 1) - GetLine(m_Cursor.LineIndex).Length) + GetLine(m_Cursor.LineIndex).Length); m_Cursor.Position.X += CapitalCharacterHeight; } //Scroll the text right if the cursor is at the beginning of the control. if (m_Cursor.Position.X == m_TextEditPosition.X) { if (m_TextPosition.X < m_TextEditPosition.X) m_TextPosition.X += m_Font.LineSpacing; } } /// <summary> /// Moves m_Cursor up. /// </summary> private void MoveCursorUp() { if (m_Cursor.Position.Y > m_TextEditPosition.Y) { m_Cursor.LineIndex--; m_Cursor.CharacterIndex -= (((NUM_CHARS_IN_LINE + 1) - GetLine(m_Cursor.LineIndex).Length) + GetLine(m_Cursor.LineIndex).Length); m_Cursor.Position.Y -= CapitalCharacterHeight; m_CanMoveCursorDown = true; } //Scroll the text down if the cursor is at the top of the control. if (m_Cursor.Position.Y == m_TextEditPosition.Y) { if (m_TextPosition.Y < m_TextEditPosition.Y) m_TextPosition.Y += m_Font.LineSpacing; } } /// <summary> /// Moves m_Cursor down. /// </summary> private void MoveCursorDown() { if (m_Cursor.Position.Y < (m_TextEditPosition.Y + m_TextEditSize.Y)) { m_Cursor.LineIndex++; m_Cursor.CharacterIndex += (((NUM_CHARS_IN_LINE + 1) - GetLine(m_Cursor.LineIndex).Length) + GetLine(m_Cursor.LineIndex).Length); m_Cursor.Position.Y += CapitalCharacterHeight; } else //Scroll the text up if the cursor is at the bottom of the control. { if ((m_TextPosition.Y + TextSize().Y) > (m_TextEditPosition.Y + m_TextEditSize.Y)) m_TextPosition.Y -= m_Font.LineSpacing; } } /// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here base.Initialize(); } /// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here m_Font = Content.Load<SpriteFont>("ProjectDollhouse_11px"); } /// <summary> /// UnloadContent will be called once per game and is the place to unload /// game-specific content. /// </summary> protected override void UnloadContent() { // TODO: Unload any non ContentManager content here } /// <summary> /// Calculates the size of all the text in the textbox. /// </summary> /// <returns>A Vector2 containing the width and height of the text.</returns> private Vector2 TextSize() { float Width = 0.0f, Height = 0.0f; foreach (string Str in TextWithLBreaks.Split("\n".ToCharArray())) { Vector2 Size = m_Font.MeasureString(Str); Width = Size.X; Height += Size.Y; } return new Vector2(Width, Height); } /// <summary> /// Update the hitboxes for the characters in the textbox. /// The hitboxes are used to detect collision(s) with the mouse cursor. /// </summary> private void UpdateHitboxes() { if (m_UpdateCharPositions) { int Height = 0; m_HitBoxes.Clear(); //Make sure it doesn't go out of bounds... if (m_Text.Count >= 1) { for (int i = 0; i < m_CharacterPositions.Count; i++) { //Make sure it doesn't go out of bounds... Height = (int)m_Font.MeasureString(m_Text[i < m_Text.Count ? i : m_Text.Count - 1]).Y; //Create a hitbox for each character if the character isn't the last one. if (i != m_CharacterPositions.Count - 1) { Rectangle Hitbox = new Rectangle((int)m_CharacterPositions[i].X, (int)m_CharacterPositions[i].Y, (int)(m_CharacterPositions[i + 1].X - m_CharacterPositions[i].X), Height); m_HitBoxes.Add(Hitbox); } } } m_UpdateCharPositions = false; } } /// <summary> /// Updates the positions of the characters. /// Called when a character is added or deleted from the textbox. /// </summary> private void UpdateCharacterPositions() { Vector2 Position = m_TextEditPosition; float XPosition = 0, YPosition = 0; if (m_UpdateCharPositions) { m_CharacterPositions.Clear(); int CharIndex = 0; foreach (string Str in TextWithLBreaks.Split("\n".ToCharArray())) { XPosition = 0; for (int i = 0; i < Str.Length; i++) { float CharWidth = m_Font.MeasureString(Str.Substring(i, 1)).X; XPosition += CharWidth; m_CharacterPositions.Add(CharIndex, new Vector2(XPosition + m_TextEditPosition.X, Position.Y + m_TextEditPosition.Y)); CharIndex++; } YPosition += CapitalCharacterHeight; Position.Y = YPosition; } ///This shouldn't be set here, because it is set in UpdateHitboxes(); //m_UpdateCharPositions = false; } } /// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) Exit(); m_Input.Update(); UpdateCharacterPositions(); UpdateHitboxes(); foreach (Rectangle Hitbox in m_HitBoxes) { if (Hitbox.Contains(new Vector2(m_Input.MousePosition.X, m_Input.MousePosition.Y)) && m_Input.IsNewPress(MouseButtons.LeftButton)) { m_Cursor.Position = new Vector2(Hitbox.X, Hitbox.Y); int CharIndex = m_CharacterPositions.FirstOrDefault(x => x.Value == m_Cursor.Position).Key; if (CharIndex != -1) m_Cursor.CharacterIndex = CharIndex; } } foreach (Keys Key in (Keys[])Enum.GetValues(typeof(Keys))) { if (m_Input.IsNewPress(Key)) { m_DownSince = DateTime.Now; m_RepChar = Key; } else if (m_Input.IsOldPress(Key)) { if (m_RepChar == Key) m_RepChar = null; } if (m_RepChar != null && m_RepChar == Key && m_Input.CurrentKeyboardState.IsKeyDown(Key)) { DateTime Now = DateTime.Now; TimeSpan DownFor = Now.Subtract(m_DownSince); if (DownFor.CompareTo(TimeSpan.FromMilliseconds(m_TimeUntilRepInMillis)) > 0) { // Should repeat since the wait time is over now. TimeSpan repeatSince = Now.Subtract(m_LastRep); if (repeatSince.CompareTo(TimeSpan.FromMilliseconds(1000f / m_RepsPerSec)) > 0) // Time for another key-stroke. m_LastRep = Now; } } } Keys[] PressedKeys = m_Input.CurrentKeyboardState.GetPressedKeys(); //Are these keys being held down since the last update? if (m_RepChar == Keys.Back && m_LastRep == DateTime.Now) RemoveText(); if (m_RepChar == Keys.Up && m_LastRep == DateTime.Now) { if(m_MultiLine) MoveCursorUp(); } if (m_RepChar == Keys.Down && m_LastRep == DateTime.Now) { if(m_MultiLine) MoveCursorDown(); } foreach (Keys K in PressedKeys) { if (m_Input.IsNewPress(K)) { switch(K) { case Keys.Up: if (m_RepChar != Keys.Up || m_LastRep != DateTime.Now) { if(m_MultiLine) MoveCursorUp(); } break; case Keys.Down: if (m_RepChar != Keys.Down || m_LastRep != DateTime.Now) { if (m_MultiLine) MoveCursorDown(); } break; case Keys.Left: if (!m_MultiLine) MoveCursorLeft(); break; case Keys.Right: if (!m_MultiLine) MoveCursorRight(); break; case Keys.Back: if (m_RepChar != Keys.Back || m_LastRep != DateTime.Now) RemoveText(); break; case Keys.LeftShift: m_CapitalLetters = true; break; case Keys.RightShift: m_CapitalLetters = true; break; case Keys.Enter: AddNewline(); break; } } } base.Update(gameTime); } /// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); spriteBatch.GraphicsDevice.ScissorRectangle = new Rectangle((int)m_TextEditPosition.X, (int)m_TextEditPosition.Y, (int)m_TextEditSize.X, (int)m_TextEditSize.Y); Vector2 Position = m_TextPosition; spriteBatch.Begin(SpriteSortMode.BackToFront); if(m_Cursor.Visible) spriteBatch.DrawString(m_Font, m_Cursor.Symbol, m_Cursor.Position, Color.White); // TODO: Add your drawing code here foreach (string Str in TextWithLBreaks.Split("\n".ToCharArray())) { spriteBatch.DrawString(m_Font, Str, Position, Color.White); Position.Y += CapitalCharacterHeight; } spriteBatch.End(); base.Draw(gameTime); } } } UpdateCharacterPositions() and UpdateHitboxes() seems to work perfectly. That is, UNTIL the text has been scrolled up: /// <summary> /// Adds a newline to m_Text, and updates the cursor. /// </summary> private void AddNewline() { m_Text.Add("\n"); m_Cursor.CharacterIndex++; m_Cursor.Position.X = m_TextEditPosition.X; m_Cursor.LineIndex++; //Scroll the text up if it's gone beyond the borders of the control. if ((m_TextEditPosition.Y - TextSize().Y) < (m_TextEditPosition.Y - m_TextEditSize.Y)) { m_TextPosition.Y -= CapitalCharacterHeight; m_CanMoveCursorDown = false; m_UpdateCharPositions = true; } if (m_CanMoveCursorDown) m_Cursor.Position.Y += CapitalCharacterHeight; m_NumLinesInText++; } I'm guessing that I need to take m_TextPosition.Y into consideration here: foreach (Rectangle Hitbox in m_HitBoxes) { if (Hitbox.Contains(new Vector2(m_Input.MousePosition.X, m_Input.MousePosition.Y)) && m_Input.IsNewPress(MouseButtons.LeftButton)) { m_Cursor.Position = new Vector2(Hitbox.X, Hitbox.Y); int CharIndex = m_CharacterPositions.FirstOrDefault(x => x.Value == m_Cursor.Position).Key; if (CharIndex != -1) m_Cursor.CharacterIndex = CharIndex; } } But I'm not entirely sure what to do. I tried both multiplying and adding m_TextPosition.Y to m_Input.MousePosition.Y and Hitbox.Y, but none of them seemed to work. Please help!
  6. So, after weeks of strange and seemingly intermittent/coincidental UDP server crashes(Receive Thread Halt/Un-catchable Exception) and the ensuing frustration that that causes when you aren't even trying to work on the server itself. I sat down and spent a day trying to figure out the problem.. After an almost complete server rewrite from scratch with no real improvement in the problem.. I turned to random poking about on the internets.. Hmmm... It seems like the problem only happens when I'm restarting the client.. Here's a post!! https://stackoverflow.com/questions/38191968/c-sharp-udp-an-existing-connection-was-forcibly-closed-by-the-remote-host And Here! https://social.msdn.microsoft.com/Forums/en-US/6b7aa353-259b-4637-b0ae-d4e550c13e38/c-udp-socket-exception-on-bad-disconnect?forum=netfxnetcom Yup, that's the problem for sure. It appears that even though UDP isn't supposed to care about the other ends state, apparently this isn't true if the state is Port Unreachable. When the server attempts to receive data (BeginReceiveFrom/BeginReceive/EndRecieveFrom/EndReceive/etc..) from an async connection and the client has (Crashed/Quit/Etc.) an ICMP port unavailable packet is generated and this causes the UDP socket to generate an exception that (even if you try/catch the hell out of it) causes the async receive thread to halt(I assume, this is the effect anyhow). The best solution I've found, as stated in the link(s) above is to change the underlying IOControl behavior(Prevent the Exception from being thrown). //This value tells the underlying IO system to IGNORE the ICMP error. public const int SIO_UDP_CONNRESET = -1744830452; private Socket _socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); _socket.IOControl((IOControlCode)SIO_UDP_CONNRESET, new byte[] { 0, 0, 0, 0 }, null); _socket.Bind(new IPEndPoint(IPAddress.Any, port)); The first line is the value that needs to be set, and the second to last line is how you can set it. And these are the live bits of code that are WORKING without error in my server, Finally! So, there, I've posted it again because it seems way more obscure than it should be. Enjoy.
  7. Slyxsith

    Full Speed Ahead!

    NOTE: Guys at the time of writing this developer update I have made the decision not to rebrand the project. To anyone who has worked with me on development in the past, Aakrana has been around for over a decade. It's been a vehicle on a journey of learning, discovery and many great adventures. I had planned to relaunch production as Saryn: Kingdom of Thrones but really it was just a name. Just wanted to be completely transparent with what is going on. Aakrana and the gaming systems that were designed for it are back in play. Long live Aakrana. Sorry it’s been a while since I’ve updated the blog. The good news (and there is lots of it) is that the progress we’ve made on the servers in the last month and a half has been staggering. We went from basic account setups and some basic network code across multiple instances to integrating some of the most foundational systems to kick off alpha. In the last 4 weeks we have: - Implemented our advanced questing engine - Implemented tiers 1 through 5 of the resource harvesting system - Itemized Resource harvesting for Lumbering, Herbalism, Farming and Mining - Implemented phase 1 of crafting (Currently Blacksmithing) - Implemented our first pass at day and night cycles - Upgraded the starting area assets (more on this later) - Improved the chat system - Added personal banking and storage - A bunch of gui improvements/functionality (In game compass bar, login screen updates, character selection updates) - UMA character models are in game - A lot more… All of the above has been fully integrated and is testing well on our headless servers. We are slightly ahead of our planning roadmap for pre-alpha completion by the end of November. I’ll attach a couple of screenshots to this blog for your enjoyment but I have a couple of messages I want to pass on at this point. 1) If you are skilled in UMA character management, 3D modelling and or building/integrating 3D animations and want to talk about how you can be a part of what we are building I would really be interested in talking. Please head to our website and hit the opportunities link in the navigation bar to see more details 2) If you are a 3D modelling professional and have fantasy RPG asset bundles for sale that are Unity and UMA compatible and are willing to offer us a an amazing “special offer” please get in touch. 3) Are you a 2D fantasy artist and interested in showcasing your talents through our website and in game screens? We are currently so focused on delivering an awesome player experience with our in game systems that we could really use a talented 2D fantasy artist to help us spruce up our web presence. Things like loading screen artwork and GUI upgrades are all on our roadmap but if this is something that interests you we’d love to have a conversation. I would like to be clear (and the website has all of the details on this) this project is un-funded. Every cent that gets spent is money I am taking away from supporting my family. I am doing this project because I have a passion for game development and over 15 years working in the indie game dev world. We are looking for individuals with a similar passion and commitment who can work in a professional manner for the love of what they do. If this sounds like you please get in touch. Thank you for reading this latest blog. Looking forward to the next one.
  8. Hello forum dwellers! I've recently decided to dive into using ECS, as it looks like it solves so many issues with game development, especially with the game I am currently making (which involved many complex entities seamlessly interacting at the same time). It all seemed relatively straightforward. So far, I understand that: 1.) The entity is simply a container for components (which can also have an identifier) 2.) The components are interchangeable blocks of data which change the way the entity will behave (only containing data - no methods/functions/logic) 3.) The systems loop through all the entities and checks to see which components they contain. If it contains the appropriate components, act on them. So far, this has been easy to implement and worked for the basic design. For example, I have a player, block and a ball. The rendering component is present in all 3, colliders in all 3, physics in the player and ball, and input only in the player. I recently looked up how components interact with one another, and that also seems simple. For example, if I want a player to animate due to a button press, I would create a system which requires a rendering component AND input component. The problem I seem to be having trouble understanding is exactly how to nest more complex entities and components. For example, I want my player to be able to punch the ball around. If the player presses the "E" key, I want to create a fist which punches to the left (drawn over the player without the player animation changing). However, the fist itself punching the ball technically has a sprite that needs rendering and also a collision box, so should I create a "fist" component which contains 2 components (rendering and collision), or should I generate a new entity which contains those 2 components and let the systems act naturally on it? I feel like by nesting components within components, I end up with this spaghetti code where systems are calling other systems, removing the whole point of an ECS. It feels more "natural" to just leave the systems to wait and act on entities which contain the correct components. However, if I create a new "fist" entity, this needs to be tied to the player, so I ended up with an entity containing an entity which also seems ugly, or a weird entity with some kind of reference of linking ID to its creator. Am I missing something? On another note, is it unsafe to add multiple instances of the same component? I've heard that it's bad practice too. For example, I might have entities which all require rendering, but some might want to use animated sprites, multiple layers of sprites, shaders, etc. Is it better to have multiple rendering components which can optionally interact, or possibly use a rendering component interface which multiple rendering components can inherit from? Is this inheritance not defeating the purpose of using an ECS in the first place? Any help would be greatly appreciated! Thanks, Zuhane
  9. I'm working on a learning project of a fairly simplistic multiplayer RPG game as a way to get my head around best-practices etc. One thing I am wondering is if best practice is to roll all loot drops and item crafting on the server rather than inside the game? I don't have a lot of experience in game development so hopefully this doesn't seem like a really obvious / embarrassing yes or no! 😑 My thought process was: 1. that if there are two players on a map, and they kill a mob, they need to immediately see identical loot, and; 2. rolling the properties of an item server-side eliminates the chance of hacking local code to spit out top tier items If the above two assumptions are correct, my second question was how to verify on the server that the player has actually performed the function in-game? (For example, that the crafting materials were actually used, or the monster was actually killed? And that a forged request has not been sent from a modified game client?) I would expect some sort of "signature" or unique hash to be included, but can't yet understand how that dynamic would work?
  10. Hello, Emmersion Studios LLC is looking to add a programmer for our MATCHINO development team. We're a startup studio (in business for the past 7 months) planning for a release in November. We've hit a bump in the road and need some help from an additional programmer. We have a comprehensive go-to-market strategy, we feel we have a strong marketing design with the core demographic we're aiming for, and all of our legal eggs in a basket (incorporate, registered with the state, EIN number, rev share contracts, TOS and Privacy Policy). In short, not only do we plan on making more games in short order, but we also plan on building a whole business that will hopefully create jobs for us in addition to fantastic games. Right now, we're a revenue share, but this project we're working on is an important part of making a stable game studio and business so we can create even more content very soon. For more information, please visit our website at: EmmersionStudios.com Please PM me if you're interested. -Sam
  11. I've spent the last few days coding in my Economy Server, I've almost completed the functionality of Banking! So, it's truly time for a rewind about something entirely different to clear my head. Here's an editor view from a little while back, before I was loading a "visible planet" object, the procedurally loaded landscape was the only visible landscape, the rest of the planet, if you could see it before the landscape loaded, just looked like water. So, let me start off by clarifying, the landscape in my game is generated prodedurally, however it is not "generated" during game play. I have a separate process that I can run on any sculptured sphere of my choosing that will generate the individual triangular mesh objects and then save them into "tile" files. These tile files also contain place holders for items such as Arrays of Trees, Rocks, and Plants. Let's start at the Crawler! The following script is the code that crawls from triangle to triangle along the planet mesh and kicks off the generation of the tiles. using System.Collections; using System.Collections.Generic; using UnityEngine; public class MeshCrawler : MonoBehaviour { public Vector3[] verts; public int[] tris; public Vector3[] norms; public int curTri = 0; public int startTri = -1; public int endTri; public string meshName; public List<int> triBuffer = new List<int>(); bool crawling = false; // Use this for initialization void Start () { verts = GetComponent<MeshFilter>().mesh.vertices; norms = GetComponent<MeshFilter>().mesh.normals; tris = GetComponent<MeshFilter>().mesh.triangles; meshName = GetComponent<MeshFilter>().mesh.name; } IEnumerator CrawlIT() { crawling = true; if (endTri > (tris.Length / 3)) endTri = tris.Length / 3; if (startTri > -1 && endTri > 0) { Debug.Log("Crawling " + startTri.ToString() + " to " + endTri.ToString()); for (int i = startTri; i < endTri; i++) { curTri = i; Vector3 p0 = verts[tris[i * 3 + 0]]; Vector3 p1 = verts[tris[i * 3 + 1]]; Vector3 p2 = verts[tris[i * 3 + 2]]; Vector3 n0 = norms[tris[i * 3 + 0]]; Vector3 n1 = norms[tris[i * 3 + 1]]; Vector3 n2 = norms[tris[i * 3 + 2]]; UWTerrainTri triCandidate = new UWTerrainTri(); triCandidate.triIndex = i; triCandidate.meshName = "PlanetZed"; triCandidate.points = new Vector3[3] { p0, p1, p2 }; triCandidate.normals = new Vector3[3] { n0, n1, n2 }; TerrainController.TriHit(triCandidate); //Debug.Log("Tri: " + i.ToString()); yield return null; } } Debug.Log("Crawler finished."); crawling = false; } // Update is called once per frame void Update () { if (triBuffer.Count > 0) { if (!crawling) { startTri = triBuffer[0] - 5; endTri = triBuffer[0] + 5; run = true; triBuffer.RemoveAt(0); } } if (!crawling) { StartCoroutine(CrawlIT()); } } } Okay, so what's it doing? This script is attached to the planet mesh object and it starts a Coroutine(Unity safe psudo-thread a "function that yields") that handles all the data gathering steps. This routine grabs the triangles array from the MeshFilter and works its way from 0 to the end, pulling the vertices out of the MeshFilters verts array, stuffing those into a class that is passed to another bit of code. The following code decides how to handle the UWTerrainTri class objects that are passed from the Crawler: //The above code sends it's result to a "TriHit()" routine. //that routine has terrain Loading functionality in it, in this mode mode //it just passes the UWTerrainTri object to GenTriLand(): public List<Vector3> vertsWTrees = new List<Vector3>(); public void GenTriLand(UWTerrainTri uWTerrainTri) { //Create a new mesh object. Mesh mesh = new Mesh(); //This is the class that is saved as the "tile" object. TerrainSegment ts = new TerrainSegment(); //Generate a good file name. string tpName = uWTerrainTri.meshName + uWTerrainTri.triIndex.ToString("0000000"); //Grab the vertices. ts.vertices = uWTerrainTri.points; //500,000 files in the same directory is a BAD idea. ;) string dir1 = tpName.Substring(9, 2); string dir2 = tpName.Substring(11, 1); dir2 = "0" + dir2; //Generate a full file name. string fullFilePath = Application.persistentDataPath + "/tdat/" + dir1 + "/" + dir2 + "/" + tpName + ".dat"; mesh.vertices = ts.vertices; mesh.uv = new Vector2[3] { new Vector2(0, 0), new Vector2(0, 1), new Vector2(1, 1) }; mesh.triangles = new int[] { 0, 1, 2 }; mesh.RecalculateBounds(); mesh.RecalculateNormals(); ts.vertices = mesh.vertices; ts.normals = mesh.normals; ts.uvs = mesh.uv; ts.Tris = mesh.triangles; //Data Objects for Rocks, Grass, Trees List<EnvironmentObject> rl = new List<EnvironmentObject>(); List<EnvironmentObject> gl = new List<EnvironmentObject>(); List<EnvironmentObject> tl = new List<EnvironmentObject>(); List<Vector3> usedVertices = new List<Vector3>(); //Rocks int r = UnityEngine.Random.Range(3, 12); for (int i = 0; i < r; i++) { Vector3 point = GetRandomPointOnMesh(mesh); int tryCount = 0; while (usedVertices.Contains(point)) { tryCount++; point = GetRandomPointOnMesh(mesh); if (tryCount > 10) goto NoRock;//Yeah goto just works sometimes, hate me if you want. } usedVertices.Add(point); EnvironmentObject eo = new EnvironmentObject(); eo.prefab = "rock" + UnityEngine.Random.Range(1, 3).ToString() + "sm"; eo.pos = point; eo.rot = Quaternion.identity; eo.scale = Vector3.one; rl.Add(eo); NoRock:; } usedVertices.Clear(); //Grass int g = UnityEngine.Random.Range(2, 8); for (int i = 0; i < g; i++) { Vector3 point = GetRandomPointOnMesh(mesh); int tryCount = 0; while (usedVertices.Contains(point)) { tryCount++; point = GetRandomPointOnMesh(mesh); if (tryCount > 10) goto NoGrass; } usedVertices.Add(point); EnvironmentObject eo = new EnvironmentObject(); eo.prefab = "grass" + UnityEngine.Random.Range(1, 4).ToString(); eo.pos = point; // + new Vector3(UnityEngine.Random.Range(-5.0f, 5.0f), 0, UnityEngine.Random.Range(-5.0f, 5.0f)); eo.rot = Quaternion.identity; eo.scale = Vector3.one; gl.Add(eo); NoGrass:; } usedVertices.Clear(); //Trees int t = UnityEngine.Random.Range(0, 3); for (int i = 0; i < t; i++) { Vector3 point = mesh.vertices[UnityEngine.Random.Range(0, mesh.vertices.Length)]; int tryCount = 0; while (vertsWTrees.Contains(point)) { tryCount++; point = mesh.vertices[UnityEngine.Random.Range(0, mesh.vertices.Length)]; if (tryCount > 10) goto NoTree; } vertsWTrees.Add(point); EnvironmentObject eo = new EnvironmentObject(); eo.prefab = "tree" + UnityEngine.Random.Range(1, 3).ToString(); eo.pos = point; GameObject tree = new GameObject(); tree.transform.SetParent(planet.transform); tree.transform.localPosition = eo.pos; float maxs = 10; if (eo.prefab == "tree2") maxs = 15; FixTree(tree.transform, 5, maxs, 10); eo.pos = tree.transform.localPosition; eo.rot = tree.transform.localRotation; eo.scale = tree.transform.localScale; Destroy(tree); tl.Add(eo); NoTree:; } //Housekeeping for performance. if (vertsWTrees.Count > 10000) { while (vertsWTrees.Count > 10000) { vertsWTrees.RemoveAt(0); } } ts.rocks = rl.ToArray(); ts.grass = gl.ToArray(); ts.trees = tl.ToArray(); //Save terrain "tile" file. string json = JsonUtility.ToJson(ts); File.WriteAllText(fullFilePath, json); //Debug.Log("New Terrain Generated: " + tpName); } [Serializable] public class TerrainSegment { public Vector3[] vertices; public Vector3[] normals; public Vector2[] uvs; public int[] Tris; public EnvironmentObject[] rocks; public EnvironmentObject[] grass; public EnvironmentObject[] trees; } [Serializable] public class EnvironmentObject { public string prefab; public Vector3 pos; public Quaternion rot; public Vector3 scale; } This code produces a file for each triangle in the planet mesh. These files are then "streamed" to the client when any of many "mesh agents"(attached to the player object) in the game does a raycast at the ground and discovers a triangle ID that has not been loaded. The game client will then send a request to the server to download the tile number that hasn't been found in the local cache of tile files. Which as you can see from the above image, it works pretty swimmingly. Let me know what ya think!
  12. Hey all! I thought I would lay my post out a little different just so you can skip to the main parts that you wish to see. I Am: CheekyTrooper / Jason (JSON) Who Am I: I am 25 years old, software developer working on websites currently (C#, T-SQL, HTML5, CSS3, Sass, Angular, IIS) from England (for timezone purposes). What am I looking for: I am seeking a individual / team to join so that I can expand my game programming skills further and make some cool stuff . I don't really want a MMORPG to start working on, a small game would be better for myself. Motivators and encourages so we can push each other forwards. Previous Experience: I have created a zombie survival game in Game Maker, I have created a non-engine nodeJS html5 multiplayer chat node application (Little circles floating around with ability to chat). Engines I Know: I have previously used Unity, Game Maker, GoDot, and played around with code not in an engine. Languages I Know: C#, HTML5, CSS3, Sass, GML(Game Maker Language), T-SQL, Javascript. How long can I dedicate to the project: I work from 6am - 4pm, Monday - Friday. Saturday morning I take my daughter to gymnastics. Other than this i am pretty dedicated and determined to create something great!. How to contact: Please PM myself, or view my profile to see my Twitter or website to get hold of myself. I look forward to hearing from you! Take Care.
  13. Unsettled World, makes a great title I think, but without a server, it's just a terribly lonely place indeed. I've written many servers over the years and clients to go with them, and in lots of different languages(never before for games). However,I've never been one to hang onto the proper semantics of communicating how a program works so, stick in there and I'll do my best. Please feel free to chime in if you see something technical that could be fixed or if it just looks at you funny, you can tell me that too. I'm good with it. Architecture: Multiple, functionally segmented, server applications / To many, identically functional clients. To sum it up.. haha It's important to say that all servers maintain an authoritative role in all matters of game play. If the Avatar Server hasn't authorized that item in your inventory, it won't be there. If the Economy Server has a 0.00 in your bank account, the game client will reflect that. Avatar Server(Functional in all listed categories): C# UDP server application, game time keeper, controls authentication, resource access, player inventories, land ownership and mining claim ownership and is the "echo point" for network player data such as positioning and appearance data. Economy Server(Currently in ACTIVE Dev): C# UDP server application, Communicates with the Avatar Server to coordinate time synchronization, and to update its list of active player id#s and their encryption keys. Its purpose is to house all the functionality that one would attribute to a game economy(aside from physical resource access). Banking, Auctions and a Resource Stock Market. My Player1 checked the balance on his bank account for the first time just yesterday in fact. He was pleased to finally see the 2000.00 Settler Credits he was promised months ago. lol. NPC Server(s)(Currently Completely Imaginary): C# UDP server application that communicates the positions and coordinates the movements of NPCs that are instantiated into the world by their NPC Client applications. NPC Client(s)(Currently Completely Imaginary): C#(or c#/unity) UDP Client applications that will control the movement and interactivity of one or many NPCs, all NPC code will interact with the server just like player code does, via a UDP connection. However, since most of the NPC data will already be built into the client, these connections will be significantly less chatty than a real players connection. Other Servers/Clients(Also Completely Imaginary): C# probably, UDP most likely.. the rest, who knows. So, how do I keep all these data bits ready for player interaction? Data Structures!! Everything in my servers runs from in-memory data structures, I have no database back end, nor a desire to ever need one. I'm not saying databases aren't cool, or massively useful in similar scenarios. I have built MANY of those too, but to get the response times I want, well that would require something in the range of an in-memory instance of mysql or another big hitter similarly configured. I don't want to have to add that to the arena, and certainly not at this stage of the game.. heh.. stage of the game... Anyway! Some of the Data Structures Currently Utilized in my Avatar Server: //This keeps track of the player ids and encryption strings //When a player logs on an encryption string is negotiated... Dictionary<int, string> playerKeys = new Dictionary<int, string>(); //Reverse lookup for player ID#s to stored GUID ids. //ID#s are shorter and travel better in a compact UDP packet(1470ishbytes) than a big Ol'GUID! Dictionary<int, string> playerGUIDLookup = new Dictionary<int, string>(); //"Table" of currently authenticated Player Save data for many uses here and there, but mostly for persistence purposes. //This gets updated by the client when the player makes changes and is saved on the server side. //Including the character's avatar description. (Avatar Server) Dictionary<int, AvatarSave> PlayerAuth = new Dictionary<int, AvatarSave>(); //Seems redundant somehow, but it isn't. Just, a bad name. //This keeps count of how long a player is idle from the server's perspective, so it can give them the BOOT when it goes too long. Dictionary<int, int> livePlayers = new Dictionary<int, int>(); //Seperate "Table" of data specific to the player avatar movements and orientation, position/rotation/etc... Dictionary<int, AvatarAttitudeUpd> livePlayerData = new Dictionary<int, AvatarAttitudeUpd>(); //This holds data recieved asynchronously from the game clients(or other servers) as well as the EndPoint it was recieved from, for replies. //Each recieved command in this Queue is given a Task to process and reply to the game client with. //One message/activity/request/command per packet and only ONE, so no complicated re-assembly is needed on either end of the wire. Queue<KeyValuePair<string, EndPoint>> UDPClientMessages = new Queue<KeyValuePair<string, EndPoint>>(); //A less organized version of the above data structure. These get filtered for players who aren't logged in anymore, commands out of order get skipped, and etc.. Essentially it's the RAW data from the asyncronous receiver. Dictionary<EndPoint, Queue<string>> UDPMessages = new Dictionary<EndPoint, Queue<string>>(); //The collection of all known player IP/PORT end points, that haven't been booted for inactivity. Dictionary<int, EndPoint> playerEPs = new Dictionary<int, EndPoint>(); Here's a quick run.. Avatar Server Application Starts: udpServerThread = new Thread(new ThreadStart(UDPServer)); UDPServer() { //Starts up a standard UDP Socket Server here with an asynchronous receive mechanism which pumps into the UDPClientMessages Queue. Loops here waiting for clients to send data. while(true) { Increments Game Time, a double precision counter that keeps track of the total run time of the avatar server. Parallel.ForEach() through the playerEPs sending them them the current server time. foreach() through the livePlayerData sending all relevant network player data to the clients who should see them. Some threadpool scaling to increase/decrease the pool size depending on # of users logged in. Requeueing of messages from UDPMessages into UDPClientMessages happens via some Task.Factor Tasks. And finally a new Task.Factory Task is created for every item in the UDPClientMessages Queue to process the incoming command from the player's game client. (player's new coordinates, logins, inventory requests, changes,etc,etc,etc)... } } I can't even call that pseudo-code but I think it conveys what I'm trying to share without going into too much gory detail. If anybody wants some of that, feel free to comment below and I'll expand on anything I can. But this describes the basic conceptual design of my server applications. There are whole other layers of data structures in that server that I've omitted as it gets extremely gory in there... But that's where the inventories / resources / and crafted items live and it's a bit messy right now. I'm going to try to get those a little bit more finalized before I try to convey their madness to you. Suffice to say, there's a lot more to it than this. But that is less related to the "server" and more related to the game. Until next, Thanks for reading!
  14. Septopus

    How and Why my world Turns.

    Continuing my rewind for Unsettled World: Time to give some detail on the foundations of my game environment. The planet I've created and how it mechanically works within Unity. Here is a 2d view of the editor interface with the "canvas" highlighted sitting at 0,0,0. The planet object has a 30000m radius and it is sitting @ 0,-30000,0. The object parentage looks like this. Generic GameObject "PlanetHolder", non-rendered mesh w/collider "Planet" (used by the procedural terrain system mostly), followed by the camera, player, water sphere and the actually visible surface mesh. Now, this arrangement may change somewhat, I may figure out a way to combine the "Planet" with the visible surface, but it is how it is for now. And it works. The PlanetController script is responsible for keeping the player and camera close to Origin, 0,0,0. This is necessary because once your player/camera cross the 10000m distance boundary the underlying floating point mathematics loses enough precision that your meshes begin jumping around the screen. The PlanetController script contains this logic: public class PlanetController : MonoBehaviour { public GameObject Planet; public GameObject Player; Rigidbody rb; void Start() { rb = Player.GetComponent<Rigidbody>(); } void FixedUpdate() { if (rb.velocity.magnitude < 1) { Planet.transform.localRotation = Quaternion.FromToRotation((Player.transform.localPosition - Planet.transform.localPosition).normalized, Vector3.up); } } } Keep in mind I omitted a lot of extra stuff from that code, for example, it doesn't actually run EVERY FixedUpdate, but as a timed event inside the fixed update, every few seconds or so. Also Important to note, I still have a minor amount of vertical jitter that is caused by the planet sitting at 0,-30000,0. I am actively working at ways to reduce this, in fact, as I type I'm having more ideas on how to fix the issue.. So keep posted. ^Solved and NOT related to the size/positioning within the 3D space, see comment below. The visual look of the planet(Before the procedural code kicks off and repaints it with textures/objects). Is a split up version of the planet mesh(will be split up MUCH more than this eventually).. And the water is a simple sphere object(also broken up and non-visible sections removed) with a water texture. My Gravity "system" is also very simple(Just a script, like this one, attached to the objects that need gravity applied to them): public class GravControl : MonoBehaviour { public GameObject planet; private Rigidbody rb; public Vector3 upVector; void Start() { if (planet == null) { planet = GameObject.Find("Planet"); } rb = GetComponent<Rigidbody>(); Vector3 upVector = (transform.position - planet.transform.position); transform.rotation = Quaternion.FromToRotation(transform.up, upVector) * transform.rotation; } void FixedUpdate() { upVector = (transform.position - planet.transform.position).normalized; rb.AddForce(-upVector * 9.81f, ForceMode.Acceleration); } } I may incorporate this into a "controller" type script that isn't attached to every object at some point for simplicity, but for now, it works just fine. So that, just a few pics and sentences, well summarizes at least 2 or 3 solid weeks of 8+ hour days... hahaha!
  15. Septopus

    Inception, or How I Lost My Mind.

    Well, this is the first post for a project I've been working on for a few months already. So, let me rewind a bit.... A few months back I started toying with the idea of making a game with an actual spheroid planet as the core of the environment. Yay Unity and Blender!! A few weeks of toying around and I had a pretty neat little 5000m diameter spheroid planet with custom gravity and a player character(UMA v2) running around on it. Well, that was way easier than I expected... It was at this very point, the actual madness began to set in. Well, it's working, I guess I should make a game out of it... Okay. Hmm, online? Of course! Hmm, mmoYES! Oh, damn, I've really lost it now. Crafting, well, certainly. Mining and hunting?! Don't be silly, yes yes yes yes, all the yes. Bigger? hmmm.... hmm... yes? Let's try 10000m radius.. hmmm... Jittery character movements.. and jittery everything... hmm... 9000m radius? all good... hmmm... And this is where I learned all about the floating point precision problems of 3d engines at great distances from 0,0,0.. Fun stuff. Only slightly maddening. But, in the end, also easily solved by rotating the entire freakin planet periodically so the player character and camera stay close to 0,0,0. Let's pump this guy up to 30000meter radius and call that good for now. I ran across a few other jitter problems along this winding path but those were solved through the careful use of the "FixedUpdate" vs "Update" method selection. Moving anything that involved my custom gravity or physics in general to a FixedUpdate method was the solution for most cases. So, we got a character and a planet... I guess we need stuff to do. And from here the rabbit hole only started lengthening, until there really was no beginning or end. So, there's one of the nutshells... The inception! Over the next few days I'm going to try to detail as much of the current guts of this beast as I can for anybody who's crazy enough to follow along, while trying to not distract myself from creating more of them of course. Project Stats: Unity Game Client Lines of Code: 24,032 Avatar Server Lines of Code: 2,480 Economy Server Lines of Code: 387
  16. Hello, my name is Piotrek, I'm 26 years old and I'm a programmer looking for a team who could use my help. I am programming amateurly for over 8 years (sometimes more, sometimes less), I studied computer science and currently I've been working for over two years as C# developer in company creating backup software (WinForms. WPF etc.). I played with UnityEngine (more) and UnrealEngine (less) so I get basics to further work. I wanted always make computer games and it's why I became programmer. I tried few times to collaborate with single persons from Internet but it was always starting from zero. without any experience and unfortunately, it didn't work out. Now I'm looking for a team which are working now on game and have more work than programmers (but had at least 1-2 with which I can work). It would be nice if it is a commercial project (I can work some times for free to show my skill), but if it is a hobby project I also could consider cooperation. My main goal is to ship first game for my portfolio. I can spend 2-3h every day on this, in weekends more. Please PM if you have something which could interest me or any question. EDIT: It didn't last long to wait for first offers, so I'll focus now on one of them and if it won't work out well (I hope not!), I will be back here. Wish me good luck.
  17. Hello Everyone, I am a one man team looking for the perfect technical collaborator to partner with on the making of an independent story driven game. I have a background in film making and a few years of experience in the industry as freelance Cinematic Artist, and besides my cinematic skills i developed soft skills in modeling, lighting, blocking out levels and staging animations, audio design and narrative writing. I can also script in c# myself, which, along with the soft skills listed above, helps me to quickly prototype new game-play ideas independently. My counterpart must be technical, possibly but not necessarily with an artistic mind too, and can take care of everything that is related to the engineering part of a game, from basic artist friendly features scripting to structure solid, stable and modular code that will support the core of the game. Knowledge of C# and Unity is required and professional experience of 3\5 years in a relevant position is preferred. I dedicate a lot of hours in game development, whether I am working full-time on something else during the day (as Cinematic Artist) or whether I am unemployed. The ideal “partner” then is someone that can put together enough hours during the week and weekends too. I know how to balance life, work and personal work, so I am expecting you to be able and willing to do the same with passion, dedication and sometimes spirit of sacrifice. I am based in Central Europe, so ideally no more than 2 hours difference in our time zone is preferred, for productivity reasons. Should you be a good match with the description above and in case you are interested in knowing more about me, my past projects and the present one and how i am planning to complete it, please get in touch. Cheers
  18. yonisit

    delete please

    delete please
  19. I'm writing a wrapper around some filesystem stuff in C#, and I was wondering if the "LoadFile" function should throw a (custom) FileNotFoundException, or just return null? There is a "FileExists" function, so I guess I could just throw an exception and trust the caller, but I can see how failing gracefully would lead to an easier to handle class. I'd like to ask for pros and cons.
  20. Hi everyone. I am programmer from Ukraine. I am not designer , but I want to draw cool art and make cool games. I learning. I walked the long road from zero to publicating game in store. So, I want to tell you about my game. I hope you enjoy my game and you will write feedback in Store or here (In store will be better 😉 ). Thanks everyone who will play my game. Genre: Arcade/Runner Platform: Android (4.1 and higher) Description: Do you think what these stairs is easy ? No! Every stair want to kill you. One wrong move and you begin from start. You should be careful. Try to find good tactic and look a both ! Be careful ! Stairs are anywhere ! Do you want to be a King of Stairs ? It will not easy. Android - https://play.google.com/store/apps/details?id=com.nazariyoliynyk.dangerousstairs
  21. I've been experimenting with my own n-body simulation for some time and I recently discovered how to optimize it for efficient multithreading and vectorization with the Intel compiler. It did exactly the same thing after making it multithreaded and scaled very well on my ancient i7 3820 (4.3GHz). Then I changed the interleaved xy coordinates to separate arrays for x and y to eliminate the strided loads to improve AVX scaling and copy the coordinates to an interleaved array for OpenTK to render as points. Now the physics is all wrong, the points form clumps that interact with each other but they are unusually dense and accelerate faster than they decelerate causing the clumps to randomly fly off into the distance and after several seconds I get a NaN where 2 points somehow occupy exactly the same x and y float coordinates. This is the C++ DLL: #include "PPC.h" #include <thread> static const float G = 0.0000001F; const int count = 4096; __declspec(align(64)) float pointsx[count]; __declspec(align(64)) float pointsy[count]; void SetData(float* x, float* y){ memcpy(pointsx, x, count * sizeof(float)); memcpy(pointsy, y, count * sizeof(float)); } void Compute(float* points, float* velx, float* vely, long pcount, float aspect, float zoom) { #pragma omp parallel for for (auto i = 0; i < count; ++i) { auto forcex = 0.0F; auto forcey = 0.0F; for (auto j = 0; j < count; ++j) { if(j == i)continue; const auto distx = pointsx[i] - pointsx[j]; const auto disty = pointsy[i] - pointsy[j]; //if(px != px) continue; //most efficient way to avoid a NaN failure const auto force = G / (distx * distx + disty * disty); forcex += distx * force; forcey += disty * force; } pointsx[i] += velx[i] -= forcex; pointsy[i] += vely[i] -= forcey; if (zoom != 1) { points[i * 2] = pointsx[i] * zoom / aspect; points[i * 2 + 1] = pointsy[i] * zoom; } else { points[i * 2] = pointsx[i] / aspect; points[i * 2 + 1] = pointsy[i]; } /*points[i * 2] = pointsx[i]; points[i * 2 + 1] = pointsy[i];*/ } } This is the relevant part of the C# OpenTK GameWindow: private void PhysicsLoop(){ while(true){ if(stop){ for(var i = 0; i < pcount; ++i) { velx[i] = vely[i] = 0F; } } if(reset){ reset = false; var r = new Random(); for(var i = 0; i < Startcount; ++i){ do{ pointsx[i] = (float)(r.NextDouble()*2.0F - 1.0F); pointsy[i] = (float)(r.NextDouble()*2.0F - 1.0F); } while(pointsx[i]*pointsx[i] + pointsy[i]*pointsy[i] > 1.0F); velx[i] = vely[i] = 0.0F; } NativeMethods.SetData(pointsx, pointsy); pcount = Startcount; buffersize = (IntPtr)(pcount*8); } are.WaitOne(); NativeMethods.Compute(points0, velx, vely, pcount, aspect, zoom); var pointstemp = points0; points0 = points1; points1 = pointstemp; are1.Set(); } } protected override void OnRenderFrame(FrameEventArgs e){ GL.Clear(ClearBufferMask.ColorBufferBit); GL.EnableVertexAttribArray(0); GL.BindBuffer(BufferTarget.ArrayBuffer, vbo); mre1.Wait(); are1.WaitOne(); GL.BufferData(BufferTarget.ArrayBuffer, buffersize, points1, BufferUsageHint.StaticDraw); are.Set(); GL.VertexAttribPointer(0, 2, VertexAttribPointerType.Float, false, 0, 0); GL.DrawArrays(PrimitiveType.Points, 0, pcount); GL.DisableVertexAttribArray(0); SwapBuffers(); } These are the array declarations: private const int Startcount = 4096; private readonly float[] pointsx = new float[Startcount]; private readonly float[] pointsy = new float[Startcount]; private float[] points0 = new float[Startcount*2]; private float[] points1 = new float[Startcount*2]; private readonly float[] velx = new float[Startcount]; private readonly float[] vely = new float[Startcount]; Edit 0: It seems that adding 3 zeros to G increases the accuracy of the simulation but I'm at a loss as to why its different without interleaved coordinates. Edit 1: I somehow achieved an 8.3x performance increase with AVX over scalar with the new code above!
  22. Hi everyone! So, I have this rather complex Unity project, I've been working on for the past months. So I will try to narrow it down to only the most relevant parts. The game's core is pretty much your standard space sim, meaning you're flying your spacecraft through open space. To do that, I have a "Player" GameObject in the scene's root. The Player has a Rigidbody (3D) attached, and a simple box collider. And it has two child objects: One is the actual ship (incl. meshes, etc.) to be used for the simulation and outside camera views. The other is the cockpit (also containing meshes) to be rendered on top of the main camera's image by another camera. The ship is then moved by applying force (and torque) to the Rigidbody. So far, everything seemed to work smoothly. But I discovered, that if a coordinate exceeds about 20k on any axis, I get a very visible stutter/jitter in the cockpit. Will I really have to re-scale my whole game into miniature wonderland or did I overlook something? It might be important to note, that as soon as I get the jitter, I can make it worse by changing course in any direction. Also, returning to my starting point (thus, putting coords into "working parameters" again) won't cancel the jitter. Neither flying back nor setting the coords by script will help. Any idea will be much appreciated. Thank you very much
  23. ShrimpAllergy

    C# C# Scripting: Help!

    Hello! I'm a student in a Game Design class, and I need help with a primitive game that's due tonight. It's my first time using vectors, Dot products, and 3D space. The object of the game is simply to sneak past the NPC and reach the goal without being spotted. I'm currently writing script for the NPC, which I intend to have a "cone" of vision, as well as a maximum visibility distance. I've worked out distance with relative ease, but I haven't figured out how to create a field of view for the NPC to spot the player within. I need help with a solution for this mechanic. I'm not intending for anyone to solve it for me, but I've hit a wall, and am at the point where I cannot complete this without asking for help. I'm building in Unity. Any feedback is GREATLY appreciated.
  24. Hello~ I've been Developing an Indie Game for about 2 Months now; that is rather close to being a 2D Version of StarCraft 2; you can read about all of the differences from SC2 at the Link near the bottom of the Page. At the Top of the Page in the Link, there are 4 other Links; these can help you get a FULL Understanding of what the Project is; as well as allow you to view its' Progress, and Join the Dev-Team if you should so wish via the Discord. Any people who are considering joining, please know that I understand that you may be busy with other priorities, and I entirely understand; I don't wish to take your time from that, I'd be happy with only as much time as you feel you can spare as I know that this is a daunting Project and that levels of commitment across Members of the Team will vary. While this is starting out as a Hobby Project, I genuinely dont hope that it will forever remain that way. I'm here working on this to kick-start my Career with Design, while getting some much needed experience in the process, so that I can be better when I go to school. Hiring: The Dev-Team is looking for both Artists and Coders, I feel as though we can wait awhile before looking for any Composers simply due to the fact that the game is in a very early state and there just wouldn't be a lot of Sounds to make so far; but I'm open to it if some Composers want to join. For the Current Game Files, they are intended to be interpreted as the Core of the Game; as the Test Phase is only supposed to create a very limited working Version of the Game, most of the Images will have been revamped by the time that Alpha arrives. Artists: I understand that each Artist will have their own Art Style; infact, I'm counting on it. I believe that as many Art Styles as possible would make the game feel really special. Coders: While the Game may be capable of being Coded in C#; I'm entirely open to it also being coded in Java at the same time. Currently, we are working on creating a Program to allow us to link multiple pictures together into one file, all the while attaching custom variables to each image in the file; so that our Coders can easier work with the Images. Link: https://docs.google.com/document/d/1Dbk3adJNoka4B_q6wWJTVi4v7yKsE54uJopoB26Az80/edit?usp=sharing Thank you for your consideration, have a splendid day.
  25. Hey, me and my team participated in a local game jam last month, we'd love if you could give us some feedback on it! Also, we're just one place behind in the regional ranking of the game jam, and if you guys could vote on us we'll be able to go to the finals, which will happen in 2 months o/ The game is free and playable in the browser: https://bit.ly/VoteForAgatha We plan on improving this game to do an official launch later this year, so any feedback will be really appreciated! Aaand we'd be specially grateful if you could leave a rating on the jam page, the voting ends today 🙃 Agathas-Escape-Vitoria-2-Set-2018.mp4
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!