コード例 #1
0
        internal void OnAddedToBattle(EntityParam param)
        {
            SyncEventHelper.SpawnEntity(this.GetType().Name, param);
            this._rid  = param.rid;
            this._data = ModelFactory.GetEntityData(Utils.GetIDFromRID(this._rid));
            this.property.Init(this._data);
            this.property.Equal(Attr.Position, param.position);
            this.property.Equal(Attr.Direction, param.direction);
            this.size          = this._data.size * this.property.scale;
            this.bornPosition  = param.position;
            this.bornDirection = param.direction;
            AIData[] aiDatas = this._data.aiDatas;
            if (aiDatas != null)
            {
                int count = aiDatas.Length;
                for (int i = 0; i < count; i++)
                {
                    this.CreateAIEvaluator(aiDatas[i]);
                }
            }

            this.InternalOnAddedToBattle(param);

            SyncEventHelper.EntityAttrInitialized(this.rid);

            if (!string.IsNullOrEmpty(this._data.script))
            {
                this._script = new Script(this, this.battle.luaEnv, this._data.script);
                this._script.Call(Script.S_ON_ENTITY_ADDED_TO_BATTLE);
            }
        }
コード例 #2
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);
            }
        }
コード例 #3
0
ファイル: Buff.cs プロジェクト: niuniuzhu/Lockstep
        internal void OnAddedToBattle(string rid, string skillId, int lvl, Bio caster, Bio target, Vec3 targetPoint)
        {
            SyncEventHelper.SpawnBuff(rid, skillId, lvl, caster.rid, target == null ? string.Empty : target.rid, targetPoint);
            this._rid       = rid;
            this._data      = ModelFactory.GetBuffData(Utils.GetIDFromRID(this._rid));
            this.skillData  = ModelFactory.GetSkillData(skillId);
            this.campType   = this._data.campType == 0 ? this.skillData.campType : this._data.campType;
            this.targetFlag = this._data.targetFlag == 0 ? this.skillData.targetFlag : this._data.targetFlag;
            this.rangeType  = this._data.rangeType == 0 ? this.skillData.rangeType : this._data.rangeType;
            this.caster     = caster;
            this.target     = target;
            if (this.target == null &&
                (this.campType & CampType.Self) > 0)
            {
                this.target = caster;
            }
            this.caster.AddRef();
            this.target?.AddRef();
            this.targetPoint = targetPoint;
            this.deadType    = this._data.deadType;

            if (this.target == null)
            {
                if (this.deadType == DeadType.WithMainTarget)
                {
                    LLogger.Error("Dead_type of the buff that has no target can not set to DeadType.WithMainTarget");
                }

                if (this.skillData.rangeType == RangeType.Single)
                {
                    LLogger.Error("Range_type of the buff that has no target can not set to RangeType.Single");
                }

                if (this.orbit == Orbit.FollowTarget)
                {
                    LLogger.Error("Orbit_type of the buff that has no target can not set to Orbit.FollowTarget");
                }
            }
            else
            {
                this.deadType = DeadType.WithMainTarget;
            }

            this.property.Init(this._data);
            this.ApplyLevel(lvl);
            targetPoint = this.target?.property.position ?? this.targetPoint;
            switch (this.spawnPoint)
            {
            case SpawnPoint.Target:
                this.property.Equal(Attr.Position, targetPoint);
                break;

            case SpawnPoint.Caster:
                this.property.Equal(Attr.Position, this.caster.property.position);
                break;
            }
            this.property.Equal(Attr.Direction, targetPoint == this.caster.property.position
                                                                                                                 ? this.caster.property.direction
                                                                                                                 : Vec3.Normalize(targetPoint - this.caster.property.position));

            SyncEventHelper.BuffAttrInitialized(this.rid);

            this._implement = BIBase.Create(this.id);
            this._implement.Init(this);
        }