| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260 |
- using UnityEngine;
- using Sirenix.OdinInspector;
- using System.Collections.Generic;
- using System;
- using System.Linq;
- public class ConductController : MonoBehaviour
- {
- //组件
- private PlayerController playerController;
- //融魂技
- public enum ConductSkills
- {
- //弓箭手
- [LabelText("怨气弹")]
- AngryBullet,
- [LabelText("扇形飞剑")]
- FlyingSwords,
- //胖子
- [LabelText("合成大胖子")]
- Giant,
- [LabelText("光球")]
- Photon,
- [LabelText("增加攻击力")]
- AddAttack,
- //棒子
- [LabelText("泰山压顶")]
- Mountain,
- [LabelText("气功波")]
- WavePower,
- [LabelText("御剑术")]
- SwordsControl,
- }
- [LabelText("转换率")] public float[] conversionRate;
- [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>();
- }
- void Start()
- {
-
- }
- void Update()
- {
-
- }
- public void Conduct(int demonicId)
- {
- int boostNum = playerController.demonicDic[demonicId].Count;
- int dienum = (int)(boostNum * conversionRate[demonicId] + 0.5f);
- if (dienum == 0 && boostNum >= 1)
- {
- dienum = 1;
- }
- if (dienum > 0)
- {
- GameObject obj;
- List<int> dieId = new List<int>();
- List<Demonic> dieDemonic = new List<Demonic>();
- while (dieId.Count < dienum)
- {
- int id = UnityEngine.Random.Range(0, boostNum);
- if (!dieId.Exists(t => t == id))
- {
- dieId.Add(id);
- dieDemonic.Add(playerController.demonicDic[demonicId][id]);
- }
- }
- foreach (Demonic d in dieDemonic)
- {
- d.ChangeState(CharacterState.Die);
- }
- switch (conductSkills[demonicId])
- {
- /*胖子*/
- //融合大胖子
- case ConductSkills.Giant:
- GameObject demonicObj = PoolManager.Instantiate(giant.bigGiant);
- demonicObj.SetActive(false);
- 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();
- }
- }
- demonicObj.SetActive(true);
- break;
- //光球
- case ConductSkills.Photon:
- playerController.conductCanRelease[demonicId] = false;
- obj = Instantiate(photon.obj, transform);
- 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.AddAttack:
- // List<Demonic> newGiants = new List<Demonic>();
- // foreach (Demonic d in demonicDic[cacheConductId])
- // {
- // if (!d.isDie)
- // {
- // newGiants.Add(d);
- // if (d.attackController.addAttackEffect == null)
- // {
- // d.attackController.addAttackEffect = Instantiate(attackEffect, d.bodyTrans.position, new Quaternion(0, 0, 0, 0), d.bodyTrans);
- // }
- // d.attackController.addAttackEffect.transform.GetChild(0).gameObject.SetActive(true);
- // }
- // }
- // foreach (Demonic d in newGiants)
- // {
- // int damage = d.attackController.curDamage;
- // d.attackController.curDamage += (int)(addRate * boostNum * damage);
- // }
- // break;
- // //气功师
- // case ConductSkills.Mountain:
- // conductCanRelease[cacheConductId] = false;
- // GameObject curMountain = Instantiate(mountain, null);
- // Vector3 moffset = mountainOffset;
- // Vector3 sc = curMountain.transform.localScale;
- // sc.x = largeX * dienum;
- // curMountain.transform.localScale = sc;
- // if (bodyTrans.localScale.x < 0)
- // {
- // moffset.x = mountainOffset.x + sc.x / 2;
- // }
- // else
- // {
- // moffset.x = -mountainOffset.x - sc.x / 2;
- // }
- // Mountain MT = curMountain.GetComponent<Mountain>();
- // curMountain.transform.position = transform.position + moffset;
- // MT.pc = this;
- // MT.id = cacheConductId;
- // MT.demonicNum = boostNum;
- // break;
- // case ConductSkills.WavePower:
- // rb.constraints = RigidbodyConstraints.FreezeAll;
- // rb.useGravity = false;
- // conductCanRelease[cacheConductId] = false;
- // obj = Instantiate(wavePowerObj, transform);
- // obj.transform.position = transform.position + Vector3.up;
- // WavePowerSkill wps = obj.GetComponent<WavePowerSkill>();
- // wps.continueTime = wps.singleTime * dienum;
- // wps.longFX = (int)bodyTrans.localScale.x;
- // wps.damage = wavePowerDamage * boostNum;
- // wps.cacheID = cacheConductId;
- // wps.pc = this;
- // 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;
- // //弓箭手
- // case ConductSkills.AngryBullet:
- // conductCanRelease[cacheConductId] = false;
- // obj = Instantiate(angryBulletObj);
- // AngryBulletControl angryBulletControl = obj.GetComponent<AngryBulletControl>();
- // angryBulletControl.playerController = this;
- // angryBulletControl.cacheConductId = cacheConductId;
- // angryBulletControl.maxNum = boostNum * angryBulletNum;
- // break;
- // case ConductSkills.FlyingSwords:
- // obj = Instantiate(fanFlyingSwords);
- // FanFlyingSwords FFS = obj.GetComponent<FanFlyingSwords>();
- // FFS.owner = this;
- // FFS.angleRange = flyingSwordsAngleRange;
- // FFS.arrivalAngle = flyintSwordsArrivalAngle;
- // FFS.swordsNum = boostNum * flyingSwordsNum;
- // FFS.Biu();
- // break;
- }
- }
- }
- public bool HavePhoton(Character attackFrom, int damage)
- {
- if (photon.havePhoton)
- {
- photon.photosphere.Reflex(attackFrom.beHitTrigger, damage);
- return true;
- }
- return false;
- }
- }
|