private void SpawnSplit(UnitsMap map, BoardController boardController, CardinalDirections direction, Point attackerPosition) { if (InstantiatedSplits >= maxSplits) { return; } InstantiatedSplits++; Logcat.I(this, $"Multisplit instances {InstantiatedSplits}"); CardinalDirections[] directions = PlayerUtils.HoloBlastSplitDirections(direction); Vector3 position = PointConverter.ToVector(attackerPosition) + PointConverter.ToVector(Direction.GetDirection(direction)); position.y = fixedPosition; Quaternion rotation = RotationHelper.GetRotation(direction); MultiSplit instance = Instantiate(split, position, rotation); instance.SetUp(this.unitsMap, boardController, attackerPosition, directions, secondAttackDamage, secondAttackDamage, knockback); }
private void OnCollisionEnter(Collision collision) { Unit unit = collision.gameObject.GetComponent <Unit>(); Vector3 otherPosition = collision.gameObject.transform.position; if (otherPosition == PointConverter.ToVector(attackerPosition)) { return; } if (unit == null) { MultiSplit.Destroy(this.gameObject); return; } this.SpawnSplit(unitsMap, boardController, blastSplit[0], unit.GetPosition()); this.SpawnSplit(unitsMap, boardController, blastSplit[1], unit.GetPosition()); MultiSplit.Destroy(this.gameObject); }