Esempio n. 1
0
        private void Die(Bio killer)
        {
            this._script?.Call(Script.S_ON_ENTITY_DIE);

            killer?.OnKillTarget(this);

            int count = this._buffStates.Count;

            for (int i = 0; i < count; i++)
            {
                this._buffStates[i].OnDie(killer);
            }

            while (this._buffStates.Count > 0)
            {
                this.DestroyBuffStateImmediately(this._buffStates[0]);
            }

            this.UpdateVelocity(Vec3.zero);

            this.sensorySystem.Clear();

            this.property.Add(Attr.Gold, -this.goldBountyAwarded);

            SyncEventHelper.ChangeState(this.rid, FSMStateType.Dead);
            this.ChangeState(FSMStateType.Dead);

            this.brain.Rearbitrate();
            this.brain.enable = false;

            SyncEventHelper.EntityDie(this.rid, killer == null ? string.Empty : killer.rid);
        }
Esempio n. 2
0
        public static bool CheckCampType(Bio self, CampType campType, Bio target)
        {
            if ((campType & CampType.Self) > 0 &&
                target == self)
            {
                return(true);
            }

            if ((campType & CampType.Allied) > 0 &&
                target.property.team == self.property.team &&
                target != self)
            {
                return(true);
            }

            if ((campType & CampType.Hostile) > 0 &&
                target.property.team != self.property.team && target.property.team != 2)
            {
                return(true);
            }

            if ((campType & CampType.Neutral) > 0 &&
                target.property.team == 2)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 3
0
        public void UseSkill(Skill skill, Bio target, Vec3 targetPoint)
        {
            if (!this.CanUseSkill(skill))
            {
                LLogger.Log("skill:{0} can not use.", skill.id);
                return;
            }

            if (skill.castType == CastType.Target &&
                (target == null || target.isDead))
            {
                return;
            }

            switch (skill.castType)
            {
            case CastType.Target:
            case CastType.Point:
                this.Pursue(skill, target, skill.castType == CastType.Immediately ? this.property.position : targetPoint);
                break;

            case CastType.Immediately:
            case CastType.Dash:
                this.Attack(skill, target, skill.castType == CastType.Immediately ? this.property.position : targetPoint);
                break;
            }
        }
Esempio n. 4
0
 public static bool CanAttack(Bio attacker, Bio target, CampType campType, EntityFlag targetFlag)
 {
     return(!target.isDead &&
            target.property.stealth <= 0 &&                 //不在隐身状态下
            CheckCampType(attacker, campType, target) &&
            CheckTargetFlag(targetFlag, target));
 }
Esempio n. 5
0
        public static Bio GetNearestTarget(List <Entity> entities, Bio self, float radius, CampType campType, EntityFlag targetFlag)
        {
            GetEntitiesInCircle(entities, self.property.position, radius, ref _temp);

            float minDistance = float.MaxValue;
            Bio   nearest     = null;
            int   count       = _temp.Count;

            for (int i = 0; i < count; i++)
            {
                Bio target = _temp[i] as Bio;
                if (target == null || !CanAttack(self, target, campType, targetFlag))
                {
                    continue;
                }

                float d = (self.property.position - target.property.position).SqrMagnitude();
                if (d < minDistance)
                {
                    minDistance = d;
                    nearest     = target;
                }
            }

            _temp.Clear();
            return(nearest);
        }
Esempio n. 6
0
 public void AddHitter(Bio hitter)
 {
     if (!this._hitters.ContainsKey(hitter))
     {
         hitter.AddRef();
     }
     this._hitters[hitter] = this._owner.battle.time;
 }
Esempio n. 7
0
 public void AddAttacaker(Bio attacker)
 {
     if (!this._attackers.ContainsKey(attacker))
     {
         attacker.AddRef();
     }
     this._attackers[attacker] = this._owner.battle.time;
 }
Esempio n. 8
0
        internal virtual void OnHurt(Buff buff, Bio attacker, float damage)
        {
            int count = this._buffStates.Count;

            for (int i = 0; i < count; i++)
            {
                this._buffStates[i].OnHurt(buff, attacker, damage);
            }
        }
Esempio n. 9
0
        internal virtual void OnDamage(Buff buff, Bio target, float damage)
        {
            int count = this._buffStates.Count;

            for (int i = 0; i < count; i++)
            {
                this._buffStates[i].OnDamage(buff, target, damage);
            }
        }
Esempio n. 10
0
        protected override void InternalOnRemoveFromBattle()
        {
            this._target?.RedRef();
            this._target = null;

            this._caster.RedRef();
            this._caster = null;

            base.InternalOnRemoveFromBattle();
        }
Esempio n. 11
0
        protected override void InternalOnRemoveFromBattle()
        {
            this.fsm.Stop();

            this._skillId  = string.Empty;
            this._skillLvl = 0;

            this.caster.RedRef();
            this.caster = null;
            this.target?.RedRef();
            this.target = null;
        }
Esempio n. 12
0
        internal void Emmit(string skillId, int lvl, Bio caster, Bio target, Vec3 targetPoint)
        {
            this._skillId    = skillId;
            this._skillLvl   = lvl;
            this.caster      = caster;
            this.target      = target;
            this.targetPoint = targetPoint;

            this.caster.AddRef();
            this.target?.AddRef();

            this.ChangeState(FSMStateType.Move, false, (LMissileMove.MoveCompleteHander) this.OnMoveComplete);
        }
Esempio n. 13
0
        internal void Setup(int lvl, Bio caster, float distance)
        {
            this.skills[0].ApplyLevel(lvl);

            LFoxFireIdle idleAction = this.fsm[FSMStateType.Idle].GetAction <LFoxFireIdle>();

            idleAction.caster     = caster;
            idleAction.distance   = distance;
            idleAction.angleSpeed = Quat.Euler(0f, this.battle.random.NextFloat(this.angleSpeed, this.angleSpeed2), 0f);

            this._caster = caster;
            this._caster.AddRef();
        }
Esempio n. 14
0
 public void Clear()
 {
     this.killer = null;
     foreach (KeyValuePair <Bio, float> kv in this._hitters)
     {
         kv.Key.RedRef();
     }
     this._hitters.Clear();
     foreach (KeyValuePair <Bio, float> kv in this._attackers)
     {
         kv.Key.RedRef();
     }
     this._attackers.Clear();
 }
Esempio n. 15
0
        public void Update(UpdateContext context)
        {
            float time = this._owner.battle.time;

            if (time < this._nextUpdateTime)
            {
                return;
            }

            this._nextUpdateTime = time + UPDATE_INTERVAL;

            foreach (KeyValuePair <Bio, float> kv in this._attackers)
            {
                Bio bio = kv.Key;
                if (bio.isDead || time > kv.Value + EXPRIE_TIME)
                {
                    this._temp.Add(bio);
                }
            }
            int count = this._temp.Count;

            for (int i = 0; i < count; i++)
            {
                this.RemoveAttacker(this._temp[i]);
            }
            this._temp.Clear();

            foreach (KeyValuePair <Bio, float> kv in this._hitters)
            {
                Bio bio = kv.Key;
                if (bio.isDead || time > kv.Value + EXPRIE_TIME)
                {
                    this._temp.Add(bio);
                }
            }

            count = this._temp.Count;
            for (int i = 0; i < count; i++)
            {
                this.RemoveHitter(this._temp[i]);
            }
            this._temp.Clear();

            ListPool <Bio> .Release(this._temp);
        }
Esempio n. 16
0
        private void OnKillTarget(Bio target)
        {
            int count = this._buffStates.Count;

            for (int i = 0; i < count; i++)
            {
                this._buffStates[i].OnKill(target);
            }

            this.property.Add(Attr.Gold, target.goldBountyAwarded);
            this.property.Add(Attr.Exp, target.expBountyAwarded);

            while (this.property.exp >= this.upgradeExpNeeded)
            {
                this.Upgrade();
                //todo 重新计算属性
            }
        }
Esempio n. 17
0
        public static void FilterTarget(Bio self, CampType campType, EntityFlag targetFlag, ref List <Entity> targets, ref List <Entity> results)
        {
            int count = targets.Count;

            for (int i = 0; i < count; i++)
            {
                Bio target = targets[i] as Bio;
                if (target == null || target.isDead)
                {
                    continue;
                }

                //作为buff选择范围来进行筛选,隐身等状态应该被选中,因此这里不能使用CanAttack方法
                if (CheckCampType(self, campType, target) &&
                    CheckTargetFlag(targetFlag, target))
                {
                    results.Add(target);
                }
            }
        }
Esempio n. 18
0
        public static bool CheckTargetFlag(EntityFlag targetFlag, Bio target)
        {
            if ((targetFlag & EntityFlag.Hero) > 0 &&
                (target.flag & EntityFlag.Hero) > 0)
            {
                return(true);
            }

            if ((targetFlag & EntityFlag.SmallPotato) > 0 &&
                (target.flag & EntityFlag.SmallPotato) > 0)
            {
                return(true);
            }

            if ((targetFlag & EntityFlag.Structure) > 0 &&
                (target.flag & EntityFlag.Structure) > 0)
            {
                return(true);
            }

            if ((targetFlag & EntityFlag.Missile) > 0 &&
                (target.flag & EntityFlag.Missile) > 0)
            {
                return(true);
            }

            if ((targetFlag & EntityFlag.Effect) > 0 &&
                (target.flag & EntityFlag.Effect) > 0)
            {
                return(true);
            }

            if ((targetFlag & EntityFlag.Item) > 0 &&
                (target.flag & EntityFlag.Item) > 0)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 19
0
 public SensorySystem(Bio owner)
 {
     this._owner = owner;
 }
Esempio n. 20
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);
        }
