70 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			70 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			C#
		
	
	
	
| using System.Collections;
 | |
| using System.Collections.Generic;
 | |
| using UnityEngine;
 | |
| 
 | |
| public class BlockUnit : MonoBehaviour
 | |
| {
 | |
|     public BlockType BType => mBType;
 | |
|     public int Level => mLevel;
 | |
|     public int GroupID => mGroupID;
 | |
| 
 | |
|     [SerializeField] BlockType mBType;
 | |
|     [SerializeField] int mLevel;
 | |
|     [SerializeField] int mGroupID;
 | |
| 
 | |
|     public List<SoldierUnit> AllSoldiers
 | |
|     {
 | |
|         get
 | |
|         {
 | |
|             if (mAllSoldiers == null)
 | |
|             {
 | |
|                 mAllSoldiers = Utils.GetChildList<SoldierUnit>(transform);
 | |
|                 for (int i = 0; i < mAllSoldiers.Count; i++)
 | |
|                 {
 | |
|                     mAllSoldiers[i].BType = mBType;
 | |
|                     mAllSoldiers[i].Level = mLevel;
 | |
|                     mAllSoldiers[i].GroupID = mGroupID;
 | |
|                 }
 | |
|             }
 | |
| 
 | |
|             return mAllSoldiers;
 | |
|         }
 | |
|     }
 | |
|     private List<SoldierUnit> mAllSoldiers;
 | |
| 
 | |
|     public void SetGroupID(int pGroupID)
 | |
|     {
 | |
|         mGroupID = pGroupID;
 | |
|     }
 | |
| 
 | |
|     public void SetAsBoss()
 | |
|     {
 | |
|         List<SoldierUnit> tSoldierList = Utils.GetChildList<SoldierUnit>(transform);
 | |
|         for (int i = 0; i < tSoldierList.Count; i++)
 | |
|         {
 | |
|             tSoldierList[i].SetScale(1.5f);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     public bool IsMergable(BlockUnit pOtherUnit)
 | |
|     {
 | |
|         if (mLevel >= GameConfig.Instance.BlockMaxLevel || pOtherUnit.mLevel >= GameConfig.Instance.BlockMaxLevel)
 | |
|             return false;
 | |
| 
 | |
|         return mLevel == pOtherUnit.mLevel && mBType == pOtherUnit.mBType;
 | |
|     }
 | |
| 
 | |
|     public void SetTrigger(SoldierACTrigger pTrigger)
 | |
|     {
 | |
|         for (int i = 0; i < AllSoldiers.Count; i++)
 | |
|         {
 | |
|             AllSoldiers[i].SetACTrigger(pTrigger);
 | |
|         }
 | |
|     }
 | |
| }
 | |
| 
 | |
| public enum BlockType
 | |
| {
 | |
|     Monster = 0,
 | |
|     Human
 | |
| } |