示例#1
0
 public void ApplyAggroBuff(BuffEventData data)
 {
     if (data.BuffObj.BuffData.ContainsKey("originator"))
     {
         Buff             buffObj     = data.BuffObj;
         SmartEntity      smartEntity = (SmartEntity)buffObj.BuffData["originator"];
         ShooterComponent shooterComp = data.Target.ShooterComp;
         if (data.Target.TurretShooterComp == null && shooterComp == null)
         {
             return;
         }
         if (smartEntity == null)
         {
             return;
         }
         if (smartEntity.HealthComp == null)
         {
             return;
         }
         if (smartEntity.HealthComp.IsDead())
         {
             return;
         }
         int squaredDistanceToTarget = GameUtils.GetSquaredDistanceToTarget(shooterComp, smartEntity);
         if ((long)squaredDistanceToTarget > (long)((ulong)shooterComp.MaxAttackRangeSquared) || (long)squaredDistanceToTarget <= (long)((ulong)shooterComp.MinAttackRangeSquared))
         {
             return;
         }
         this.InvalidateCurrentTarget(data.Target);
         this.UpdateShooterTarget(true, data.Target, smartEntity);
     }
 }
示例#2
0
        public EatResponse OnEvent(EventId id, object cookie)
        {
            BuffEventData buffEventData = (BuffEventData)cookie;

            Service.Logger.DebugFormat("Buff proc: {0}", new object[]
            {
                buffEventData.BuffObj.BuffType.Uid
            });
            if (buffEventData.BuffObj.BuffType.Modify != BuffModify.Aggro)
            {
                return(EatResponse.NotEaten);
            }
            if (id != EventId.ProcBuff)
            {
                if (id == EventId.RemovingBuff)
                {
                    this.RemoveAggroBuff(buffEventData);
                }
            }
            else
            {
                this.ApplyAggroBuff(buffEventData);
            }
            return(EatResponse.NotEaten);
        }
示例#3
0
        private void SendBuffEvent(EventId id, Buff buff)
        {
            SmartEntity   target = (SmartEntity)this.Entity;
            BuffEventData cookie = new BuffEventData(buff, target);

            Service.EventManager.SendEvent(id, cookie);
        }
示例#4
0
 public EatResponse OnEvent(EventId id, object cookie)
 {
     if (id == EventId.ProcBuff)
     {
         BuffEventData buffEventData = (BuffEventData)cookie;
         this.ProcBuffOnTarget(buffEventData.BuffObj, buffEventData.Target);
     }
     return(EatResponse.NotEaten);
 }
示例#5
0
 public EatResponse OnEvent(EventId id, object cookie)
 {
     if (id != EventId.ProcBuff)
     {
         if (id != EventId.EntityKilled)
         {
             if (id == EventId.GameStateChanged)
             {
                 IState currentState = Service.GameStateMachine.CurrentState;
                 if (currentState is BattleStartState || currentState is BattlePlaybackState)
                 {
                     this.BattleInit();
                 }
             }
         }
         else
         {
             SmartEntity key = cookie as SmartEntity;
             if (this.visitorExecution.ContainsKey(key))
             {
                 List <SmartEntity> list = this.visitorExecution[key];
                 if (list != null)
                 {
                     for (int i = 0; i < list.Count; i++)
                     {
                         Service.HealthController.KillEntity(list[i]);
                     }
                 }
                 this.visitorExecution.Remove(key);
             }
         }
     }
     else
     {
         BuffEventData buffEventData = (BuffEventData)cookie;
         if (buffEventData.BuffObj.BuffType.Modify != BuffModify.Summon)
         {
             return(EatResponse.NotEaten);
         }
         this.HandleSummon(buffEventData);
     }
     return(EatResponse.NotEaten);
 }
示例#6
0
        public EatResponse OnEvent(EventId id, object cookie)
        {
            BuffEventData buffEventData = (BuffEventData)cookie;

            if (buffEventData.BuffObj.BuffType.Modify != BuffModify.Stun)
            {
                return(EatResponse.NotEaten);
            }
            AttackFSM attackFSM = null;

            if (buffEventData.Target.ShooterComp != null)
            {
                attackFSM = buffEventData.Target.ShooterComp.AttackFSM;
            }
            if (attackFSM != null)
            {
                attackFSM.Stun(buffEventData.BuffObj.BuffType.Duration);
            }
            return(EatResponse.NotEaten);
        }
