private void RemoveItem(IClimber climber) { if (_climbers.Contains(climber)) { _climbers.Remove(climber); } }
private void Move(IClimber climber) { var tr = climber.transform; var pos = tr.position; var direction = Vector3.down; var toPos = pos + direction * _moveSpeed; var step = _moveSpeed * Time.deltaTime; tr.position = Vector3.MoveTowards(pos, toPos, step); }
private void AddItem(IClimber climber, GameObjectCollisionHandler wall) { if (!_climbers.Contains(climber)) { _climbers.Add(climber); climber.OnCanceledCling += CanceledCling; climber.OnDestroyed += () => { _climbers.Remove(climber); }; var direction = climber.transform.position - wall.transform.position; direction.y = 0; direction.z = 0; direction = direction.normalized; climber.transform.rotation = Quaternion.LookRotation(direction); } }
private void CanceledCling(IClimber climber) { RemoveItem(climber); climber.OnCanceledCling -= CanceledCling; }