示例#1
0
        public Battle(BattleParams param, Navmesh navmesh, LuaEnv luaEnv)
        {
            this.rid  = param.id;
            this.data = ModelFactory.GetBattleData(Utils.GetIDFromRID(this.rid));

            this._luaEnv        = luaEnv;
            this._context       = new UpdateContext();
            this._entityManager = new EntityManager(this);
            this._buffManager   = new BuffManager(this);
            this._random        = new ConsistentRandom(param.rndSeed);
            this._pathManager   = new NavMeshProxy();
            this._timer0        = new TimeScheduler();
            this._pathManager.Create(navmesh);

            if (!string.IsNullOrEmpty(this.data.script))
            {
                this._script = new Script(this, this._luaEnv, this.data.script);
                this._script.Call(Script.S_ON_BATTLE_INITIALIZED);
            }

            this.CreatePlayers(param);

            foreach (KeyValuePair <string, BattleData.Structure> kv in this.data.structures)
            {
                BattleData.Structure def = this.data.structures[kv.Key];
                this.CreateBio(def.id, def.pos, def.dir, def.team);
            }

            foreach (KeyValuePair <string, BattleData.Neutral> kv in this.data.neutrals)
            {
                BattleData.Neutral def = this.data.neutrals[kv.Key];
                this.CreateBio(def.id, def.pos, def.dir, def.team);
            }
        }
示例#2
0
        private void CreatePlayers(BattleParams battleParams)
        {
            int count = battleParams.players.Length;

            for (int i = 0; i < count; i++)
            {
                BattleParams.Player player = battleParams.players[i];
                EntityParam         param  = new EntityParam();
                param.rid       = player.cid + "@" + player.id;
                param.uid       = player.id;
                param.position  = this.RandomPoint(this.data.bornPos1, this.data.bornRange);
                param.direction = this.data.bornDir1;
                param.team      = player.team;
                this._entityManager.CreateBio(param);
            }
        }
示例#3
0
 public Battle(BattleParams param)
 {
     this._data           = ModelFactory.GetMapData(Utils.GetIDFromRID(param.id));
     this._random         = new FPseudoRandom(param.rndSeed);
     this._buffManager    = new BuffManager(this);
     this._entityManager  = new EntityManager(this);
     this._context        = new UpdateContext();
     this._startCountDown = new StartCountDown(this, this._data.startCountDown);
     this._maze           = new Maze(this._random, this._data.scale, this._data.offset, this._data.row, this._data.col, this._data.startIndex,
                                     this._data.endIndex, this._data.startPointPlace);
     SyncEvent.GenMaze(this._maze.walkables, this._maze.startIndex, this._maze.endIndex);
     this.CreateRails();
     this.CreateTerminus();
     this.CreatePlayers(param.players);
     this._entityManager.SupplyItems();
 }