From 40a2cbb83c4d0485ed52d4d87db78bb3c0e3fcbb Mon Sep 17 00:00:00 2001 From: River Jiang <546213258@qq.com> Date: Wed, 21 Oct 2020 19:35:55 +0800 Subject: [PATCH] 隐藏子弹条. --- Assets/Scripts/TowerDefense/UI/BulletUICtl.cs | 4 + Assets/Scripts/TowerDefense/Affectors/AttackAffector.cs | 39 +++++++++++++++++++ Assets/Scripts/TowerDefense/Towers/Tower.cs | 6 ++- Assets/Scripts/ActionGameFramework/Health/Damager.cs | 16 +++++++ Assets/Scripts/TowerDefense/Towers/TowerLaunchers/BallisticLauncher.cs | 1 5 files changed, 60 insertions(+), 6 deletions(-) diff --git a/Assets/Scripts/ActionGameFramework/Health/Damager.cs b/Assets/Scripts/ActionGameFramework/Health/Damager.cs index a5861ce..585b6d7 100644 --- a/Assets/Scripts/ActionGameFramework/Health/Damager.cs +++ b/Assets/Scripts/ActionGameFramework/Health/Damager.cs @@ -18,6 +18,11 @@ public float damage; /// <summary> + /// 用于最后一颗子弹的多倍攻击 + /// </summary> + public float damageMulti = 1.0f; + + /// <summary> /// TEST CODE TO TOWER_NAME /// </summary> public string towerName = ""; @@ -105,7 +110,16 @@ /// </summary> public float finalDamage { - get { return damage + inSceneUpGradeDamage; } + + + get { + float fd = damage * damageMulti; + if (damageMulti > 1.0f) + Debug.Log("hello,world:" + damageMulti.ToString() ); + + damageMulti = 1.0f; + return fd + inSceneUpGradeDamage; + } } /// <summary> diff --git a/Assets/Scripts/TowerDefense/Affectors/AttackAffector.cs b/Assets/Scripts/TowerDefense/Affectors/AttackAffector.cs index 43013f7..c7c1430 100644 --- a/Assets/Scripts/TowerDefense/Affectors/AttackAffector.cs +++ b/Assets/Scripts/TowerDefense/Affectors/AttackAffector.cs @@ -101,6 +101,12 @@ /// </summary> protected Targetable m_TrackingEnemy; + + /// <summary> + /// 处理装弹时间. + /// </summary> + protected float fillBulletTime = 0.0f; + /// <summary> /// Gets the search rate from the targetter /// </summary> @@ -223,6 +229,23 @@ /// </summary> protected virtual void Update() { + // + // 预留出来装填子弹的时间. + if( fillBulletTime > 0 ) + { + fillBulletTime -= Time.deltaTime; + if (fillBulletTime <= 0.3f) + { + if (towerPtr && towerPtr.bulletCtl) + towerPtr.bulletCtl.resetToMaxBullet(); + } + + if (fillBulletTime <= 0) + { + fillBulletTime = 0; + } + } + m_FireTimer -= Time.deltaTime; if( trackingEnemy == null ) m_TrackingEnemy = targetter.GetTarget(waveLineID, bWoodAffector); @@ -258,7 +281,7 @@ // 不再处理多子弹攻击,确保只有一个弹道 isMultiAttack = false; m_TrackingEnemy = targetter.GetTarget( waveLineID, bWoodAffector ); - if (m_TrackingEnemy == null) + if ( (m_TrackingEnemy == null) || (fillBulletTime>0) ) { if (this.towerPtr) towerPtr.setTowerState(false); @@ -269,6 +292,20 @@ towerPtr.setTowerState(true); } + // + // 处理子弹充能相关的内容 + if( towerPtr && (towerPtr.bulletCtl != null)) + { + int bnum = towerPtr.bulletCtl.decBullet(); + // + if (bnum == 0) + { + damagerProjectile.damageMulti = 2.0f; + Debug.Log("设置DamgeMult 2.0"); + fillBulletTime = 2.0f; + } + } + if (isMultiAttack) { List<Targetable> enemies = towerTargetter.GetAllTargets(); diff --git a/Assets/Scripts/TowerDefense/Towers/Tower.cs b/Assets/Scripts/TowerDefense/Towers/Tower.cs index 8e07dbb..4aa7604 100644 --- a/Assets/Scripts/TowerDefense/Towers/Tower.cs +++ b/Assets/Scripts/TowerDefense/Towers/Tower.cs @@ -72,7 +72,7 @@ /// 塔防对应的充能状态. /// </summary> public ETowerFuntion eTowerFuntion = ETowerFuntion.NULL; - protected BulletUICtl bulletCtl = null; + public BulletUICtl bulletCtl = null; /// <summary> /// The tower levels associated with this tower @@ -115,6 +115,7 @@ /// 攻击增加 /// </summary> public float attackRise { get; set; } + /// <summary> /// 塔防数据的局内升级 @@ -200,12 +201,13 @@ if (this.eTowerFuntion == ETowerFuntion.BULLET) { BulletUICtl buc = this.placementArea.GetBulletUICtl(gridPosition.x); + /* if (buc) { buc.gameObject.SetActive(true); this.bulletCtl = buc; buc.resetToMaxBullet(); - } + }*/ } } diff --git a/Assets/Scripts/TowerDefense/Towers/TowerLaunchers/BallisticLauncher.cs b/Assets/Scripts/TowerDefense/Towers/TowerLaunchers/BallisticLauncher.cs index 7f8db62..a4fc5da 100644 --- a/Assets/Scripts/TowerDefense/Towers/TowerLaunchers/BallisticLauncher.cs +++ b/Assets/Scripts/TowerDefense/Towers/TowerLaunchers/BallisticLauncher.cs @@ -37,7 +37,6 @@ DestroyImmediate(projectile); return; } - ballisticProjectile.FireAtPoint(startPosition, enemy.position); if (fireParticleObj != null) diff --git a/Assets/Scripts/TowerDefense/UI/BulletUICtl.cs b/Assets/Scripts/TowerDefense/UI/BulletUICtl.cs index 114c314..0e7f4ff 100644 --- a/Assets/Scripts/TowerDefense/UI/BulletUICtl.cs +++ b/Assets/Scripts/TowerDefense/UI/BulletUICtl.cs @@ -1,4 +1,5 @@ using DG.Tweening; +using Protobuf; using System.Collections; using System.Collections.Generic; using UnityEngine; @@ -31,10 +32,11 @@ /// </summary> public void resetToMaxBullet() { + if (this.curBulletNum == maxBulletNum) return; + this.curBulletNum = maxBulletNum; this.updateBulletUI(curBulletNum, maxBulletNum); } - /// <summary> /// 减少子弹,返回减少后的子弹数目。 -- Gitblit v1.9.1