Actionscript 3 制作一个基于回合的RPG游戏,一些关于结构的问题。动作脚本3

Actionscript 3 制作一个基于回合的RPG游戏,一些关于结构的问题。动作脚本3,actionscript-3,Actionscript 3,这里的第一个问题:)(“AS3”) 首先,如何从另一个类访问变量? 你看,我的“数据库”目前在一个类中,我需要访问它,比如说,我称之为“scene_battle”。编写此代码的最佳方法是什么?我希望得到正确的类变量,而不是实例变量,因为我甚至不需要这个类的实例,因为它只是一个数据库 第二,关于我的游戏的OOP结构的一个更一般的问题。现在是这样的, scene\u battle调用玩家和敌人。玩家和敌人从我的数据库中获取数据。基本上,我只是重复我的player类的一个实例,它将有一个基于游戏方的I

这里的第一个问题:)(“AS3”)

首先,如何从另一个类访问变量?
你看,我的“数据库”目前在一个类中,我需要访问它,比如说,我称之为“scene_battle”。编写此代码的最佳方法是什么?我希望得到正确的类变量,而不是实例变量,因为我甚至不需要这个类的实例,因为它只是一个数据库

第二,关于我的游戏的OOP结构的一个更一般的问题。现在是这样的,

scene\u battle
调用
玩家
敌人
。玩家和敌人从我的数据库中获取数据。基本上,我只是重复我的player类的一个实例,它将有一个基于游戏方的ID

如果你能给我一些关于代码的一般或有用的提示,比如封装一些东西,我将非常感激。先谢谢你

首先,如何从另一个类访问变量

-如果希望有一个通用类作为值的引用器,那么可以使用类的实例或静态类,两者都同样好

我希望得到正确的类变量,而不是 实例变量,因为我甚至不需要这个类的实例, 因为它只是一个数据库

——如果你要像在C++中那样得到一个指针,就不必担心,所有的对象都是指针,除非你使用新的关键字。 战斗召唤玩家和敌人。玩家和敌人从我的 数据库基本上,我只是重复我的player类的一个实例 它将有一个基于游戏方的ID

-我以前实现过回合制游戏,下面是我是如何实现的,请记住,这并不是最好的实现

BattleManager
    Members:
    -BattleScenario (this contains all the meta data for your battle scenario, teams, map location, any modifiers that are related to a battle)
    -Teams (this is a list of Team classes wich have players)
    -TeamSequence(this is a list of team wich will be populated from Teams and will control the flow of the battle)
    Functions:
    -StartBattle
    -EndBattle
    -GiveTeamTurn (this function gets the TeamSequence and calls ActTurn on the Class Team and removes the team from the TeamSequence list)
    -RepopulateTeamSequence(when the TeamSequence is empty this is called to repopulate the TeamSequence)

Team
    Members:
    -Players (this is a list of players)
    Functions:
    -ActTurn (this function calls a player that is still able to act during the turn, and tells him to act, this is where you prompt the user for actions or use your AI)
这只是一个大的行,他们的很多东西没有显示在这里,你必须实现。也要注意,很多回调都会被触发,例如,当玩家演完戏后,会回电话给他的团队,说本回合结束了,团队应该为团队的另一个成员调用ActTurn,直到完成为止,同样的情况也适用于团队,当团队中的每个玩家完成本回合任务后,将触发对battlemanager的回调

希望这有帮助,GL