Beispiel #1
0
        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);
        }