示例#7
0
        public EatResponse OnEvent(EventId id, object cookie)
        {
            switch (id)
            {
            case EventId.EntityHit:
                this.ApplyBuffFromBullet((Bullet)cookie);
                return(EatResponse.NotEaten);

            case EventId.EntityHealthChanged:
            case EventId.EntityHitByBeam:
            {
IL_1D:
                if (id == EventId.TroopAbilityActivate)
                {
                    this.AddTroopAbilitySelfBuff((SmartEntity)cookie);
                    return(EatResponse.NotEaten);
                }
                if (id == EventId.TroopAbilityDeactivate)
                {
                    this.RemoveTroopAbilitySelfBuff((SmartEntity)cookie);
                    return(EatResponse.NotEaten);
                }
                if (id == EventId.BuildingPlacedOnBoard)
                {
                    SmartEntity entity = cookie as SmartEntity;
                    this.ApplyEntityWarBuffs(entity);
                    this.ApplyBuildingEquipmentBuffs(entity);
                    return(EatResponse.NotEaten);
                }
                if (id == EventId.TroopPlacedOnBoard)
                {
                    SmartEntity smartEntity = cookie as SmartEntity;
                    this.AddBuffsOnSpawn(smartEntity);
                    this.ApplyEntityWarBuffs(smartEntity);
                    this.ApplyTroopEquipmentBuffs(smartEntity);
                    return(EatResponse.NotEaten);
                }
                if (id == EventId.SpecialAttackSpawned)
                {
                    SpecialAttack specialAttack = cookie as SpecialAttack;
                    this.ApplySpecialAttackWarBuffs(specialAttack);
                    this.ApplySpecialAttackEquipmentBuffs(specialAttack);
                    return(EatResponse.NotEaten);
                }
                if (id == EventId.BattleLoadedForDefend)
                {
                    this.ApplyEquipmentBuffsToExistingBuildings();
                    this.RemoveAllEquipmentBuffShader(GameConstants.EQUIPMENT_SHADER_DELAY_DEFENSE);
                    return(EatResponse.NotEaten);
                }
                if (id != EventId.EquipmentBuffShaderRemove)
                {
                    return(EatResponse.NotEaten);
                }
                int timeDelayInMS = (int)cookie;
                this.RemoveAllEquipmentBuffShader(timeDelayInMS);
                return(EatResponse.NotEaten);
            }

            case EventId.AddedBuff:
            {
                BuffEventData buffEventData = (BuffEventData)cookie;
                this.OnAddedBuff(buffEventData.BuffObj, buffEventData.Target);
                return(EatResponse.NotEaten);
            }

            case EventId.RemovingBuff:
            {
                BuffEventData buffEventData = (BuffEventData)cookie;
                this.OnRemovingBuff(buffEventData.BuffObj, buffEventData.Target);
                return(EatResponse.NotEaten);
            }
            }
            goto IL_1D;
        }
示例#8
0
 public void RemoveAggroBuff(BuffEventData data)
 {
     this.InvalidateCurrentTarget(data.Target);
 }
