mirror of
https://github.com/ConjureETS/Bomberman.git
synced 2026-03-24 02:10:59 +00:00
26 lines
770 B
C#
26 lines
770 B
C#
using System;
|
|
using UnityEngine;
|
|
|
|
public class Arena : MonoBehaviour {
|
|
public MapData data;
|
|
public GameObject explosionPrefab;
|
|
|
|
public void Explode(Vector3 position, int strength) {
|
|
if (strength <= 0)
|
|
throw new ArgumentException("Explosion strength must be positive.");
|
|
|
|
Vector3 explosionPos = data.GetClosestTilePos(position);
|
|
|
|
for (int i = 0; i < 3; i++) {
|
|
var rotation = explosionPrefab.transform.rotation;
|
|
var newRotation = Quaternion.Euler(rotation.eulerAngles + Vector3.up * i * 60f);
|
|
|
|
var explosion = Instantiate(explosionPrefab, explosionPos, newRotation);
|
|
//TODO multiply explosion.transform.scale.y by strength
|
|
|
|
Destroy(explosion, 1f);
|
|
}
|
|
}
|
|
|
|
public Vector3 GetClosestTilePos(Vector3 pos) => data.GetClosestTilePos(pos);
|
|
} |