| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 |
- using UnityEngine;
- using Sirenix.OdinInspector;
- using System.Collections.Generic;
- using System;
- using System.Linq;
- using TMPro;
- public class ConductController : MonoBehaviour
- {
- //组件
- private PlayerController playerController;
- private ConductManager conductManager;
- private GameManager gameManager;
- private SoldierLevelRecord soldierLevelRecord;
- [LabelText("品质")] public int[] rarity;
- public float[] conversionRate;
- public float[] totalCD;
- public float[] cd;
- [LabelText("融魂技")] public ConductSkills[] conductSkills;
- [Serializable] public struct Giant
- {
- public GameObject bigGiant;
- [LabelText("临时血量基数")]
- public int temptHp;
- [LabelText("临时血量持续时间")]
- public float temptTime;
- }
- private bool ShowGiant() => conductSkills.Contains(ConductSkills.Giant);
- [ShowIf("ShowGiant")][LabelText("合成大胖子参数")]
- public Giant giant;
- [Serializable]public struct Photon
- {
- public GameObject obj;
- [LabelText("血量基数")]
- public int photosphereHp;
- [DisplayOnly] public bool havePhoton;
- [HideInInspector] public Photosphere photosphere;
- }
- private bool ShowPhotosphere() => conductSkills.Contains(ConductSkills.Photon);
- [ShowIf("ShowPhotosphere")][LabelText("光球参数")]
- public Photon photon;
-
- private void Awake()
- {
- playerController = GetComponent<PlayerController>();
- conductManager = ConductManager.instance;
- gameManager = GameManager.instance;
- soldierLevelRecord = gameManager.GetComponent<SoldierLevelRecord>();
- for (int i = 0; i < 3; i++)
- {
- int demonicRarity = rarity[i];
- switch (conductSkills[i])
- {
- case ConductSkills.NetherfireRebirth:
- ConductManager.NetherfireRebirth netherfireRebirth = conductManager.netherfireRebirth;
- conversionRate[i] = netherfireRebirth.sacrificeRatio[demonicRarity];
- totalCD[i] = netherfireRebirth.cd[demonicRarity];
- break;
- case ConductSkills.FlyingSwords:
- ConductManager.FlyingSwords flyingSwords = conductManager.flyingSwords;
- conversionRate[i] = flyingSwords.sacrificeRatio[demonicRarity];
- totalCD[i] = flyingSwords.cd[demonicRarity];
- break;
- case ConductSkills.IceRain:
- ConductManager.IceRain iceRain = conductManager.iceRain;
- conversionRate[i] = iceRain.sacrificeRatio[demonicRarity];
- totalCD[i] = iceRain.cd[demonicRarity];
- break;
- }
- }
- }
- void Start()
- {
-
- }
- void Update()
- {
- for(int i = 0; i < 3; i++)
- {
- TextMeshProUGUI text = GameUI.instance.CD.GetChild(i).GetComponent<TextMeshProUGUI>();
- if (cd[i] > 0)
- {
- cd[i] -= Time.deltaTime;
- text.text = $"{(int)cd[i]}";
- text.gameObject.SetActive(true);
- }
- else
- {
- text.gameObject.SetActive(false);
- }
- }
- }
- public void Conduct(int demonicId)
- {
- int boostNum = playerController.demonicDic[demonicId].Count;
- int dienum = (int)(boostNum * conversionRate[demonicId]/100f + 0.5f);
- if (dienum == 0 && boostNum >= 1)
- {
- dienum = 1;
- }
- if (dienum > 0)
- {
- cd[demonicId] = totalCD[demonicId];
- GameObject obj;
- List<int> dieId = new List<int>();
- List<Demonic> dieDemonic = new List<Demonic>();
- List<Demonic> demonicDic = new List<Demonic>(playerController.demonicDic[demonicId]);
- for(int i = 0; i < dienum; i++)
- {
- int id = UnityEngine.Random.Range(0, demonicDic.Count);
- dieId.Add(id);
- dieDemonic.Add(demonicDic[id]);
- demonicDic.RemoveAt(id);
- }
- foreach (Demonic d in dieDemonic)
- {
- d.ChangeState(CharacterState.Die);
- }
- int attackDamage = playerController.demonicPrefabs[demonicId].GetComponent<Demonic>().attackController.attackMethod_summon[0].attackInfo.damage
- + soldierLevelRecord.seb[demonicId].summonAttack
- + gameManager.damage;
- List<int> myTreasureTag = gameManager.myTreasuresTag;
- float tagAdd = 1;
- int demonicRarity = rarity[demonicId];
- switch (conductSkills[demonicId])
- {
- case ConductSkills.NetherfireRebirth:
- ConductManager.NetherfireRebirth netherfireRebirth = conductManager.netherfireRebirth;
- for (int i = 0;i<dienum * netherfireRebirth.power[demonicRarity]; i++)
- {
- Demonic demonic = playerController.CreateDemonic(demonicId);
- if (netherfireRebirth.canDie)
- {
- demonic.summonEndToDie = true;
- }
- Vector3 targetPos = transform.position + new Vector3(
- UnityEngine.Random.Range(-netherfireRebirth.randomRange.x / 2, netherfireRebirth.randomRange.x / 2),
- UnityEngine.Random.Range(-netherfireRebirth.randomRange.y / 2, netherfireRebirth.randomRange.y / 2),
- 0);
- if (targetPos.y < 0)
- {
- targetPos.y = 0;
- }
- demonic.gameObject.transform.position = targetPos;
- demonic.attackController.attackSummonId = 0;
- tagAdd += netherfireRebirth.effectBonus[demonicRarity] * myTreasureTag [(int)netherfireRebirth.attributeTag - 1]/ 100;
- int damage = demonic.attackController.attackMethod_summon[0].attackInfo.damage;
- damage = (int)(damage * tagAdd);
- demonic.attackController.attackMethod_summon[0].attackInfo.damage = damage;
- demonic.Attack_summon();
- playerController.lastSoldier = SoldierType.Conduct;
- }
- break;
- case ConductSkills.FlyingSwords:
- ConductManager.FlyingSwords flyingSwords = conductManager.flyingSwords;
- obj = PoolManager.Instantiate(flyingSwords.obj);
- FanFlyingSwords FFS = obj.GetComponent<FanFlyingSwords>();
- FFS.owner = playerController;
- FFS.swordsNum = dienum * flyingSwords.power[demonicRarity];
- tagAdd += flyingSwords.effectBonus[demonicRarity] * myTreasureTag[(int)flyingSwords.attributeTag - 1] / 100;
- FFS.damage = (int)(attackDamage * tagAdd);
- FFS.Biu();
- break;
- case ConductSkills.IceRain:
- ConductManager.IceRain iceRain = conductManager.iceRain;
- obj = PoolManager.Instantiate(iceRain.obj);
- IceRainController iceRainController = obj.GetComponent<IceRainController>();
- iceRainController.owner = playerController;
- iceRainController.swordsNum = dienum * iceRain.power[demonicRarity];
- tagAdd += iceRain.effectBonus[demonicRarity] * myTreasureTag[(int)iceRain.attributeTag - 1] / 100;
- iceRainController.damage = (int)(attackDamage * tagAdd);
- iceRainController.Biu();
- break;
- /*胖子*/
- //融合大胖子
- case ConductSkills.Giant:
- GameObject demonicObj = PoolManager.Instantiate(giant.bigGiant);
- BigSoldier bs = demonicObj.GetComponent<BigSoldier>();
- bs.id = demonicId + 3;
- playerController.demonicDic[bs.id].Add(bs);
- if (bs.id < 3)
- {
- playerController.demonicNums[bs.id].text = playerController.demonicDic[bs.id].Count.ToString();
- }
- int tempthp = boostNum * giant.temptHp;
- bs.playerID = playerController.playerId;
- demonicObj.transform.parent = null;
- demonicObj.transform.localEulerAngles = Vector3.zero;
- bs.boostNum = boostNum;
- if (playerController.isInSoulTower)
- {
- playerController.ls.AddDenomic(bs);
- }
- bs.player = playerController;
- bs.Settings();
- bs.GetTemptHP(tempthp, giant.temptTime);
- int order = bs.baseSortingOrder + playerController.demonicDic[bs.id].Count;
- bs.SetSortingOrder(order);
- Vector3 offset = playerController.demonicSummonPos[0] * 2;
- if (playerController.bodyTrans.localScale.x > 0)
- {
- demonicObj.transform.position = transform.position + offset;
- if (bs.bodyTrans.localScale.x < 0)
- {
- bs.Turn();
- }
- }
- else
- {
- demonicObj.transform.position = transform.position + new Vector3(-offset.x, offset.y, offset.z);
- if (bs.bodyTrans.localScale.x > 0)
- {
- bs.Turn();
- }
- }
- bs.Attack_summon();
- demonicObj.SetActive(true);
- break;
- //光球
- case ConductSkills.Photon:
- playerController.conductCanRelease[demonicId] = false;
- obj = PoolManager.Instantiate(photon.obj);
- obj.transform.position = transform.position + Vector3.up;
- Photosphere photosphere = obj.GetComponent<Photosphere>();
- photosphere.owner = playerController;
- photosphere.conductId = demonicId;
- photosphere.hp = boostNum * photon.photosphereHp;
- photosphere.conductController = this;
- photon.photosphere = photosphere;
- photon.havePhoton = true;
- break;
- // case ConductSkills.SwordsControl:
- // conductCanRelease[cacheConductId] = false;
- // obj = Instantiate(flyingSwordsObj, transform);
- // obj.transform.position = transform.position + Vector3.up;
- // SwordsControl swordsControl = obj.GetComponentInChildren<SwordsControl>();
- // swordsControl.owner = this;
- // swordsControl.conductId = cacheConductId;
- // swordsControl.boostNum = boostNum;
- // break;
- }
- }
- }
- public bool HavePhoton(Character attackFrom, int damage)
- {
- if (photon.havePhoton)
- {
- photon.photosphere.Reflex(attackFrom.beHitTrigger, damage);
- return true;
- }
- return false;
- }
- }
|