private void ConstructDefenseObject(BattleDefenseObjectParameter param) { PropsConfigData configData = ConfigInterface.Instance.PropsConfigHelper.GetPropsData(param.PropsType); PropsDefenseScopeConfigData defenseData = configData.FunctionConfigData as PropsDefenseScopeConfigData; PropsDefenseScopeLastingConfigData lastingData = configData.FunctionConfigData as PropsDefenseScopeLastingConfigData; DefenseObjectConfigWrapper configWrapper = new DefenseObjectConfigWrapper(configData.FunctionConfigData); GameObject defenseObjectPrefab = Resources.Load(ClientStringConstants.BATTLE_SCENE_RESOURCE_PREFAB_PREFIX_NAME + ClientStringConstants.DEFENSE_OBJECT_PREFAB_PREFIX_NAME + configWrapper.PrefabName) as GameObject; GameObject defenseObject = GameObject.Instantiate(defenseObjectPrefab) as GameObject; defenseObject.transform.position = PositionConvertor.GetWorldPositionFromBuildingTileIndex (new TilePosition(param.PositionColumn, param.PositionRow)); DefenseObjectAI ai = defenseObject.GetComponent <DefenseObjectAI>(); ai.enabled = false; DefenseObjectPropertyBehavior property = defenseObject.GetComponent <DefenseObjectPropertyBehavior>(); property.DefenseObjectID = param.DefenseObjectID; property.BuildingPosition = new TilePosition(param.PositionColumn, param.PositionRow); property.ActorObstacleList = new List <TilePosition>(); property.BuildingObstacleList = new List <TilePosition>(); if (defenseData != null) { BombBehavior bomb = defenseObject.GetComponent <BombBehavior>(); bomb.AttackCategory = defenseData.AttackCategory; bomb.Damage = defenseData.Damage; bomb.PushVelocity = defenseData.PushVelocity; bomb.PushTicks = defenseData.PushTicks; bomb.Scope = defenseData.Scope; bomb.TriggerScope = defenseData.TriggerScope; bomb.TriggerTick = defenseData.TriggerTicks; bomb.TargetType = (TargetType)defenseData.TargetType; bomb.ParentNode = this.m_BulletParent; } else if (lastingData != null) { LastingEffectBehavior lasting = defenseObject.GetComponent <LastingEffectBehavior>(); lasting.AttackCategory = lastingData.AttackCategory; lasting.Damage = lastingData.Damage; lasting.IntervalTicks = lastingData.IntervalTicks; lasting.TotalTimes = lastingData.TotalTimes; lasting.Scope = lastingData.Scope; lasting.TriggerScope = lastingData.TriggerScope; lasting.TriggerTick = lastingData.TriggerTicks; lasting.TargetType = (TargetType)lastingData.TargetType; //lasting.ParentNode = this.m_ParentNode; } defenseObject.transform.parent = this.m_ParentNode; this.m_SceneHelper.ConstructDefenseObject(defenseObject); }
public override void AICalculate() { if (--this.m_CurrentTriggerCount == 0) { this.m_DefenseObjectBattleBehavior.Effect(); LastingEffectBehavior lastingEffect = this.m_DefenseObjectBattleBehavior as LastingEffectBehavior; if (lastingEffect != null && lastingEffect.CurrentTimes != lastingEffect.TotalTimes) { DefenseObjectLastingState lastingState = new DefenseObjectLastingState(this.m_AIBehavior, lastingEffect); this.m_AIBehavior.ChangeState(lastingState); } } }
public override void AICalculate() { if (this.m_AIBehavior.CanTakeResponse) { List <GameObject> targets = BattleSceneHelper.Instance.GetActors(this.m_DefenseObjectBattleBehavior.TriggerList, this.m_DefenseObjectBattleBehavior.TargetType); foreach (GameObject target in targets) { CharacterPropertyBehavior characterProperty = target.GetComponent <CharacterPropertyBehavior>(); if (characterProperty.CharacterType == CharacterType.Invader) { float distanceSqrt = Vector2.SqrMagnitude((Vector2)this.m_DefenseObjectBattleBehavior.Property.AnchorTransform.position - (Vector2)target.transform.position); if (distanceSqrt <= this.m_DefenseObjectBattleBehavior.TriggerScopeSqrt) { this.m_DefenseObjectBattleBehavior.DisplayTriggerAnimation(); if (Application.loadedLevelName.Equals(ClientStringConstants.BATTLE_SCENE_LEVEL_NAME)) { DefenseObjectPropertyBehavior property = this.m_AIBehavior.GetComponent <DefenseObjectPropertyBehavior>(); CommunicationUtility.Instance.TriggerDefenseObject(new TriggerDefenseObjectRequestParameter() { DefenseObjectID = property.DefenseObjectID, OperateTime = TimeTickRecorder.Instance.CurrentTimeTick - BattleDirector.Instance.MatchStartTick }); } if (this.m_DefenseObjectBattleBehavior.TriggerTick == 0) { this.m_DefenseObjectBattleBehavior.Effect(); LastingEffectBehavior lastingEffect = this.m_DefenseObjectBattleBehavior as LastingEffectBehavior; if (lastingEffect != null && lastingEffect.CurrentTimes != lastingEffect.TotalTimes) { DefenseObjectLastingState lastingState = new DefenseObjectLastingState(this.m_AIBehavior, lastingEffect); this.m_AIBehavior.ChangeState(lastingState); } AudioController.Play(this.m_DefenseObjectBattleBehavior.EffectSound); } else { DefenseObjectTriggerState triggerState = new DefenseObjectTriggerState(this.m_AIBehavior); this.m_AIBehavior.ChangeState(triggerState); } break; } } } } }
public DefenseObjectLastingState(NewAI aiBehavior, LastingEffectBehavior lastingEffectBehavior) : base(aiBehavior) { this.m_LastingEffectBehavior = lastingEffectBehavior; }