Unity中面向对象的编程 [英] Object-oriented programming in Unity

查看:131
本文介绍了Unity中面向对象的编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我的名字是Cynthia,我需要一些面向对象编程方面的帮助。我有一个学校项目,我正在与Unity制作2D平台游戏。我必须创建一个基类和两个继承它的子类。我必须使用构造函数,属性等。



问题是我知道构造函数,属性等做了什么,但我不知道如何将它们组合在一起制作游戏。



有人可以帮助我,让我走向正确的方向因为现在我不知道从哪里开始。



我喜欢做的是一个敌人基类,有两个子类(敌人1和敌人2)或基类物品(一类硬币或电源),有两个子类(第1项和第2项)。



我不会要求完成的脚本,而是可以帮助我制作或提供提示或其他内容的人。



如果有人可以提供帮助我会非常感激。



(我在C#编程并且游戏必须在Unity中制作。

对不起,如果这不是问这样的事情的正确的地方。



谢谢

Cynni

Hi people,

My name is Cynthia and I need some help with Object-oriented programming. I have a project for school where I'am making a 2D platformer game with Unity. Where I have to make a base class and two child classes that inherits from it. I have to work with constructors, properties, etc .

The problem is I kinda know what the constructors, properties etc do but I don't know how to put them together to make a game.

Can someone help me, push me into the right direction cause now I don't know where to begin with.

What I like to make is a Enemy base class with two sub classes (enemy 1 and enemy 2) or base class Item (sort of coins or power ups) with two sub classes (item 1 and item 2).

I don't ask for a finished script but someone who can help me making it or giving tips or something.

If there is someone who can help I would be so grateful.

(I program in C# and the game must be made in Unity).
Sorry if this is not the right place for asking such a thing.

Thanks
Cynni

推荐答案

参见 https://msdn.microsoft.com/en-gb/library/ms173152(v = vs.80).aspx [ ^ ],https://msdn.microsoft.com/en-gb/library/ms173149(v=vs.110).aspx [ ^ ],继承介绍,C#中的多态性 [ ^ ]等
See https://msdn.microsoft.com/en-gb/library/ms173152(v=vs.80).aspx[^], https://msdn.microsoft.com/en-gb/library/ms173149(v=vs.110).aspx[^], Introduction to inheritance, polymorphism in C#[^], etc.


这篇关于Unity中面向对象的编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