示例#9
0
        private void HandleSummon(BuffEventData data)
        {
            SummonDetailsVO summonDetailsVO = (SummonDetailsVO)data.BuffObj.Details;

            if (data.BuffObj.ProcCount > summonDetailsVO.MaxProc)
            {
                return;
            }
            if (this.numSummons >= GameConstants.MAX_SUMMONS_PER_BATTLE)
            {
                return;
            }
            List <SmartEntity> list;
            bool flag = this.visitorExecution.TryGetValue(data.Target, out list);

            if (list == null)
            {
                list = new List <SmartEntity>();
            }
            if (summonDetailsVO.VisitorUids == null || summonDetailsVO.VisitorUids.Length == 0)
            {
                Service.Logger.WarnFormat("No visitor uid for buff {0}", new object[]
                {
                    summonDetailsVO.Uid
                });
                return;
            }
            int                num  = (data.BuffObj.ProcCount - 1) % summonDetailsVO.VisitorUids.Length;
            string             text = summonDetailsVO.VisitorUids[num];
            TransformComponent transformComponent = data.Target.Get <TransformComponent>();
            TeamType           teamType           = data.Target.TeamComp.TeamType;

            if (!summonDetailsVO.SameTeam)
            {
                teamType = ((data.Target.TeamComp.TeamType != TeamType.Attacker) ? TeamType.Attacker : TeamType.Defender);
            }
            SmartEntity smartEntity = null;

            if (summonDetailsVO.VisitorType == VisitorType.Troop)
            {
                int         num2        = (data.BuffObj.ProcCount - 1) % summonDetailsVO.SpawnPoints.Length;
                Vector3     offset      = summonDetailsVO.SpawnPoints[num2];
                TroopTypeVO troopTypeVO = Service.StaticDataController.Get <TroopTypeVO>(text);
                IntPosition boardPosition;
                bool        flag2             = this.VerifyBoardPosition(transformComponent, offset, transformComponent.Rotation, troopTypeVO.SizeX, teamType, out boardPosition);
                bool        forceAllow        = !flag2;
                int         randomSpawnRadius = summonDetailsVO.RandomSpawnRadius;
                if (troopTypeVO.Type == TroopType.Phantom && randomSpawnRadius > 0)
                {
                    forceAllow = true;
                    BattleController battleController = Service.BattleController;
                    RandSimSeed      simSeed          = Service.Rand.SimSeed;
                    int num3 = (int)((battleController.Now + simSeed.SimSeedA) % (uint)randomSpawnRadius);
                    int num4 = (int)((battleController.Now + simSeed.SimSeedB) % (uint)randomSpawnRadius);
                    if (num3 % 2 == 0)
                    {
                        num3 *= -1;
                    }
                    if (num4 % 2 == 1)
                    {
                        num4 *= -1;
                    }
                    boardPosition.x = Mathf.Clamp(boardPosition.x + num3, -23, 23);
                    boardPosition.z = Mathf.Clamp(boardPosition.z + num4, -23, 23);
                }
                smartEntity = Service.TroopController.SpawnTroop(troopTypeVO, teamType, boardPosition, TroopSpawnMode.Unleashed, true, forceAllow, summonDetailsVO.VisitorType);
                if (smartEntity == null)
                {
                    Service.Logger.WarnFormat("could not spawn troop visitor {0} for buff {1}", new object[]
                    {
                        text,
                        summonDetailsVO.Uid
                    });
                }
                else
                {
                    this.numSummons++;
                }
            }
            else if (summonDetailsVO.VisitorType == VisitorType.SpecialAttack)
            {
                Vector3 zero = Vector3.zero;
                zero.x = Units.BoardToWorldX(transformComponent.X);
                zero.z = Units.BoardToWorldX(transformComponent.Z);
                SpecialAttackTypeVO specialAttackType = Service.StaticDataController.Get <SpecialAttackTypeVO>(text);
                if (Service.SpecialAttackController.DeploySpecialAttack(specialAttackType, teamType, zero) == null)
                {
                    Service.Logger.WarnFormat("could not spawn special attack {0} for buff {1}", new object[]
                    {
                        text,
                        summonDetailsVO.Uid
                    });
                }
                else
                {
                    this.AddVisitorToValidate(data.BuffObj.BuffType, text, 1);
                }
            }
            else
            {
                Service.Logger.WarnFormat("Unhandled visitor type {0} for {1}", new object[]
                {
                    summonDetailsVO.VisitorType,
                    summonDetailsVO.Uid
                });
            }
            if (smartEntity != null)
            {
                if (summonDetailsVO.DieWithSummoner)
                {
                    list.Add(smartEntity);
                    if (!flag)
                    {
                        this.visitorExecution[data.Target] = list;
                    }
                }
                if (summonDetailsVO.TargetSummoner && smartEntity.ShooterComp != null)
                {
                    smartEntity.ShooterComp.Target = data.Target;
                }
                this.AddVisitorToValidate(data.BuffObj.BuffType, text, 1);
            }
        }