| | |
| | | /// </summary> |
| | | public class Tower : Targetable |
| | | { |
| | | public static readonly int MAX_LEVEL = 4; |
| | | |
| | | /// <summary> |
| | | /// A generalised name common to a levels |
| | | /// </summary> |
| | |
| | | /// 是否是特色骰子,如果是,则选择一个Enum类型。 |
| | | /// </summary> |
| | | public EFeatureTower towerFeature = EFeatureTower.NULL; |
| | | |
| | | /// <summary> |
| | | /// 当前塔防对应的MonsterMaterial,自身和对方显示不同的Mat. |
| | | /// </summary> |
| | | public Material materialMonsterSelf; |
| | | |
| | | public Material materialMonsterOppo; |
| | | |
| | | /// <summary> |
| | | /// 塔防对应的充能状态. |
| | |
| | | /// <summary> |
| | | /// The tower levels associated with this tower |
| | | /// </summary> |
| | | public TowerLevel[] levels; |
| | | [SerializeField] |
| | | private TowerLevel towerLevel; |
| | | |
| | | public TowerLevel CurrentTowerLevel { get; private set; } |
| | | |
| | | /// <summary> |
| | | /// 当前塔防对应的AttributeID. |
| | | /// 精灵id,一一对应 elf_info表中的id,唯一的区分每一种精灵塔 |
| | | /// </summary> |
| | | public int attributeId; |
| | | |
| | | /// <summary> |
| | | /// 当前的Tower在游戏内UI界面上用到的Image数据,再以后应该是直接在表格内配置才合适 |
| | | /// </summary> |
| | | public Sprite uiImage; |
| | | public int ElfId; |
| | | |
| | | /// <summary> |
| | | /// The physics mask the tower searches on |
| | |
| | | public int currentLevel { get; protected set; } |
| | | |
| | | protected bool m_bInAttackMode = false; |
| | | |
| | | /// <summary> |
| | | /// 精英怪和Boss双倍伤害. |
| | | /// </summary> |
| | | public bool bDoubleHitElit = false; |
| | | |
| | | /// <summary> |
| | | /// Reference to the data of the current level |
| | | /// </summary> |
| | | public TowerLevel currentTowerLevel { get; protected set; } |
| | | |
| | | /// <summary> |
| | | /// 攻击增加 |
| | |
| | | /// </summary> |
| | | public Agent WoodAimAgent; |
| | | |
| | | /// <summary> |
| | | /// 塔防数据的局内升级 |
| | | /// </summary> |
| | | public int inSceneTowerLevel |
| | | { |
| | | get; set; |
| | | } |
| | | |
| | | public int uiProOffset |
| | | { |
| | | get { return progressOffset; } |
| | |
| | | /// <summary> |
| | | /// Gets whether the tower can level up anymore |
| | | /// </summary> |
| | | public bool isAtMaxLevel |
| | | public bool IsMaxLevel |
| | | { |
| | | get { return currentLevel == levels.Length - 1; } |
| | | get { return currentLevel == ElfUpgradeData.MaxTowerLevel - 1; } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | set |
| | | { |
| | | m_bInAttackMode = value; |
| | | currentTowerLevel.SetAffectorState(m_bInAttackMode, gridPosition.x); |
| | | currentTowerLevel.SetAttackState(value); |
| | | CurrentTowerLevel.SetAffectorState(m_bInAttackMode, gridPosition.x); |
| | | CurrentTowerLevel.SetAttackState(value); |
| | | |
| | | if (value) |
| | | { |
| | | if (opponentSide) |
| | | { |
| | | OpponentMgr.instance.SetTowerAttID(gridPosition.x, attributeId, currentLevel); |
| | | OpponentMgr.instance.SetTowerAttID(gridPosition.x, ElfId, currentLevel); |
| | | } |
| | | else |
| | | { |
| | | if (LevelManager.instanceExists) |
| | | { |
| | | LevelManager.instance.SetTowerAttID(gridPosition.x, attributeId, currentLevel); |
| | | LevelManager.instance.SetTowerAttID(gridPosition.x, ElfId, currentLevel); |
| | | WaveLineSelMgr.instance.attackTowerFixed(gridPosition.x); |
| | | } |
| | | else if (EndlessLevelManager.instanceExists) |
| | | { |
| | | EndlessLevelManager.instance.SetTowerAttID(gridPosition.x, attributeId, currentLevel); |
| | | EndlessLevelManager.instance.SetTowerAttID(gridPosition.x, ElfId, currentLevel); |
| | | EndlessWaveLineManager.instance.AttackTowerFixed(gridPosition.x, PlayWaveLineFlash); |
| | | } |
| | | } |
| | |
| | | /// </summary> |
| | | public void upGradeInSceneTL() |
| | | { |
| | | inSceneTowerLevel++; |
| | | |
| | | // cx test |
| | | // 设置攻击数据的加强,暂时是测试数据,后面需要读取表格数据处理: |
| | | float damageAdd = inSceneTowerLevel; |
| | | |
| | | Debug.Log("Upgrade Tower name is:" + name); |
| | | |
| | | // 播放相关的特效 |
| | | currentTowerLevel.PlayUpGradeEffect(); |
| | | CurrentTowerLevel.PlayUpGradeEffect(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | public TowerPlacementGhost towerGhostPrefab |
| | | { |
| | | get { return levels[currentLevel].towerGhostPrefab; } |
| | | get { return towerLevel.towerGhostPrefab; } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | // Invoke base kill method |
| | | Kill(); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// Used to (try to) upgrade the tower data |
| | | /// </summary> |
| | | public virtual bool UpgradeTower() |
| | | { |
| | | if (isAtMaxLevel) |
| | | if (IsMaxLevel) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | /// </returns> |
| | | public virtual bool UpgradeTowerToLevel(int level) |
| | | { |
| | | if (level < 0 || isAtMaxLevel || level >= levels.Length) |
| | | { |
| | | return false; |
| | | } |
| | | if (level < 0 || IsMaxLevel || level >= ElfUpgradeData.MaxTowerLevel) return false; |
| | | |
| | | SetLevel(level); |
| | | return true; |
| | | } |
| | |
| | | /// <summary> |
| | | /// Cache and update oftenly used data |
| | | /// </summary> |
| | | public void SetLevel(int level) |
| | | protected void SetLevel(int level) |
| | | { |
| | | if (level < 0 || level >= levels.Length) |
| | | { |
| | | return; |
| | | } |
| | | if (level < 0 || level >= ElfUpgradeData.MaxTowerLevel) return; |
| | | |
| | | currentLevel = level; |
| | | if (currentTowerLevel != null) |
| | | { |
| | | Destroy(currentTowerLevel.gameObject); |
| | | } |
| | | |
| | | // instantiate the visual representation |
| | | currentTowerLevel = Instantiate(levels[currentLevel], transform); |
| | | // cx test 不需要删除,直接刷新等级显示还有body的显示即可 |
| | | if (CurrentTowerLevel != null) |
| | | Destroy(CurrentTowerLevel.gameObject); |
| | | |
| | | // initialize TowerLevel |
| | | currentTowerLevel.Initialize(this, enemyLayerMask, configuration.alignmentProvider); |
| | | CurrentTowerLevel = Instantiate(towerLevel, transform); |
| | | CurrentTowerLevel.Initialize(this, enemyLayerMask, configuration.alignmentProvider); |
| | | CurrentTowerLevel.SetShowLevel(level + 1); |
| | | |
| | | // disable affectors |
| | | LevelState levelState = LevelState.Intro; |
| | |
| | | levelState = EndlessLevelManager.instance.EndlessLeveltate; |
| | | bool initialise = levelState == LevelState.AllEnemiesSpawned || levelState == LevelState.SpawningEnemies; |
| | | initialise = false; |
| | | currentTowerLevel.SetAffectorState(initialise, gridPosition.x); |
| | | CurrentTowerLevel.SetAffectorState(initialise, gridPosition.x); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | bool initialise = current == LevelState.AllEnemiesSpawned || current == LevelState.SpawningEnemies; |
| | | initialise = false; |
| | | //currentTowerLevel.SetAffectorState(initialise); |
| | | currentTowerLevel.SetAffectorState(bInAttackMode, gridPosition.x); |
| | | CurrentTowerLevel.SetAffectorState(bInAttackMode, gridPosition.x); |
| | | } |
| | | } |
| | | } |