コード例 #1
0
 public void Punch()
 {
     if (punchCurrentCD <= 0)
     {
         punchCurrentCD = bossDatas.punchSettings.cooldown;
         GameObject punchObj         = Instantiate(Resources.Load <GameObject>("EnemyResource/BossResource/BossPunch"));
         Vector3    newPunchPosition = transform.position + (topPart.forward * bossDatas.punchSettings.distance);
         RaycastHit hit;
         if (Physics.Raycast(punchObj.transform.position, Vector3.down, out hit, 20f, LayerMask.GetMask("Environment")))
         {
             newPunchPosition.y = hit.point.y;
         }
         punchObj.transform.position = newPunchPosition;
         Vector3 punchForwardFlat = currentTarget.transform.position - transform.position;
         punchForwardFlat.y            = 0;
         punchObj.transform.rotation   = Quaternion.LookRotation(punchForwardFlat);
         punchObj.transform.localScale = Vector3.one * bossDatas.punchSettings.hitboxSize;
         BossPunch punchScript = punchObj.GetComponent <BossPunch>();
         punchScript.punchChargeDuration   = bossDatas.punchSettings.chargeDuration;
         punchScript.punchChargeSpeedCurve = bossDatas.punchSettings.chargeSpeedCurve;
         punchScript.punchDamages          = bossDatas.punchSettings.damages;
         punchScript.fillColorHit          = bossDatas.punchSettings.hitColor;
         punchScript.fillColorCharging     = bossDatas.punchSettings.chargingColor;
         punchScript.punchPushForce        = bossDatas.punchSettings.pushForce;
         punchScript.punchPushHeight       = bossDatas.punchSettings.pushHeight;
         punchScript.StartPunch(animator);
         Freeze(bossDatas.punchSettings.chargeDuration);
     }
 }
コード例 #2
0
 public void HammerPunch()
 {
     if (hammerCurrentCD <= 0)
     {
         Vector3    playerPosition   = currentTarget.transform.position;
         Collider[] enviroNearPlayer = Physics.OverlapSphere(playerPosition, 5f, LayerMask.GetMask("Environment"));
         Transform  nearestTile      = null;
         float      nearestDistance  = 5f;
         for (int i = 0; i < enviroNearPlayer.Length; i++)
         {
             if (enviroNearPlayer[i].gameObject.tag == "Boss_Tile")
             {
                 if (Vector3.Distance(enviroNearPlayer[i].transform.position, playerPosition) <= nearestDistance)
                 {
                     nearestTile     = enviroNearPlayer[i].transform;
                     nearestDistance = Vector3.Distance(enviroNearPlayer[i].transform.position, playerPosition);
                 }
             }
         }
         if (nearestTile == null)
         {
             return;
         }
         hammerCurrentCD = bossDatas.hammerSettings.cooldown;
         GameObject hammerObj         = Instantiate(Resources.Load <GameObject>("EnemyResource/BossResource/BossHammer"));
         Vector3    newHammerPosition = nearestTile.transform.position + Vector3.up * 1f;
         RaycastHit hit;
         if (Physics.Raycast(hammerObj.transform.position, Vector3.down, out hit, 100f, LayerMask.GetMask("Environment")))
         {
             newHammerPosition.y = hit.point.y;
         }
         hammerObj.transform.position = newHammerPosition;
         Vector3 hammerForwardFlat = currentTarget.transform.position - transform.position;
         hammerForwardFlat.y            = 0;
         hammerObj.transform.rotation   = Quaternion.identity;
         hammerObj.transform.localScale = Vector3.one * 10f;
         BossPunch hammerScript = hammerObj.GetComponent <BossPunch>();
         hammerScript.fillColorCharging     = bossDatas.hammerSettings.chargingColor;
         hammerScript.fillColorHit          = bossDatas.hammerSettings.hitColor;
         hammerScript.punchChargeDuration   = bossDatas.hammerSettings.chargeDuration;
         hammerScript.punchChargeSpeedCurve = bossDatas.hammerSettings.chargeSpeedCurve;
         hammerScript.StartPunch(animator);
         Freeze(bossDatas.hammerSettings.chargeDuration);
     }
 }