- Home /
Some Basic Conversions from JavaScript to C#
My company is asking me to make a text-based game using Unity (I know) so I'm trying to get a better grasp of the GUI system since I figure I'll be needed to use that almost exclusively.
They've also asked that I do it in C# since the experience will help if we decide to make something for XBLA. Problem is that I have no experience in programming and the guidebook I'm using is written in Java. Any help you can give would be appreciated.
Text is "Unity 3D Game Development By Example" by Ryan Creighton.
When setting up variables there are two areas I don't know how to do in C#. Snipped out excess code. The project is to create a "Memory" type game where you flip cards over and try to find it's pair.
class Card extends System.Object
{
var aCards:Array;
var aGrid:Array;
var aCardsFlipped;ArrayList;
var img : String;
function Card()
{
img = "robot";
}
}
I'm not sure how to set an image as a variable, nor how to set up Arrays / ArrayLists as variables. I've tried looking around online but there is very little stuff for C# out there. Thanks again for any help you can give. (Any advice on making a text-based game would also be appreciated......just kidding. :( )
Answer by Joshua · Aug 22, 2011 at 07:12 AM
There's very little stuff for C# out there? Are you kidding me? There are literally dozens and dozens of books on it.
The section on ArrayLists / Arrays looks like it will be useful.
I didn't mean to make it sound like there isn't much out there on C#, I meant that in terms of learning materials - there isn't much out there for use of C# within Unity - especially for beginners. There is a text scheduled to come out towards the end of the year but that is it.
There are a few good tutorials out there that I've come across - like the ones at BergZerg Arcade and 3D Buzz, but they're not quite what I'm looking for - namely a very heavy GUI-focused game (well, at least that's how it's looking now.)
Anyway, thanks for taking the time out to reply. Will look into your suggested reading material as well.
Well, Unity uses quite plain C# only with some limitations (no unsafe code for example). Learning the language or using it in Unity are two things ;). Unity just provides an API you can use to interact with Unity. $$anonymous$$eep in $$anonymous$$d that "most" examples in the documentation also provide C# samples. You can switch the language in this small drop-down-selector.
Your answer
Follow this Question
Related Questions
Converting a JS script into C# - hit a wall with arrays... 1 Answer
Integer to Character in unityscript 2 Answers
Help, How can I get variables? 1 Answer
Convert from javascript to c# 2 Answers