Esempio n. 21
0
 public void Attack(Skill skill, Bio target, Vec3 targetPoint)
 {
     SyncEventHelper.ChangeState(this.rid, FSMStateType.Attack, true, skill.id, target == null ? string.Empty : target.rid, targetPoint);
     this.ChangeState(FSMStateType.Attack, true, skill, target, targetPoint);
 }
Esempio n. 22
0
 public void Pursue(Skill skill, Bio target, Vec3 targetPoint)
 {
     SyncEventHelper.ChangeState(this.rid, FSMStateType.Pursue, true);
     this.ChangeState(FSMStateType.Pursue, true, skill, target, targetPoint);
 }
Esempio n. 23
0
 public void Track(Bio target)
 {
     SyncEventHelper.ChangeState(this.rid, FSMStateType.Track, true);
     this.ChangeState(FSMStateType.Track, true, target);
 }
Esempio n. 24
0
 public void Dispose()
 {
     this._owner = null;
 }
Esempio n. 25
0
 private bool RemoveAttacker(Bio attacker)
 {
     attacker.RedRef();
     return(this._attackers.Remove(attacker));
 }
Esempio n. 26
0
 private bool RemoveHitter(Bio hitter)
 {
     hitter.RedRef();
     return(this._hitters.Remove(hitter));
 }
Esempio n. 27
0
 internal void Emmit(Bio target)
 {
     this._target = target;
     this._target.AddRef();
     this.fsm.ChangeState(FSMStateType.Move, false, target, (LFoxFireMove.MoveCompleteHander) this.OnMoveComplete);
 }